Script that runs engine unit tests and Dart tests of engine APIs (flutter/engine#3372)
The Dart tests were migrated from the flutter/test/engine suite in the framework repository
This commit is contained in:
2
engine/src/flutter/testing/dart/.gitignore
vendored
Normal file
2
engine/src/flutter/testing/dart/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.packages
|
||||
pubspec.lock
|
||||
44
engine/src/flutter/testing/dart/color_test.dart
Normal file
44
engine/src/flutter/testing/dart/color_test.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright 2015 The Chromium 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("color accessors should work", () {
|
||||
Color foo = const Color(0x12345678);
|
||||
expect(foo.alpha, equals(0x12));
|
||||
expect(foo.red, equals(0x34));
|
||||
expect(foo.green, equals(0x56));
|
||||
expect(foo.blue, equals(0x78));
|
||||
});
|
||||
|
||||
test("paint set to black", () {
|
||||
Color c = const Color(0x00000000);
|
||||
Paint p = new Paint();
|
||||
p.color = c;
|
||||
expect(c.toString(), equals('Color(0x00000000)'));
|
||||
});
|
||||
|
||||
test("color created with out of bounds value", () {
|
||||
try {
|
||||
Color c = const Color(0x100 << 24);
|
||||
Paint p = new Paint();
|
||||
p.color = c;
|
||||
} catch (e) {
|
||||
expect(e != null, equals(true));
|
||||
}
|
||||
});
|
||||
|
||||
test("color created with wildly out of bounds value", () {
|
||||
try {
|
||||
Color c = const Color(1 << 1000000);
|
||||
Paint p = new Paint();
|
||||
p.color = c;
|
||||
} catch (e) {
|
||||
expect(e != null, equals(true));
|
||||
}
|
||||
});
|
||||
}
|
||||
20
engine/src/flutter/testing/dart/paragraph_builder_test.dart
Normal file
20
engine/src/flutter/testing/dart/paragraph_builder_test.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright 2015 The Chromium 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("Should be able to build and layout a paragraph", () {
|
||||
ParagraphBuilder builder = new ParagraphBuilder(new ParagraphStyle());
|
||||
builder.addText('Hello');
|
||||
Paragraph paragraph = builder.build();
|
||||
expect(paragraph, isNotNull);
|
||||
|
||||
paragraph.layout(new ParagraphConstraints(width: 800.0));
|
||||
expect(paragraph.width, isNonZero);
|
||||
expect(paragraph.height, isNonZero);
|
||||
});
|
||||
}
|
||||
3
engine/src/flutter/testing/dart/pubspec.yaml
Normal file
3
engine/src/flutter/testing/dart/pubspec.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
name: engine_tests
|
||||
dependencies:
|
||||
test: 0.12.15+4
|
||||
37
engine/src/flutter/testing/dart/rect_test.dart
Normal file
37
engine/src/flutter/testing/dart/rect_test.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2015 The Chromium 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("rect accessors", () {
|
||||
Rect r = new Rect.fromLTRB(1.0, 3.0, 5.0, 7.0);
|
||||
expect(r.left, equals(1.0));
|
||||
expect(r.top, equals(3.0));
|
||||
expect(r.right, equals(5.0));
|
||||
expect(r.bottom, equals(7.0));
|
||||
});
|
||||
|
||||
test("rect created by width and height", () {
|
||||
Rect r = new Rect.fromLTWH(1.0, 3.0, 5.0, 7.0);
|
||||
expect(r.left, equals(1.0));
|
||||
expect(r.top, equals(3.0));
|
||||
expect(r.right, equals(6.0));
|
||||
expect(r.bottom, equals(10.0));
|
||||
});
|
||||
|
||||
test("rect intersection", () {
|
||||
Rect r1 = new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0);
|
||||
Rect r2 = new Rect.fromLTRB(50.0, 50.0, 200.0, 200.0);
|
||||
Rect r3 = r1.intersect(r2);
|
||||
expect(r3.left, equals(50.0));
|
||||
expect(r3.top, equals(50.0));
|
||||
expect(r3.right, equals(100.0));
|
||||
expect(r3.bottom, equals(100.0));
|
||||
Rect r4 = r2.intersect(r1);
|
||||
expect(r4, equals(r3));
|
||||
});
|
||||
}
|
||||
11
engine/src/flutter/testing/fail_test.dart
Normal file
11
engine/src/flutter/testing/fail_test.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017 The Chromium 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 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('test smoke test -- this test SHOULD FAIL', () {
|
||||
expect(false, isTrue);
|
||||
});
|
||||
}
|
||||
18
engine/src/flutter/testing/run_tests.sh
Executable file
18
engine/src/flutter/testing/run_tests.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
out/host_debug_unopt/ftl_unittests
|
||||
out/host_debug_unopt/synchronization_unittests
|
||||
out/host_debug_unopt/wtf_unittests
|
||||
|
||||
pushd flutter/testing/dart
|
||||
pub get
|
||||
popd
|
||||
|
||||
# Verify that a failing test returns a failure code.
|
||||
! out/host_debug_unopt/sky_shell --disable-observatory --disable-diagnostic --non-interactive --enable-checked-mode --packages=flutter/testing/dart/.packages flutter/testing/fail_test.dart
|
||||
|
||||
for TEST_SCRIPT in flutter/testing/dart/*.dart; do
|
||||
out/host_debug_unopt/sky_shell --disable-observatory --disable-diagnostic --non-interactive --enable-checked-mode $TEST_SCRIPT
|
||||
done
|
||||
Reference in New Issue
Block a user