Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e8d2732

Browse files
committed
add test
1 parent 2132a25 commit e8d2732

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:typed_data';
6+
7+
import 'package:test/bootstrap/browser.dart';
8+
import 'package:test/test.dart';
9+
10+
import 'package:ui/src/engine/vector_math.dart';
11+
12+
void main() {
13+
internalBootstrapBrowserTest(() => testMain);
14+
}
15+
16+
void testMain() {
17+
test('toMatrix32', () {
18+
final List<double> data = <double>[
19+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
20+
];
21+
final Float32List m32 = toMatrix32(Float64List.fromList(data));
22+
expect(m32, Float32List.fromList(data));
23+
});
24+
25+
test('FastMatrix32.transform', () {
26+
final FastMatrix32 fast = FastMatrix32(Float32List.fromList(<double>[
27+
2, 1, 0, 0,
28+
1, 3, 0, 0,
29+
0, 0, 0, 0,
30+
4, 5, 0, 1
31+
]));
32+
fast.transform(6, 7);
33+
34+
// Just make sure that the fast version produces a result consistent with
35+
// the slow version.
36+
final Matrix4 slow = Matrix4.fromFloat32List(fast.matrix);
37+
final Float32List slowTransformed = Float32List.fromList(<double>[
38+
6, 7, 0
39+
]);
40+
slow.transform3(slowTransformed);
41+
42+
expect(fast.transformedX, slowTransformed[0]);
43+
expect(fast.transformedY, slowTransformed[1]);
44+
});
45+
}

0 commit comments

Comments
 (0)