Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dev/manual_tests/test/card_collection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ void main() {
tester.pump(); // see https://github.com/flutter/flutter/issues/1865
tester.pump(); // triggers a frame

Element navigationMenu = tester.findElement((Element element) {
Finder navigationMenu = find.byElement((Element element) {
Widget widget = element.widget;
if (widget is Tooltip)
return widget.message == 'Open navigation menu';
return false;
});

expect(navigationMenu, isNotNull);
expect(tester, hasWidget(navigationMenu));

tester.tap(navigationMenu);
tester.pump(); // start opening menu
tester.pump(const Duration(seconds: 1)); // wait til it's really opened

// smoke test for various checkboxes
tester.tap(tester.findText('Make card labels editable'));
tester.tap(find.text('Make card labels editable'));
tester.pump();
tester.tap(tester.findText('Let the sun shine'));
tester.tap(find.text('Let the sun shine'));
tester.pump();
tester.tap(tester.findText('Make card labels editable'));
tester.tap(find.text('Make card labels editable'));
tester.pump();
tester.tap(tester.findText('Vary font sizes'));
tester.tap(find.text('Vary font sizes'));
tester.pump();
});
});
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world/test/hello_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
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);
expect(tester, hasWidget(find.text('Hello, world!')));
});
});
}
16 changes: 8 additions & 8 deletions examples/material_gallery/test/smoke_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,45 @@ void main() {
tester.pump(); // triggers a frame

// Try loading Weather demo
tester.tap(tester.findText('Demos'));
tester.tap(find.text('Demos'));
tester.pump();
tester.pump(const Duration(seconds: 1)); // wait til it's really opened

tester.tap(tester.findText('Weather'));
tester.tap(find.text('Weather'));
tester.pump();
tester.pump(const Duration(seconds: 1)); // wait til it's really opened

// Go back
Element backButton = tester.findElement((Element element) {
Finder backButton = find.byElement((Element element) {
Widget widget = element.widget;
if (widget is Tooltip)
return widget.message == 'Back';
return false;
});
expect(backButton, isNotNull);
expect(tester, hasWidget(backButton));
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) {
Finder navigationMenu = find.byElement((Element element) {
Widget widget = element.widget;
if (widget is Tooltip)
return widget.message == 'Open navigation menu';
return false;
});
expect(navigationMenu, isNotNull);
expect(tester, hasWidget(navigationMenu));
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.tap(find.text('Dark'));
tester.pump();
tester.pump(const Duration(seconds: 1)); // wait til it's changed

// switch theme
tester.tap(tester.findText('Light'));
tester.tap(find.text('Light'));
tester.pump();
tester.pump(const Duration(seconds: 1)); // wait til it's changed
});
Expand Down
28 changes: 14 additions & 14 deletions examples/stocks/test/icon_color_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Element findElementOfExactWidgetTypeGoingUp(Element node, Type targetType) {

final RegExp materialIconAssetNameColorExtractor = new RegExp(r'[^/]+/ic_.+_(white|black)_[0-9]+dp\.png');

void checkIconColor(WidgetTester tester, String label, Color color) {
void checkIconColor(ElementTreeTester tester, String label, Color color) {
// The icon is going to be in the same merged semantics box as the text
// regardless of how the menu item is represented, so this is a good
// way to find the menu item. I hope.
Expand All @@ -59,11 +59,11 @@ void main() {
tester.pump(); // triggers a frame

// sanity check
expect(tester.findText('MARKET'), isNotNull);
expect(tester.findText('Help & Feedback'), isNull);
expect(tester, hasWidget(find.text('MARKET')));
expect(tester, doesNotHaveWidget(find.text('Help & Feedback')));
tester.pump(new Duration(seconds: 2));
expect(tester.findText('MARKET'), isNotNull);
expect(tester.findText('Help & Feedback'), isNull);
expect(tester, hasWidget(find.text('MARKET')));
expect(tester, doesNotHaveWidget(find.text('Help & Feedback')));

// drag the drawer out
Point left = new Point(0.0, ui.window.size.height / 2.0);
Expand All @@ -74,24 +74,24 @@ void main() {
tester.pump();
gesture.up();
tester.pump();
expect(tester.findText('MARKET'), isNotNull);
expect(tester.findText('Help & Feedback'), isNotNull);
expect(tester, hasWidget(find.text('MARKET')));
expect(tester, hasWidget(find.text('Help & Feedback')));

// check the colour of the icon - light mode
checkIconColor(tester, 'Stock List', Colors.purple[500]); // theme primary color
checkIconColor(tester, 'Account Balance', Colors.black45); // enabled
checkIconColor(tester, 'Help & Feedback', Colors.black26); // disabled
checkIconColor(tester.elementTreeTester, 'Stock List', Colors.purple[500]); // theme primary color
checkIconColor(tester.elementTreeTester, 'Account Balance', Colors.black45); // enabled
checkIconColor(tester.elementTreeTester, 'Help & Feedback', Colors.black26); // disabled

// switch to dark mode
tester.tap(tester.findText('Pessimistic'));
tester.tap(find.text('Pessimistic'));
tester.pump(); // get the tap and send the notification that the theme has changed
tester.pump(); // start the theme transition
tester.pump(const Duration(seconds: 5)); // end the transition

// check the colour of the icon - dark mode
checkIconColor(tester, 'Stock List', Colors.redAccent[200]); // theme accent color
checkIconColor(tester, 'Account Balance', Colors.white); // enabled
checkIconColor(tester, 'Help & Feedback', Colors.white30); // disabled
checkIconColor(tester.elementTreeTester, 'Stock List', Colors.redAccent[200]); // theme accent color
checkIconColor(tester.elementTreeTester, 'Account Balance', Colors.white); // enabled
checkIconColor(tester.elementTreeTester, 'Help & Feedback', Colors.white30); // disabled

});
});
Expand Down
9 changes: 3 additions & 6 deletions examples/stocks/test/locale_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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:stocks/main.dart' as stocks;
import 'package:stocks/stock_data.dart' as stock_data;
Expand All @@ -14,15 +13,13 @@ void main() {
test("Test changing locale", () {
testWidgets((WidgetTester tester) {
stocks.main();
tester.async.flushMicrotasks(); // see https://github.com/flutter/flutter/issues/1865
tester.flushMicrotasks(); // see https://github.com/flutter/flutter/issues/1865
tester.pump();

Element tab = tester.findText('MARKET');
expect(tab, isNotNull);
expect(tester, hasWidget(find.text('MARKET')));
tester.setLocale("es", "US");
tester.pump();
Text text = tab.widget;
expect(text.data, equals("MERCADO"));
expect(tester, hasWidget(find.text('MERCADO')));

// TODO(abarth): We're leaking an animation. We should track down the leak
// and plug it rather than waiting for the animation to end here.
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/benchmark/stocks/build_bench.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void main() {
tester.tapAt(new Point(20.0, 20.0)); // Open drawer
tester.pump(); // Start drawer animation
tester.pump(const Duration(seconds: 1)); // Complete drawer animation
appState = tester.findStateOfType(stocks.StocksAppState);
appState = tester.stateOf(find.byType(stocks.StocksApp));
});

WidgetFlutterBinding binding = WidgetFlutterBinding.instance;
Expand Down
8 changes: 4 additions & 4 deletions packages/flutter/test/material/slider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void main() {
);

expect(value, equals(0.0));
tester.tap(tester.findElementByKey(sliderKey));
tester.tap(find.byKey(sliderKey));
expect(value, equals(0.5));
tester.pump(); // No animation should start.
expect(Scheduler.instance.transientCallbackCount, equals(0));
Expand Down Expand Up @@ -70,11 +70,11 @@ void main() {
);

expect(value, equals(0.0));
tester.tap(tester.findElementByKey(sliderKey));
tester.tap(find.byKey(sliderKey));
expect(value, equals(50.0));
tester.scroll(tester.findElementByKey(sliderKey), const Offset(5.0, 0.0));
tester.scroll(find.byKey(sliderKey), const Offset(5.0, 0.0));
expect(value, equals(50.0));
tester.scroll(tester.findElementByKey(sliderKey), const Offset(40.0, 0.0));
tester.scroll(find.byKey(sliderKey), const Offset(40.0, 0.0));
expect(value, equals(80.0));

tester.pump(); // Starts animation.
Expand Down
Loading