diff --git a/testing/dart/.gitignore b/testing/dart/.gitignore new file mode 100644 index 0000000000000..93d2a1eaede95 --- /dev/null +++ b/testing/dart/.gitignore @@ -0,0 +1,2 @@ +.packages +pubspec.lock diff --git a/testing/dart/color_test.dart b/testing/dart/color_test.dart new file mode 100644 index 0000000000000..2b231f94ba275 --- /dev/null +++ b/testing/dart/color_test.dart @@ -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)); + } + }); +} diff --git a/testing/dart/paragraph_builder_test.dart b/testing/dart/paragraph_builder_test.dart new file mode 100644 index 0000000000000..faee641315f69 --- /dev/null +++ b/testing/dart/paragraph_builder_test.dart @@ -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); + }); +} diff --git a/testing/dart/pubspec.yaml b/testing/dart/pubspec.yaml new file mode 100644 index 0000000000000..43f35ec12aaa3 --- /dev/null +++ b/testing/dart/pubspec.yaml @@ -0,0 +1,3 @@ +name: engine_tests +dependencies: + test: 0.12.15+4 diff --git a/testing/dart/rect_test.dart b/testing/dart/rect_test.dart new file mode 100644 index 0000000000000..874be265d2c64 --- /dev/null +++ b/testing/dart/rect_test.dart @@ -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)); + }); +} diff --git a/testing/fail_test.dart b/testing/fail_test.dart new file mode 100644 index 0000000000000..6c642710fe914 --- /dev/null +++ b/testing/fail_test.dart @@ -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); + }); +} diff --git a/testing/run_tests.sh b/testing/run_tests.sh new file mode 100755 index 0000000000000..52e2f831a2a9d --- /dev/null +++ b/testing/run_tests.sh @@ -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