Adds a home method to device classes. (#95103)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user