Skip to content

Commit

Permalink
Script that runs engine unit tests and Dart tests of engine APIs (flu…
Browse files Browse the repository at this point in the history
…tter#3372)

The Dart tests were migrated from the flutter/test/engine suite in the
framework repository
  • Loading branch information
jason-simmons authored Jan 30, 2017
1 parent 7019432 commit d92d4c1
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 0 deletions.
2 changes: 2 additions & 0 deletions testing/dart/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.packages
pubspec.lock
44 changes: 44 additions & 0 deletions testing/dart/color_test.dart
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions testing/dart/paragraph_builder_test.dart
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions testing/dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: engine_tests
dependencies:
test: 0.12.15+4
37 changes: 37 additions & 0 deletions testing/dart/rect_test.dart
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions testing/fail_test.dart
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions testing/run_tests.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d92d4c1

Please sign in to comment.