Unverified Commit e6971136 authored by godofredoc's avatar godofredoc Committed by GitHub

Adds a home method to device classes. (#95103)

parent 70fea6d2
......@@ -124,6 +124,9 @@ abstract class Device {
/// Send the device to sleep mode.
Future<void> sendToSleep();
/// Emulates pressing the home button.
Future<void> home();
/// Emulates pressing the power button, toggling the device's on/off state.
Future<void> togglePower();
......@@ -470,6 +473,12 @@ class AndroidDevice extends Device {
await togglePower();
}
/// Sends `KEYCODE_HOME` (3), which causes the device to go to the home screen.
@override
Future<void> home() async {
await shellExec('input', const <String>['keyevent', '3']);
}
/// Sends `KEYCODE_POWER` (26), which causes the device to toggle its mode
/// between awake and asleep.
@override
......@@ -895,6 +904,9 @@ class IosDevice extends Device {
@override
Future<void> sendToSleep() async {}
@override
Future<void> home() async {}
@override
Future<void> togglePower() async {}
......@@ -945,6 +957,9 @@ class FuchsiaDevice extends Device {
@override
Future<void> sendToSleep() async {}
@override
Future<void> home() async {}
@override
Future<void> togglePower() async {}
......@@ -1011,6 +1026,9 @@ class FakeDevice extends Device {
@override
Future<void> sendToSleep() async {}
@override
Future<void> home() async {}
@override
Future<void> togglePower() async {}
......
......@@ -144,6 +144,10 @@ class _TaskRunner {
}
final Device? device = await _getWorkingDeviceIfAvailable();
// Some tests assume the phone is in home
await device?.home();
late TaskResult result;
IOSink? sink;
try {
......
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