Fix dependency skew. (#3306)
...by adding tests to our examples that don't import flutter_test, which pins the relevant dependencies. Also, provide more information when complaining about leaked transient callbacks in tests. Also, make tests display full information when they have an exception, by bypassing the throttling we have for Android logging in tests. Also, make the word wrapping not wrap stack traces if they happen to be included in exception output. Also, fix a leaked transient callback in the checkbox code.
This commit is contained in:
@@ -2,3 +2,7 @@ name: hello_world
|
||||
dependencies:
|
||||
flutter:
|
||||
path: ../../packages/flutter
|
||||
dev_dependencies:
|
||||
test: any # flutter_test provides the version constraints
|
||||
flutter_test:
|
||||
path: ../../packages/flutter_test
|
||||
|
||||
19
examples/hello_world/test/hello_test.dart
Normal file
19
examples/hello_world/test/hello_test.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '../lib/main.dart' as hello_world;
|
||||
|
||||
void main() {
|
||||
test("Hello world smoke test", () {
|
||||
testWidgets((WidgetTester tester) {
|
||||
hello_world.main(); // builds the app and schedules a frame but doesn't trigger one
|
||||
tester.pump(); // triggers a frame
|
||||
|
||||
expect(tester.findText('Hello, world!'), isNotNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -2,3 +2,7 @@ name: flutter_examples_layers
|
||||
dependencies:
|
||||
flutter:
|
||||
path: ../../packages/flutter
|
||||
dev_dependencies:
|
||||
test: any # flutter_test provides the version constraints
|
||||
flutter_test:
|
||||
path: ../../packages/flutter_test
|
||||
|
||||
12
examples/layers/test/sector_test.dart
Normal file
12
examples/layers/test/sector_test.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import '../rendering/src/sector_layout.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('SectorConstraints', () {
|
||||
expect(const SectorConstraints().isTight, isFalse);
|
||||
});
|
||||
}
|
||||
@@ -11,3 +11,8 @@ dependencies:
|
||||
flutter_markdown:
|
||||
path: ../../packages/flutter_markdown
|
||||
flutter_gallery_assets: '0.0.15'
|
||||
|
||||
dev_dependencies:
|
||||
test: any # flutter_test provides the version constraints
|
||||
flutter_test:
|
||||
path: ../../packages/flutter_test
|
||||
|
||||
62
examples/material_gallery/test/smoke_test.dart
Normal file
62
examples/material_gallery/test/smoke_test.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '../lib/main.dart' as material_gallery;
|
||||
|
||||
void main() {
|
||||
test('Material Gallery app smoke test', () {
|
||||
testWidgets((WidgetTester tester) {
|
||||
material_gallery.main(); // builds the app and schedules a frame but doesn't trigger one
|
||||
tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
||||
tester.pump(); // triggers a frame
|
||||
|
||||
// Try loading Weather demo
|
||||
tester.tap(tester.findText('Demos'));
|
||||
tester.pump();
|
||||
tester.pump(const Duration(seconds: 1)); // wait til it's really opened
|
||||
|
||||
tester.tap(tester.findText('Weather'));
|
||||
tester.pump();
|
||||
tester.pump(const Duration(seconds: 1)); // wait til it's really opened
|
||||
|
||||
// Go back
|
||||
Element backButton = tester.findElement((Element element) {
|
||||
Widget widget = element.widget;
|
||||
if (widget is Tooltip)
|
||||
return widget.message == 'Back';
|
||||
return false;
|
||||
});
|
||||
expect(backButton, isNotNull);
|
||||
tester.tap(backButton);
|
||||
tester.pump(); // start going back
|
||||
tester.pump(const Duration(seconds: 1)); // wait til it's finished
|
||||
|
||||
// Open menu
|
||||
Element navigationMenu = tester.findElement((Element element) {
|
||||
Widget widget = element.widget;
|
||||
if (widget is Tooltip)
|
||||
return widget.message == 'Open navigation menu';
|
||||
return false;
|
||||
});
|
||||
expect(navigationMenu, isNotNull);
|
||||
tester.tap(navigationMenu);
|
||||
tester.pump(); // start opening menu
|
||||
tester.pump(const Duration(seconds: 1)); // wait til it's really opened
|
||||
|
||||
// switch theme
|
||||
tester.tap(tester.findText('Dark'));
|
||||
tester.pump();
|
||||
tester.pump(const Duration(seconds: 1)); // wait til it's changed
|
||||
|
||||
// switch theme
|
||||
tester.tap(tester.findText('Light'));
|
||||
tester.pump();
|
||||
tester.pump(const Duration(seconds: 1)); // wait til it's changed
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user