Skip to content

Commit 6ae9ded

Browse files
srujzscommit-bot@chromium.org
authored andcommitted
Migrate html tests off of unittest.dart
Changed tests either use expect/minitest or async_helper/async_minitest as a replacement. There are still a few outstanding tests that need to be migrated off of unittest.dart. Change-Id: I9231d453f61507110b5a89360dfb9e5647a5b4c7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135420 Reviewed-by: Sigmund Cherem <[email protected]> Reviewed-by: Bob Nystrom <[email protected]> Commit-Queue: Srujan Gaddam <[email protected]>
1 parent 361f881 commit 6ae9ded

38 files changed

Lines changed: 56 additions & 137 deletions

tests/lib_2/html/async_cancellingisolate.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
library async_cancellingisolate;
22

33
import 'dart:async';
4-
import 'package:unittest/unittest.dart';
4+
import 'package:expect/minitest.dart';
55

66
main(message, replyTo) {
77
var command = message.first;

tests/lib_2/html/async_oneshot.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dart:async';
2-
import 'package:unittest/unittest.dart';
2+
import 'package:expect/minitest.dart';
33

44
main(message, replyTo) {
55
var command = message.first;

tests/lib_2/html/async_periodictimer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
library async_periodictimer;
22

33
import 'dart:async';
4-
import 'package:unittest/unittest.dart';
4+
import 'package:expect/minitest.dart';
55

66
main(message, replyTo) {
77
var command = message.first;

tests/lib_2/html/async_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
library async_test;
22

3-
import 'package:unittest/unittest.dart';
4-
import 'package:unittest/html_config.dart';
3+
import 'package:async_helper/async_minitest.dart';
54

65
import 'dart:async';
76
import 'dart:isolate';
@@ -17,8 +16,6 @@ periodicTimerIsolate(message) =>
1716
cancellingIsolate(message) => cancelling_test.main(message.first, message.last);
1817

1918
main() {
20-
useHtmlConfiguration();
21-
2219
test('one shot timer in pure isolate', () {
2320
var response = new ReceivePort();
2421
var remote = Isolate.spawn(oneshot, [

tests/lib_2/html/callback_list_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ library callback_list_test;
33
import 'dart:html';
44
import 'dart:async';
55

6-
import 'package:unittest/unittest.dart';
7-
import 'package:unittest/html_config.dart';
6+
import 'package:expect/minitest.dart';
87

98
var callbackDone = false;
109
bool isCallbackDone() => callbackDone;
@@ -24,7 +23,6 @@ Future waitUntilCallbackDone(bool test()) async {
2423
}
2524

2625
void main() async {
27-
useHtmlConfiguration();
2826
window.navigator.persistentStorage.requestQuota(1024 * 1024, _quotaHandler);
2927

3028
await waitUntilCallbackDone(isCallbackDone);

tests/lib_2/html/canvas_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library CanvasTest;
22

33
import 'dart:html';
44

5-
import 'package:unittest/unittest.dart';
5+
import 'package:async_helper/async_minitest.dart';
66

77
main() {
88
CanvasElement canvas;
@@ -19,7 +19,7 @@ main() {
1919
ImageData image = context.createImageData(canvas.width, canvas.height);
2020
List<int> data = image.data;
2121

22-
expect(data, hasLength(40000));
22+
expect(data.length, 40000);
2323
checkPixel(data, 0, [0, 0, 0, 0]);
2424
checkPixel(data, width * height - 1, [0, 0, 0, 0]);
2525

tests/lib_2/html/css_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library CssTest;
22

33
import 'dart:html';
44

5-
import 'package:unittest/unittest.dart';
5+
import 'package:expect/minitest.dart';
66

77
main() {
88
group('supportsPointConversions', () {

tests/lib_2/html/cssstyledeclaration_test.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ library CssStyleDeclarationTest;
77
import 'dart:async';
88
import 'dart:html';
99

10-
import 'package:unittest/unittest.dart';
10+
import 'package:async_helper/async_minitest.dart';
1111

1212
import 'utils.dart';
1313

@@ -23,23 +23,23 @@ main() {
2323

2424
test('default constructor is empty', () {
2525
var style = new CssStyleDeclaration();
26-
expect(style.cssText, isEmpty);
27-
expect(style.getPropertyPriority('color'), isEmpty);
28-
expect(style.item(0), isEmpty);
29-
expect(style, hasLength(0));
26+
expect(style.cssText.isEmpty, isTrue);
27+
expect(style.getPropertyPriority('color').isEmpty, isTrue);
28+
expect(style.item(0).isEmpty, isTrue);
29+
expect(style.length, 0);
3030
// These assertions throw a UnimplementedError in dartium:
3131
// expect(style.parentRule, isNull);
3232
// expect(style.getPropertyCssValue('color'), isNull);
3333
// expect(style.getPropertyShorthand('color'), isNull);
3434
});
3535

3636
test('length is wrapped', () {
37-
expect(createTestStyle(), hasLength(2));
37+
expect(createTestStyle().length, 2);
3838
});
3939

4040
test('getPropertyPriority is wrapped', () {
4141
var style = createTestStyle();
42-
expect(style.getPropertyPriority("color"), isEmpty);
42+
expect(style.getPropertyPriority("color").isEmpty, isTrue);
4343
expect(style.getPropertyPriority("width"), equals("important"));
4444
});
4545

@@ -94,7 +94,7 @@ main() {
9494
new Timer(const Duration(milliseconds: 10), expectAsync(() {
9595
element.style.textDecoration = 'underline';
9696
var style = element.getComputedStyle();
97-
expect(style.textDecoration, contains('underline'));
97+
expect(style.textDecoration.contains('underline'), isTrue);
9898
}));
9999
});
100100

tests/lib_2/html/event_customevent_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
library EventCustomEventTest;
66

7-
import 'package:unittest/unittest.dart';
8-
import 'package:unittest/html_config.dart';
7+
import 'package:async_helper/async_minitest.dart';
98
import 'dart:html';
109
import 'dart:js' as js;
1110

@@ -16,8 +15,6 @@ class DartPayloadData {
1615
}
1716

1817
main() {
19-
useHtmlConfiguration();
20-
2118
test('custom events', () {
2219
var provider = new EventStreamProvider<CustomEvent>('foo');
2320
var el = new DivElement();

tests/lib_2/html/events_test.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ library tests.html.events_test;
77
import 'dart:async';
88
import 'dart:html';
99
import 'package:unittest/unittest.dart';
10-
import 'package:unittest/html_config.dart';
1110
import 'package:unittest/src/expected_function.dart' show ExpectedFunction;
1211

1312
T Function() expectAsync0<T>(T Function() callback,
@@ -19,8 +18,6 @@ T Function(A) expectAsync1<T, A>(T Function(A) callback,
1918
new ExpectedFunction<T>(callback, count, max).max1;
2019

2120
main() {
22-
useHtmlConfiguration();
23-
2421
test('TimeStamp', () {
2522
var event = new Event('test');
2623

0 commit comments

Comments
 (0)