Skip to content

Commit

Permalink
tweak the naming
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed Jan 24, 2025
1 parent d9c0565 commit ceb24b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/tools/lockmgmt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -218,7 +218,7 @@ export async function isScreenLocked () {
|| isCurrentFocusOnKeyguard(windowOutput)
|| !isScreenOnFully(windowOutput)
|| isInDozingMode(powerOutput)
|| isScreenOff(windowOutput);
|| isScreenStateOff(windowOutput);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions test/unit/helper-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -112,7 +112,7 @@ describe('helpers', withMocks({fs}, function (mocks) {
mCurrentUserId=0
...
`;
(await isScreenOff(dumpsys)).should.be.false;
(await isScreenStateOff(dumpsys)).should.be.false;
});
});

Expand Down

0 comments on commit ceb24b2

Please sign in to comment.