Skip to content

Commit

Permalink
Move most of the dart:ui tests to package:test. (flutter#55090)
Browse files Browse the repository at this point in the history
Work towards flutter/flutter#133569.

There are a couple with custom matchers I'd like to migrate in a follow-up PR.
  • Loading branch information
matanlurey authored Sep 11, 2024
1 parent dd2a02f commit b18adaf
Show file tree
Hide file tree
Showing 39 changed files with 86 additions and 76 deletions.
4 changes: 2 additions & 2 deletions testing/dart/assets_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'dart:convert';
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('Loading an asset that does not exist returns null', () async {
Expand Down Expand Up @@ -81,7 +81,7 @@ void main() {
final List<int> bundledFontImage = await _createPictureFromFont('Roboto2');
// Bundling fonts is disabled, so the font selected in both cases should be ahem.
// Therefore each buffer will contain identical contents.
expect(ahemImage, notEquals(bundledFontImage));
expect(ahemImage, isNot(bundledFontImage));
});
}

Expand Down
2 changes: 1 addition & 1 deletion testing/dart/channel_buffers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'dart:convert';
import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

ByteData _makeByteData(String str) {
final Uint8List list = utf8.encode(str);
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/codec_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

import 'impeller_enabled.dart';

Expand Down
2 changes: 1 addition & 1 deletion testing/dart/color_filter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

import 'impeller_enabled.dart';

Expand Down
10 changes: 5 additions & 5 deletions testing/dart/compositing_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('Scene.toImageSync succeeds', () async {
Expand Down Expand Up @@ -76,7 +76,7 @@ void main() {
if (assertsEnabled) {
expect(
() => builder.addPicture(Offset.zero, picture),
throwsA(isInstanceOf<AssertionError>()),
throwsA(const isInstanceOf<AssertionError>()),
);
} else {
builder.addPicture(Offset.zero, picture);
Expand Down Expand Up @@ -105,7 +105,7 @@ void main() {
assert(() {
expect(
() => builder.pushTransform(matrix4WrongLength),
expectAssertion,
throwsA(isA<AssertionError>()),
);
return true;
}());
Expand All @@ -119,7 +119,7 @@ void main() {
assert(() {
expect(
() => builder.pushTransform(matrix4NaN),
expectAssertion,
throwsA(isA<AssertionError>()),
);
return true;
}());
Expand All @@ -133,7 +133,7 @@ void main() {
assert(() {
expect(
() => builder.pushTransform(matrix4Infinity),
expectAssertion,
throwsA(isA<AssertionError>()),
);
return true;
}());
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/dart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'dart:async';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

/// Verifies Dart semantics governed by flags set by Flutter tooling.
void main() {
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/encoding_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

import 'impeller_enabled.dart';

Expand Down
14 changes: 7 additions & 7 deletions testing/dart/geometry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'dart:math' as math show sqrt;
import 'dart:math' show pi;
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('OffsetBase.>=', () {
Expand Down Expand Up @@ -47,8 +47,8 @@ void main() {

test('OffsetBase.==', () {
expect(const Offset(0, 0), equals(const Offset(0, 0)));
expect(const Offset(0, 0), notEquals(const Offset(1, 0)));
expect(const Offset(0, 0), notEquals(const Offset(0, 1)));
expect(const Offset(0, 0), isNot(const Offset(1, 0)));
expect(const Offset(0, 0), isNot(const Offset(0, 1)));
});

test('Offset.direction', () {
Expand Down Expand Up @@ -392,28 +392,28 @@ void main() {
const Rect.fromLTRB(10.0, 20.0, 30.0, 40.0),
topLeft: const Radius.circular(-1),
);
}, throwsA(isInstanceOf<AssertionError>()));
}, throwsA(const isInstanceOf<AssertionError>()));

expect(() {
RRect.fromRectAndCorners(
const Rect.fromLTRB(10.0, 20.0, 30.0, 40.0),
topRight: const Radius.circular(-2),
);
}, throwsA(isInstanceOf<AssertionError>()));
}, throwsA(const isInstanceOf<AssertionError>()));

expect(() {
RRect.fromRectAndCorners(
const Rect.fromLTRB(10.0, 20.0, 30.0, 40.0),
bottomLeft: const Radius.circular(-3),
);
}, throwsA(isInstanceOf<AssertionError>()));
}, throwsA(const isInstanceOf<AssertionError>()));

expect(() {
RRect.fromRectAndCorners(
const Rect.fromLTRB(10.0, 20.0, 30.0, 40.0),
bottomRight: const Radius.circular(-4),
);
}, throwsA(isInstanceOf<AssertionError>()));
}, throwsA(const isInstanceOf<AssertionError>()));
});

test('RRect.inflate clamps when deflating past zero', () {
Expand Down
10 changes: 5 additions & 5 deletions testing/dart/gesture_settings_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('GestureSettings has a reasonable toString', () {
Expand All @@ -23,11 +23,11 @@ void main() {
expect(settingsA, equals(settingsC));
expect(settingsC, equals(settingsA));

expect(settingsA, notEquals(settingsB));
expect(settingsC, notEquals(settingsB));
expect(settingsA, isNot(settingsB));
expect(settingsC, isNot(settingsB));

expect(settingsB, notEquals(settingsA));
expect(settingsB, notEquals(settingsC));
expect(settingsB, isNot(settingsA));
expect(settingsB, isNot(settingsC));
});

test('GestureSettings copyWith preserves already set values', () {
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/gpu_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

import '../../lib/gpu/lib/gpu.dart' as gpu;
import 'impeller_enabled.dart';
Expand Down
4 changes: 2 additions & 2 deletions testing/dart/gradient_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('Gradient.radial with no focal point', () {
Expand Down Expand Up @@ -64,7 +64,7 @@ void main() {
Offset.zero,
1.0,
),
expectAssertion,
throwsA(isA<AssertionError>()),
);
return true;
}());
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/http_allow_http_connections_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:async';
import 'dart:io';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

import 'http_disallow_http_connections_test.dart';

Expand Down
2 changes: 1 addition & 1 deletion testing/dart/http_disallow_http_connections_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import 'dart:async';
import 'dart:io';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

typedef FutureFunction = Future<Object?> Function();

Expand Down
2 changes: 1 addition & 1 deletion testing/dart/image_descriptor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

void main() {
test('basic image descriptor - encoded - greyscale', () async {
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/image_dispose_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

void main() {
bool assertsEnabled = false;
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/image_events_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:async';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('Image constructor and dispose invokes onCreate once', () async {
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/image_resize_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

void main() {
bool assertsEnabled = false;
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/image_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:async';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('toImage succeeds', () async {
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/isolate_name_server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:async';
import 'dart:isolate';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

const int kErrorCode = -1;
const int kStartCode = 0;
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/isolate_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:isolate';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('Invalid isolate URI', () async {
Expand Down
22 changes: 12 additions & 10 deletions testing/dart/lerp_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

const precisionErrorTolerance = 1e-4;

// These tests should be kept in sync with the web tests in
// lib/web_ui/test/lerp_test.dart.
Expand Down Expand Up @@ -103,23 +105,23 @@ void main() {
});

test('lerpDouble should throw AssertionError if interpolation value is NaN and a != b', () {
expectAssertion(() => lerpDouble(0.0, 10.0, double.nan));
expect(() => lerpDouble(0.0, 10.0, double.nan), throwsA(isA<AssertionError>()));
});

test('lerpDouble should throw AssertionError if interpolation value is +/- infinity and a != b', () {
expectAssertion(() => lerpDouble(0.0, 10.0, double.infinity));
expectAssertion(() => lerpDouble(0.0, 10.0, -double.infinity));
expect(() => lerpDouble(0.0, 10.0, double.infinity), throwsA(isA<AssertionError>()));
expect(() => lerpDouble(0.0, 10.0, -double.infinity), throwsA(isA<AssertionError>()));
});

test('lerpDouble should throw AssertionError if either start or end are NaN', () {
expectAssertion(() => lerpDouble(double.nan, 10.0, 5.0));
expectAssertion(() => lerpDouble(0.0, double.nan, 5.0));
expect(() => lerpDouble(double.nan, 10.0, 5.0), throwsA(isA<AssertionError>()));
expect(() => lerpDouble(0.0, double.nan, 5.0), throwsA(isA<AssertionError>()));
});

test('lerpDouble should throw AssertionError if either start or end are +/- infinity', () {
expectAssertion(() => lerpDouble(double.infinity, 10.0, 5.0));
expectAssertion(() => lerpDouble(-double.infinity, 10.0, 5.0));
expectAssertion(() => lerpDouble(0.0, double.infinity, 5.0));
expectAssertion(() => lerpDouble(0.0, -double.infinity, 5.0));
expect(() => lerpDouble(double.infinity, 10.0, 5.0), throwsA(isA<AssertionError>()));
expect(() => lerpDouble(-double.infinity, 10.0, 5.0), throwsA(isA<AssertionError>()));
expect(() => lerpDouble(0.0, double.infinity, 5.0), throwsA(isA<AssertionError>()));
expect(() => lerpDouble(0.0, -double.infinity, 5.0), throwsA(isA<AssertionError>()));
});
}
14 changes: 7 additions & 7 deletions testing/dart/locale_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('Locale', () {
Expand Down Expand Up @@ -45,19 +45,19 @@ void main() {

test('Locale equality', () {
expect(const Locale.fromSubtags(languageCode: 'en'),
notEquals(const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn')));
isNot(const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn')));
expect(const Locale.fromSubtags(languageCode: 'en').hashCode,
notEquals(const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn').hashCode));
isNot(const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn').hashCode));

expect(const Locale('en', ''), const Locale('en'));
expect(const Locale('en'), const Locale('en', ''));
expect(const Locale('en'), const Locale('en'));
expect(const Locale('en', ''), const Locale('en', ''));

expect(const Locale('en', ''), notEquals(const Locale('en', 'GB')));
expect(const Locale('en'), notEquals(const Locale('en', 'GB')));
expect(const Locale('en', 'GB'), notEquals(const Locale('en', '')));
expect(const Locale('en', 'GB'), notEquals(const Locale('en')));
expect(const Locale('en', ''), isNot(const Locale('en', 'GB')));
expect(const Locale('en'), isNot(const Locale('en', 'GB')));
expect(const Locale('en', 'GB'), isNot(const Locale('en', '')));
expect(const Locale('en', 'GB'), isNot(const Locale('en')));
});

test("Locale toString does not include separator for ''", () {
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/mask_filter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('MaskFilter - NOP blur does not crash', () async {
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/painting_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';
import 'package:vector_math/vector_math_64.dart';

typedef CanvasCallback = void Function(Canvas canvas);
Expand Down
Loading

0 comments on commit b18adaf

Please sign in to comment.