Unverified Commit dcfd35f8 authored by Nate Bosch's avatar Nate Bosch Committed by GitHub

Remove uses of deprecated test_api imports (#124732)

Most of these imports were never appropriate. The `test_api` package was never intended for use in `_test.dart` files.
Where possible move imports to `matcher`, otherwise move them to `test` or `flutter_test`.

Leave uses of `test_api` from `flutter_test` library code.
parent 55825f16
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
import 'package:flutter_gallery/demo/calculator/logic.dart'; import 'package:flutter_gallery/demo/calculator/logic.dart';
// ignore: deprecated_member_use import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
test('Test order of operations: 12 + 3 * 4 = 24', () { test('Test order of operations: 12 + 3 * 4 = 24', () {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
test('Trivial test', () { test('Trivial test', () {
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// ignore: deprecated_member_use import 'package:flutter_test/flutter_test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import '../../../raw/canvas.dart' as demo; import '../../../raw/canvas.dart' as demo;
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// ignore: deprecated_member_use import 'package:flutter_test/flutter_test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import '../../../raw/hello_world.dart' as demo; import '../../../raw/hello_world.dart' as demo;
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// ignore: deprecated_member_use import 'package:flutter_test/flutter_test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import '../../../raw/spinning_square.dart' as demo; import '../../../raw/spinning_square.dart' as demo;
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// ignore: deprecated_member_use import 'package:flutter_test/flutter_test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import '../../../raw/text.dart' as demo; import '../../../raw/text.dart' as demo;
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// ignore: deprecated_member_use import 'package:flutter_test/flutter_test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import '../../../raw/touch_input.dart' as demo; import '../../../raw/touch_input.dart' as demo;
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
// ignore: deprecated_member_use import 'package:flutter_test/flutter_test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import '../../../rendering/custom_coordinate_systems.dart' as demo; import '../../../rendering/custom_coordinate_systems.dart' as demo;
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
// ignore: deprecated_member_use import 'package:flutter_test/flutter_test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import '../../../rendering/flex_layout.dart' as demo; import '../../../rendering/flex_layout.dart' as demo;
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
// ignore: deprecated_member_use import 'package:flutter_test/flutter_test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import '../../../rendering/hello_world.dart' as demo; import '../../../rendering/hello_world.dart' as demo;
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
// ignore: deprecated_member_use import 'package:flutter_test/flutter_test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import '../../../rendering/spinning_square.dart' as demo; import '../../../rendering/spinning_square.dart' as demo;
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
// ignore: deprecated_member_use import 'package:flutter_test/flutter_test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import '../../../rendering/touch_input.dart' as demo; import '../../../rendering/touch_input.dart' as demo;
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter_driver/src/common/error.dart'; import 'package:flutter_driver/src/common/error.dart';
import 'package:test_api/test_api.dart'; // ignore: deprecated_member_use import 'package:test/test.dart';
export 'package:test_api/fake.dart'; // ignore: deprecated_member_use export 'package:test/fake.dart';
export 'package:test_api/test_api.dart'; // ignore: deprecated_member_use export 'package:test/test.dart';
void tryToDelete(Directory directory) { void tryToDelete(Directory directory) {
// This should not be necessary, but it turns out that // This should not be necessary, but it turns out that
......
...@@ -8,8 +8,8 @@ import 'dart:math' as math; ...@@ -8,8 +8,8 @@ import 'dart:math' as math;
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:matcher/expect.dart' show fail;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:test_api/expect.dart' show fail;
import 'goldens.dart'; import 'goldens.dart';
import 'test_async_utils.dart'; import 'test_async_utils.dart';
......
...@@ -6,7 +6,7 @@ import 'dart:convert'; ...@@ -6,7 +6,7 @@ import 'dart:convert';
import 'dart:html' as html; import 'dart:html' as html;
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:test_api/expect.dart' show fail; import 'package:matcher/expect.dart' show fail;
import 'goldens.dart'; import 'goldens.dart';
......
...@@ -7,8 +7,9 @@ import 'dart:ui' as ui; ...@@ -7,8 +7,9 @@ import 'dart:ui' as ui;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:test_api/src/expect/async_matcher.dart'; // ignore: implementation_imports import 'package:matcher/expect.dart';
import 'package:test_api/test_api.dart'; // ignore: deprecated_member_use import 'package:matcher/src/expect/async_matcher.dart'; // ignore: implementation_imports
import 'package:test_api/hooks.dart' show TestFailure;
import 'binding.dart'; import 'binding.dart';
import 'finders.dart'; import 'finders.dart';
......
...@@ -6,8 +6,9 @@ import 'dart:ui' as ui; ...@@ -6,8 +6,9 @@ import 'dart:ui' as ui;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:test_api/src/expect/async_matcher.dart'; // ignore: implementation_imports import 'package:matcher/expect.dart';
import 'package:test_api/test_api.dart'; // ignore: deprecated_member_use import 'package:matcher/src/expect/async_matcher.dart'; // ignore: implementation_imports
import 'package:test_api/hooks.dart' show TestFailure;
import 'binding.dart'; import 'binding.dart';
import 'finders.dart'; import 'finders.dart';
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:test_api/src/expect/async_matcher.dart'; // ignore: implementation_imports import 'package:matcher/src/expect/async_matcher.dart'; // ignore: implementation_imports
// ignore: deprecated_member_use // ignore: deprecated_member_use
import 'package:test_api/test_api.dart' show Description, TestFailure; import 'package:test_api/test_api.dart' show Description, TestFailure;
......
...@@ -10,10 +10,8 @@ import 'package:flutter/material.dart' show Card; ...@@ -10,10 +10,8 @@ import 'package:flutter/material.dart' show Card;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:test_api/src/expect/async_matcher.dart'; // ignore: implementation_imports import 'package:matcher/expect.dart';
// This import is discouraged in general, but we need it to implement flutter_test. import 'package:matcher/src/expect/async_matcher.dart'; // ignore: implementation_imports
// ignore: deprecated_member_use
import 'package:test_api/test_api.dart';
import '_matchers_io.dart' if (dart.library.html) '_matchers_web.dart' show MatchesGoldenFile, captureImage; import '_matchers_io.dart' if (dart.library.html) '_matchers_web.dart' show MatchesGoldenFile, captureImage;
import 'accessibility.dart'; import 'accessibility.dart';
......
...@@ -9,6 +9,7 @@ import 'package:flutter/material.dart' show Tooltip; ...@@ -9,6 +9,7 @@ import 'package:flutter/material.dart' show Tooltip;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:matcher/expect.dart' as matcher_expect;
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
// The test_api package is not for general use... it's literally for our use. // The test_api package is not for general use... it's literally for our use.
...@@ -28,7 +29,14 @@ import 'test_text_input.dart'; ...@@ -28,7 +29,14 @@ import 'test_text_input.dart';
// Keep users from needing multiple imports to test semantics. // Keep users from needing multiple imports to test semantics.
export 'package:flutter/rendering.dart' show SemanticsHandle; export 'package:flutter/rendering.dart' show SemanticsHandle;
// We re-export the matcher package minus some features that we reimplement.
//
// - expect is reimplemented below, to catch incorrect async usage.
//
// - isInstanceOf is reimplemented in matchers.dart because we don't want to
// mark it as deprecated (ours is just a method, not a class).
//
export 'package:matcher/expect.dart' hide expect, isInstanceOf;
// We re-export the test package minus some features that we reimplement. // We re-export the test package minus some features that we reimplement.
// //
// Specifically: // Specifically:
...@@ -38,23 +46,14 @@ export 'package:flutter/rendering.dart' show SemanticsHandle; ...@@ -38,23 +46,14 @@ export 'package:flutter/rendering.dart' show SemanticsHandle;
// setting up a declarer when one is not defined, which can happen when a // setting up a declarer when one is not defined, which can happen when a
// test is executed via `flutter run`. // test is executed via `flutter run`.
// //
// - expect is reimplemented below, to catch incorrect async usage.
//
// - isInstanceOf is reimplemented in matchers.dart because we don't want to
// mark it as deprecated (ours is just a method, not a class).
//
// The test_api package has a deprecation warning to discourage direct use but // The test_api package has a deprecation warning to discourage direct use but
// that doesn't apply here. // that doesn't apply here.
export 'package:test_api/hooks.dart' show TestFailure;
// ignore: deprecated_member_use // ignore: deprecated_member_use
export 'package:test_api/test_api.dart' hide export 'package:test_api/scaffolding.dart'
expect, hide group, setUp, setUpAll, tearDown, tearDownAll, test;
group, // ignore: implementation_imports
isInstanceOf, export 'package:test_api/src/scaffolding/utils.dart' show registerException;
setUp,
setUpAll,
tearDown,
tearDownAll,
test;
/// Signature for callback to [testWidgets] and [benchmarkWidgets]. /// Signature for callback to [testWidgets] and [benchmarkWidgets].
typedef WidgetTesterCallback = Future<void> Function(WidgetTester widgetTester); typedef WidgetTesterCallback = Future<void> Function(WidgetTester widgetTester);
...@@ -442,7 +441,7 @@ Future<void> benchmarkWidgets( ...@@ -442,7 +441,7 @@ Future<void> benchmarkWidgets(
/// Assert that `actual` matches `matcher`. /// Assert that `actual` matches `matcher`.
/// ///
/// See [test_package.expect] for details. This is a variant of that function /// See [matcher_expect.expect] for details. This is a variant of that function
/// that additionally verifies that there are no asynchronous APIs /// that additionally verifies that there are no asynchronous APIs
/// that have not yet resolved. /// that have not yet resolved.
/// ///
...@@ -456,12 +455,12 @@ void expect( ...@@ -456,12 +455,12 @@ void expect(
dynamic skip, // true or a String dynamic skip, // true or a String
}) { }) {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
test_package.expect(actual, matcher, reason: reason, skip: skip); matcher_expect.expect(actual, matcher, reason: reason, skip: skip);
} }
/// Assert that `actual` matches `matcher`. /// Assert that `actual` matches `matcher`.
/// ///
/// See [test_package.expect] for details. This variant will _not_ check that /// See [matcher_expect.expect] for details. This variant will _not_ check that
/// there are no outstanding asynchronous API requests. As such, it can be /// there are no outstanding asynchronous API requests. As such, it can be
/// called from, e.g., callbacks that are run during build or layout, or in the /// called from, e.g., callbacks that are run during build or layout, or in the
/// completion handlers of futures that execute in response to user input. /// completion handlers of futures that execute in response to user input.
...@@ -473,13 +472,13 @@ void expectSync( ...@@ -473,13 +472,13 @@ void expectSync(
dynamic matcher, { dynamic matcher, {
String? reason, String? reason,
}) { }) {
test_package.expect(actual, matcher, reason: reason); matcher_expect.expect(actual, matcher, reason: reason);
} }
/// Just like [expect], but returns a [Future] that completes when the matcher /// Just like [expect], but returns a [Future] that completes when the matcher
/// has finished matching. /// has finished matching.
/// ///
/// See [test_package.expectLater] for details. /// See [matcher_expect.expectLater] for details.
/// ///
/// If the matcher fails asynchronously, that failure is piped to the returned /// If the matcher fails asynchronously, that failure is piped to the returned
/// future where it can be handled by user code. If it is not handled by user /// future where it can be handled by user code. If it is not handled by user
...@@ -493,7 +492,7 @@ Future<void> expectLater( ...@@ -493,7 +492,7 @@ Future<void> expectLater(
// We can't wrap the delegate in a guard, or we'll hit async barriers in // We can't wrap the delegate in a guard, or we'll hit async barriers in
// [TestWidgetsFlutterBinding] while we're waiting for the matcher to complete // [TestWidgetsFlutterBinding] while we're waiting for the matcher to complete
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
return test_package.expectLater(actual, matcher, reason: reason, skip: skip) return matcher_expect.expectLater(actual, matcher, reason: reason, skip: skip)
.then<void>((dynamic value) => null); .then<void>((dynamic value) => null);
} }
......
...@@ -16,9 +16,6 @@ import 'package:flutter/services.dart'; ...@@ -16,9 +16,6 @@ import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
// ignore: deprecated_member_use
import 'package:test_api/test_api.dart' as test_package;
void main() { void main() {
final AutomatedTestWidgetsFlutterBinding binding = AutomatedTestWidgetsFlutterBinding(); final AutomatedTestWidgetsFlutterBinding binding = AutomatedTestWidgetsFlutterBinding();
...@@ -31,7 +28,7 @@ void main() { ...@@ -31,7 +28,7 @@ void main() {
group(AutomatedTestWidgetsFlutterBinding, () { group(AutomatedTestWidgetsFlutterBinding, () {
test('allows setting defaultTestTimeout to 5 minutes', () { test('allows setting defaultTestTimeout to 5 minutes', () {
binding.defaultTestTimeout = const test_package.Timeout(Duration(minutes: 5)); binding.defaultTestTimeout = const Timeout(Duration(minutes: 5));
expect(binding.defaultTestTimeout.duration, const Duration(minutes: 5)); expect(binding.defaultTestTimeout.duration, const Duration(minutes: 5));
}); });
}); });
......
...@@ -13,9 +13,8 @@ import 'package:flutter/rendering.dart'; ...@@ -13,9 +13,8 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:test_api/src/expect/async_matcher.dart'; // ignore: implementation_imports import 'package:matcher/expect.dart' as matcher;
// ignore: deprecated_member_use import 'package:matcher/src/expect/async_matcher.dart'; // ignore: implementation_imports
import 'package:test_api/test_api.dart' as test_package;
const List<Widget> fooBarTexts = <Text>[ const List<Widget> fooBarTexts = <Text>[
Text('foo', textDirection: TextDirection.ltr), Text('foo', textDirection: TextDirection.ltr),
...@@ -31,12 +30,12 @@ void main() { ...@@ -31,12 +30,12 @@ void main() {
future.then<void>((void value) { future.then<void>((void value) {
result = '123'; result = '123';
}); });
test_package.expect(result, isNull); matcher.expect(result, isNull);
completer.complete(); completer.complete();
test_package.expect(result, isNull); matcher.expect(result, isNull);
await future; await future;
await tester.pump(); await tester.pump();
test_package.expect(result, '123'); matcher.expect(result, '123');
}); });
testWidgets('respects the skip flag', (WidgetTester tester) async { testWidgets('respects the skip flag', (WidgetTester tester) async {
...@@ -46,9 +45,9 @@ void main() { ...@@ -46,9 +45,9 @@ void main() {
future.then<void>((_) { future.then<void>((_) {
completed = true; completed = true;
}); });
test_package.expect(completed, isFalse); matcher.expect(completed, isFalse);
await future; await future;
test_package.expect(completed, isTrue); matcher.expect(completed, isTrue);
}); });
}); });
......
...@@ -14,10 +14,10 @@ import 'package:flutter_tools/src/base/platform.dart'; ...@@ -14,10 +14,10 @@ import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:path/path.dart' as path; // flutter_ignore: package_path_import import 'package:path/path.dart' as path; // flutter_ignore: package_path_import
import 'package:test_api/test_api.dart' as test_package show test; // ignore: deprecated_member_use import 'package:test/test.dart' as test_package show test;
import 'package:test_api/test_api.dart' hide test; // ignore: deprecated_member_use import 'package:test/test.dart' hide test;
export 'package:test_api/test_api.dart' hide isInstanceOf, test; // ignore: deprecated_member_use export 'package:test/test.dart' hide isInstanceOf, test;
void tryToDelete(FileSystemEntity fileEntity) { void tryToDelete(FileSystemEntity fileEntity) {
// This should not be necessary, but it turns out that // This should not be necessary, but it turns out that
......
...@@ -6,10 +6,10 @@ import 'dart:async'; ...@@ -6,10 +6,10 @@ import 'dart:async';
import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/vmservice.dart'; import 'package:flutter_tools/src/vmservice.dart';
import 'package:test_api/test_api.dart' hide test; // ignore: deprecated_member_use import 'package:test/test.dart' hide test;
import 'package:vm_service/vm_service.dart' as vm_service; import 'package:vm_service/vm_service.dart' as vm_service;
export 'package:test_api/test_api.dart' hide isInstanceOf, test; // ignore: deprecated_member_use export 'package:test/test.dart' hide isInstanceOf, test;
/// A fake implementation of a vm_service that mocks the JSON-RPC request /// A fake implementation of a vm_service that mocks the JSON-RPC request
/// and response structure. /// and response structure.
......
...@@ -16,7 +16,7 @@ import 'package:flutter_tools/src/globals.dart' as globals; ...@@ -16,7 +16,7 @@ import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/runner/flutter_command.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart'; import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
export 'package:test_api/test_api.dart' hide isInstanceOf, test; // ignore: deprecated_member_use export 'package:test/test.dart' hide isInstanceOf, test;
CommandRunner<void> createTestCommandRunner([ FlutterCommand? command ]) { CommandRunner<void> createTestCommandRunner([ FlutterCommand? command ]) {
final FlutterCommandRunner runner = TestFlutterCommandRunner(); final FlutterCommandRunner runner = TestFlutterCommandRunner();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment