flutter_flutter/lib/web_ui/test/rect_test.dart
nturgut bb24b4938f
[web] Build unit tests with dart2js instead of build_runner (#20390)
* change from build_runner to dart2js

* add internalBootstrapBrowserTest to some of the tests

* add internalBootstrapBrowserTest to all remaining tests

* make tests build in paralel. Total time dropped from 586 to 177 seconds for 8 core MacBook

* change isolates with pool

* fixing analysis errors

* skipping canvaskit tests for ios-safari

* copy image files to the build directory

* adding internalBootstrapBrowserTest to newly added tests

* add internalBootstrapBrowserTest to faling path iterator test

* necessary changes to make chrome windows work

* in windows test in chrome instead of edge. our edge code was for legacy edge

* do not run golden unit tests on Windows LUCI bots for now

* addressing reviewer comments. Adding a method for deciding when to run integration tests.

* remove lines that I forgot to remove

* fixing analysis error. add issue for todo

* add bootstap to a test file

* adding bootstrap to another test

* add internalBootstrapBrowserTest to a golden test

* return test result in bat file. use archieve package to unzip

* fixing logs for chrome_installer

* use archieve and archieve entity instead of dynamic

* adding comments for windows platform archieve part

* addressing reviewer comments

* change readme file
2020-08-17 16:19:27 -07:00

88 lines
2.8 KiB
Dart

// 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.
// @dart = 2.6
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';
import 'package:ui/ui.dart';
void main() {
internalBootstrapBrowserTest(() => testMain);
}
void testMain() {
test('rect accessors', () {
const Rect r = 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', () {
const Rect r = 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));
expect(r.shortestSide, equals(5.0));
expect(r.longestSide, equals(7.0));
});
test('rect intersection', () {
const Rect r1 = Rect.fromLTRB(0.0, 0.0, 100.0, 100.0);
const Rect r2 = Rect.fromLTRB(50.0, 50.0, 200.0, 200.0);
final 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));
final Rect r4 = r2.intersect(r1);
expect(r4, equals(r3));
});
test('rect expandToInclude overlapping rects', () {
const Rect r1 = Rect.fromLTRB(0.0, 0.0, 100.0, 100.0);
const Rect r2 = Rect.fromLTRB(50.0, 50.0, 200.0, 200.0);
final Rect r3 = r1.expandToInclude(r2);
expect(r3.left, equals(0.0));
expect(r3.top, equals(0.0));
expect(r3.right, equals(200.0));
expect(r3.bottom, equals(200.0));
final Rect r4 = r2.expandToInclude(r1);
expect(r4, equals(r3));
});
test('rect expandToInclude crossing rects', () {
const Rect r1 = Rect.fromLTRB(50.0, 0.0, 50.0, 200.0);
const Rect r2 = Rect.fromLTRB(0.0, 50.0, 200.0, 50.0);
final Rect r3 = r1.expandToInclude(r2);
expect(r3.left, equals(0.0));
expect(r3.top, equals(0.0));
expect(r3.right, equals(200.0));
expect(r3.bottom, equals(200.0));
final Rect r4 = r2.expandToInclude(r1);
expect(r4, equals(r3));
});
test('size created from doubles', () {
const Size size = Size(5.0, 7.0);
expect(size.width, equals(5.0));
expect(size.height, equals(7.0));
expect(size.shortestSide, equals(5.0));
expect(size.longestSide, equals(7.0));
});
test('rounded rect created from rect and radii', () {
const Rect baseRect = Rect.fromLTWH(1.0, 3.0, 5.0, 7.0);
final RRect r = RRect.fromRectXY(baseRect, 1.0, 1.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));
expect(r.shortestSide, equals(5.0));
expect(r.longestSide, equals(7.0));
});
}