Unverified Commit 42a14b58 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Compatibility pass on flutter/foundation tests for JavaScript compilation. (1) (#33349)

parent 03872b63
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@TestOn('!chrome')
import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart';
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@TestOn('!chrome')
import 'dart:async';
import 'dart:io';
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@TestOn('!chrome') // web has different stack traces
import 'dart:async';
import 'package:flutter/foundation.dart';
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@TestOn('!chrome') // isolates not supported on the web.
import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart';
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@TestOn('!chrome') // web does not support certain 64bit behavior
import 'dart:typed_data';
import 'package:flutter/foundation.dart';
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@TestOn('!chrome')
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@TestOn('!chrome') // web has different stack traces
import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart';
......
......@@ -23,6 +23,7 @@ import 'package:stack_trace/stack_trace.dart' as stack_trace;
import 'package:vector_math/vector_math_64.dart';
import 'goldens.dart';
import 'platform.dart';
import 'stack_manipulation.dart';
import 'test_async_utils.dart';
import 'test_exception_reporter.dart';
......@@ -151,7 +152,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// environment variables for a variable called `FLUTTER_TEST`.)
static WidgetsBinding ensureInitialized() {
if (WidgetsBinding.instance == null) {
if (Platform.environment.containsKey('FLUTTER_TEST')) {
if (isBrowser || Platform.environment.containsKey('FLUTTER_TEST')) {
AutomatedTestWidgetsFlutterBinding();
} else {
LiveTestWidgetsFlutterBinding();
......@@ -248,6 +249,9 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
return TestAsyncUtils.guard<void>(() async {
assert(inTest);
final Locale locale = Locale(languageCode, countryCode == '' ? null : countryCode);
if (isBrowser) {
return;
}
dispatchLocalesChanged(<Locale>[locale]);
});
}
......@@ -586,7 +590,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
runApp(Container(key: UniqueKey(), child: _preTestMessage)); // Reset the tree to a known state.
await pump();
final bool autoUpdateGoldensBeforeTest = autoUpdateGoldenFiles;
final bool autoUpdateGoldensBeforeTest = autoUpdateGoldenFiles && !isBrowser;
final TestExceptionReporter reportTestExceptionBeforeTest = reportTestException;
final ErrorWidgetBuilder errorWidgetBuilderBeforeTest = ErrorWidget.builder;
......@@ -601,7 +605,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
runApp(Container(key: UniqueKey(), child: _postTestMessage)); // Unmount any remaining widgets.
await pump();
invariantTester();
_verifyAutoUpdateGoldensUnset(autoUpdateGoldensBeforeTest);
_verifyAutoUpdateGoldensUnset(autoUpdateGoldensBeforeTest && !isBrowser);
_verifyReportTestExceptionUnset(reportTestExceptionBeforeTest);
_verifyErrorWidgetBuilderUnset(errorWidgetBuilderBeforeTest);
_verifyInvariants();
......@@ -750,6 +754,9 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
static Set<String> _allowedAssetKeys;
void _mockFlutterAssets() {
if (isBrowser) {
return;
}
if (!Platform.environment.containsKey('UNIT_TEST_ASSETS')) {
return;
}
......
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