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