From ceb24b2c090bf4df6d68ea7623122d8b31adee52 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Fri, 24 Jan 2025 00:11:29 -0800 Subject: [PATCH] tweak the naming --- lib/helpers.js | 5 +++-- lib/tools/lockmgmt.js | 4 ++-- test/unit/helper-specs.js | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/helpers.js b/lib/helpers.js index 0f5e56e9..2159c80b 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -278,7 +278,7 @@ export async function getApkanalyzerForOs (sysHelpers) { * @param {string} dumpsys - The output of dumpsys window command. * @return {boolean} True if lock screen is showing. */ -export function isScreenOff(dumpsys) { +export function isScreenStateOff(dumpsys) { return /\s+screenState=SCREEN_STATE_OFF/i.test(dumpsys); } @@ -334,7 +334,8 @@ export function getSurfaceOrientation (dumpsys) { /* * Checks mScreenOnFully in dumpsys output to determine if screen is showing - * Default is true + * Default is true. + * Note: this key */ export function isScreenOnFully (dumpsys) { let m = /mScreenOnFully=\w+/gi.exec(dumpsys); diff --git a/lib/tools/lockmgmt.js b/lib/tools/lockmgmt.js index ec29f41d..af944227 100644 --- a/lib/tools/lockmgmt.js +++ b/lib/tools/lockmgmt.js @@ -2,7 +2,7 @@ import { log } from '../logger.js'; import _ from 'lodash'; import { isShowingLockscreen, isCurrentFocusOnKeyguard, isScreenOnFully, - isInDozingMode, isScreenOff, + isInDozingMode, isScreenStateOff, } from '../helpers.js'; import B from 'bluebird'; import { waitForCondition } from 'asyncbox'; @@ -218,7 +218,7 @@ export async function isScreenLocked () { || isCurrentFocusOnKeyguard(windowOutput) || !isScreenOnFully(windowOutput) || isInDozingMode(powerOutput) - || isScreenOff(windowOutput); + || isScreenStateOff(windowOutput); } /** diff --git a/test/unit/helper-specs.js b/test/unit/helper-specs.js index 44b1e0ff..f26cf8f6 100644 --- a/test/unit/helper-specs.js +++ b/test/unit/helper-specs.js @@ -3,7 +3,7 @@ import { buildStartCmd, isShowingLockscreen, getBuildToolsDirs, parseAaptStrings, parseAapt2Strings, extractMatchingPermissions, parseLaunchableActivityNames, matchComponentName, - isScreenOff, + isScreenStateOff, } from '../../lib/helpers'; import { withMocks } from '@appium/test-support'; import { fs } from '@appium/support'; @@ -59,8 +59,8 @@ describe('helpers', withMocks({fs}, function (mocks) { }); }); - describe('isScreenOff', function () { - it('should return true if isScreenOff is off', async function () { + describe('isScreenStateOff', function () { + it('should return true if isScreenStateOff is off', async function () { let dumpsys = ` KeyguardServiceDelegate showing=false @@ -85,9 +85,9 @@ describe('helpers', withMocks({fs}, function (mocks) { mCurrentUserId=0 ... `; - (await isScreenOff(dumpsys)).should.be.true; + (await isScreenStateOff(dumpsys)).should.be.true; }); - it('should return true if isScreenOff is on', async function () { + it('should return true if isScreenStateOff is on', async function () { let dumpsys = ` KeyguardServiceDelegate showing=false @@ -112,7 +112,7 @@ describe('helpers', withMocks({fs}, function (mocks) { mCurrentUserId=0 ... `; - (await isScreenOff(dumpsys)).should.be.false; + (await isScreenStateOff(dumpsys)).should.be.false; }); });