forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradient_test.dart
71 lines (65 loc) · 1.88 KB
/
gradient_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui';
import 'package:test/test.dart';
void main() {
test('Gradient.radial with no focal point', () {
expect(
new Gradient.radial(
Offset.zero,
null,
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
<double>[0.0, 1.0],
TileMode.mirror),
isNotNull,
);
});
// this is just a radial gradient, focal point is discarded.
test('radial center and focal == Offset.zero and focalRadius == 0.0 is ok',
() {
expect(
() => new Gradient.radial(
Offset.zero,
0.0,
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
<double>[0.0, 1.0],
TileMode.mirror,
null,
Offset.zero,
0.0,
),
isNotNull);
});
test('radial center != focal and focalRadius == 0.0 is ok', () {
expect(
() => new Gradient.radial(
Offset.zero,
0.0,
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
<double>[0.0, 1.0],
TileMode.mirror,
null,
const Offset(2.0, 2.0),
0.0,
),
isNotNull);
});
// this would result in div/0 on skia side.
test('radial center and focal == Offset.zero and focalRadius != 0.0 assert',
() {
expect(
() => new Gradient.radial(
Offset.zero,
0.0,
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
<double>[0.0, 1.0],
TileMode.mirror,
null,
Offset.zero,
1.0,
),
throwsA(const TypeMatcher<AssertionError>()),
);
});
}