Unverified Commit 7042481d authored by Chris Yang's avatar Chris Yang Committed by GitHub

fix test (#54403)

parent c16c3b04
...@@ -52,21 +52,27 @@ public class SimplePlatformView implements PlatformView, MethodChannel.MethodCal ...@@ -52,21 +52,27 @@ public class SimplePlatformView implements PlatformView, MethodChannel.MethodCal
touchPipe.disable(); touchPipe.disable();
result.success(null); result.success(null);
return; return;
case "showAlertDialog": case "showAndHideAlertDialog":
showAlertDialog(result); showAndHideAlertDialog(result);
return; return;
} }
result.notImplemented(); result.notImplemented();
} }
private void showAlertDialog(MethodChannel.Result result) { private void showAndHideAlertDialog(MethodChannel.Result result) {
Context context = view.getContext(); Context context = view.getContext();
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
TextView textView = new TextView(context); TextView textView = new TextView(context);
textView.setText("Alert!"); textView.setText("This alert dialog will close in 1 second");
builder.setView(textView); builder.setView(textView);
final AlertDialog alertDialog = builder.show(); final AlertDialog alertDialog = builder.show();
result.success(null); result.success(null);
view.postDelayed(new Runnable() {
@Override
public void run() {
alertDialog.hide();
}
}, 1000);
} }
} }
...@@ -79,31 +79,46 @@ class MotionEventsBodyState extends State<MotionEventsBody> { ...@@ -79,31 +79,46 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
), ),
Row( Row(
children: <Widget>[ children: <Widget>[
RaisedButton( Expanded(
child: const Text('RECORD'), child: RaisedButton(
onPressed: listenToFlutterViewEvents, child: const Text('RECORD'),
onPressed: listenToFlutterViewEvents,
),
), ),
RaisedButton( Expanded(
child: const Text('CLEAR'), child: RaisedButton(
onPressed: () { child: const Text('CLEAR'),
setState(() { onPressed: () {
flutterViewEvents.clear(); setState(() {
embeddedViewEvents.clear(); flutterViewEvents.clear();
}); embeddedViewEvents.clear();
}, });
},
),
), ),
RaisedButton( Expanded(
child: const Text('SAVE'), child: RaisedButton(
onPressed: () { child: const Text('SAVE'),
const StandardMessageCodec codec = StandardMessageCodec(); onPressed: () {
saveRecordedEvents( const StandardMessageCodec codec = StandardMessageCodec();
saveRecordedEvents(
codec.encodeMessage(flutterViewEvents), context); codec.encodeMessage(flutterViewEvents), context);
}, },
),
), ),
RaisedButton( Expanded(
key: const ValueKey<String>('play'), child: RaisedButton(
child: const Text('PLAY FILE'), key: const ValueKey<String>('play'),
onPressed: () { playEventsFile(); }, child: const Text('PLAY FILE'),
onPressed: () { playEventsFile(); },
),
),
Expanded(
child: RaisedButton(
key: const ValueKey<String>('back'),
child: const Text('BACK'),
onPressed: () { Navigator.pop(context); },
),
), ),
], ],
), ),
......
...@@ -84,7 +84,7 @@ class WindowManagerBodyState extends State<WindowManagerBody> { ...@@ -84,7 +84,7 @@ class WindowManagerBodyState extends State<WindowManagerBody> {
}); });
} }
try { try {
await viewChannel.invokeMethod<void>('showAlertDialog'); await viewChannel.invokeMethod<void>('showAndHideAlertDialog');
setState(() { setState(() {
lastTestStatus = _LastTestStatus.success; lastTestStatus = _LastTestStatus.success;
}); });
......
...@@ -17,6 +17,8 @@ Future<void> main() async { ...@@ -17,6 +17,8 @@ Future<void> main() async {
driver.close(); driver.close();
}); });
// Each test below must return back to the home page after finishing.
test('MotionEvent recomposition', () async { test('MotionEvent recomposition', () async {
final SerializableFinder motionEventsListTile = final SerializableFinder motionEventsListTile =
find.byValueKey('MotionEventsListTile'); find.byValueKey('MotionEventsListTile');
...@@ -24,9 +26,9 @@ Future<void> main() async { ...@@ -24,9 +26,9 @@ Future<void> main() async {
await driver.waitFor(find.byValueKey('PlatformView')); await driver.waitFor(find.byValueKey('PlatformView'));
final String errorMessage = await driver.requestData('run test'); final String errorMessage = await driver.requestData('run test');
expect(errorMessage, ''); expect(errorMessage, '');
}, final SerializableFinder backButton = find.byValueKey('back');
// TODO(amirh): enable this test https://github.com/flutter/flutter/issues/54022 await driver.tap(backButton);
skip: true); });
test('AlertDialog from platform view context', () async { test('AlertDialog from platform view context', () async {
final SerializableFinder wmListTile = final SerializableFinder wmListTile =
...@@ -38,5 +40,7 @@ Future<void> main() async { ...@@ -38,5 +40,7 @@ Future<void> main() async {
await driver.tap(showAlertDialog); await driver.tap(showAlertDialog);
final String status = await driver.getText(find.byValueKey('Status')); final String status = await driver.getText(find.byValueKey('Status'));
expect(status, 'Success'); expect(status, 'Success');
await driver.waitFor(find.pageBack());
await driver.tap(find.pageBack());
}); });
} }
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