mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[ Device Lab ] Add regression testing for flutter/flutter#174952 (#174956)
Also switches to using a regex group to match the device state instead of splitting the matched string on '='. Fixes https://github.com/flutter/flutter/issues/174952 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
parent
dbc119c5f5
commit
87d5b75319
@ -685,9 +685,10 @@ class AndroidDevice extends Device {
|
||||
final String powerInfo = await shellEval('dumpsys', <String>['power']);
|
||||
// A motoG4 phone returns `mWakefulness=Awake`.
|
||||
// A Samsung phone returns `getWakefullnessLocked()=Awake`.
|
||||
final RegExp wakefulnessRegexp = RegExp(r'(?:mWakefulness|getWakefulnessLocked\(\))=[a-zA-Z]+');
|
||||
final String wakefulness = grep(wakefulnessRegexp, from: powerInfo).single.split('=')[1].trim();
|
||||
return wakefulness;
|
||||
final RegExp wakefulnessRegexp = RegExp(
|
||||
r'(?:mWakefulness|getWakefulnessLocked\(\))=\s*([a-zA-Z]+)',
|
||||
);
|
||||
return wakefulnessRegexp.allMatches(powerInfo).single.group(1)!;
|
||||
}
|
||||
|
||||
Future<bool> isArm64() async {
|
||||
|
||||
@ -23,7 +23,9 @@ void main() {
|
||||
device = FakeDevice(deviceId: 'fakeDeviceId');
|
||||
});
|
||||
|
||||
tearDown(() {});
|
||||
tearDown(() {
|
||||
FakeDevice.resetLog();
|
||||
});
|
||||
|
||||
group('cpu check', () {
|
||||
test('arm64', () async {
|
||||
@ -325,20 +327,38 @@ class FakeDevice extends AndroidDevice {
|
||||
}
|
||||
|
||||
static void pretendAwake() {
|
||||
// Emit an integer value in addition to the state string to ensure only
|
||||
// the state string is matched.
|
||||
//
|
||||
// Regression testing for https://github.com/flutter/flutter/issues/174952.
|
||||
output = '''
|
||||
mWakefulness=1
|
||||
mWakefulness=Awake
|
||||
|
||||
''';
|
||||
}
|
||||
|
||||
static void pretendAwakeSamsung() {
|
||||
// Emit an integer value in addition to the state string to ensure only
|
||||
// the state string is matched.
|
||||
//
|
||||
// Regression testing for https://github.com/flutter/flutter/issues/174952.
|
||||
output = '''
|
||||
getWakefulnessLocked()=1
|
||||
getWakefulnessLocked()=Awake
|
||||
|
||||
''';
|
||||
}
|
||||
|
||||
static void pretendAsleep() {
|
||||
// Emit an integer value in addition to the state string to ensure only
|
||||
// the state string is matched.
|
||||
//
|
||||
// Regression testing for https://github.com/flutter/flutter/issues/174952.
|
||||
output = '''
|
||||
mWakefulness=0
|
||||
mWakefulness=Asleep
|
||||
|
||||
''';
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user