Skip to content

Commit

Permalink
feat: Use APIs imported from the io.appium.settings package (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Jan 12, 2024
1 parent bca9911 commit 3f8a8e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/commands/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ commands.reset = async function reset () {
commands.getClipboard = async function getClipboard () {
return (await this.adb.getApiLevel() < 29)
? (await this.espresso.jwproxy.command('/appium/device/get_clipboard', 'POST', {}))
: (await this.adb.getClipboard());
: (await this.settingsApp.getClipboard());
};

/**
Expand Down
13 changes: 7 additions & 6 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import screenshotCmds from './commands/screenshot';
import idlingResourcesCmds from './commands/idling-resources';
import { DEFAULT_ADB_PORT } from 'appium-adb';
import {
androidHelpers, SETTINGS_HELPER_PKG_ID, AndroidDriver
androidHelpers, AndroidDriver
} from 'appium-android-driver';
import { SETTINGS_HELPER_ID } from 'io.appium.settings';
import { ESPRESSO_CONSTRAINTS } from './constraints';
import { findAPortNotInUse } from 'portscanner';
import { retryInterval } from 'asyncbox';
Expand Down Expand Up @@ -469,11 +470,11 @@ class EspressoDriver extends AndroidDriver {

if (shouldDisableAnimation) {
this.log.debug('Disabling window animation as "disableWindowAnimation" capability is set to true/fallback to default value "true"');
await this.adb.setAnimationState(false);
await this.settingsApp.setAnimationState(false);
this.wasAnimationEnabled = true;
} else if (shouldEnableAnimation) {
this.log.debug('Enabling window animation as "disableWindowAnimation" capability is set to false');
await this.adb.setAnimationState(true);
await this.settingsApp.setAnimationState(true);
this.wasAnimationEnabled = false;
} else {
this.log.debug(`Window animation is already ${isEnabled ? 'enabled' : 'disabled'}`);
Expand Down Expand Up @@ -540,7 +541,7 @@ class EspressoDriver extends AndroidDriver {
await helpers.uninstallOtherPackages(
this.adb,
helpers.parseArray(this.opts.uninstallOtherPackages),
[SETTINGS_HELPER_PKG_ID, TEST_APK_PKG]
[SETTINGS_HELPER_ID, TEST_APK_PKG]
);
}

Expand All @@ -565,7 +566,7 @@ class EspressoDriver extends AndroidDriver {
} else {
await this.espresso.installTestApk();
try {
await this.adb.addToDeviceIdleWhitelist(SETTINGS_HELPER_PKG_ID, TEST_APK_PKG);
await this.adb.addToDeviceIdleWhitelist(SETTINGS_HELPER_ID, TEST_APK_PKG);
} catch (e) {
this.log.warn(`Cannot add server packages to the Doze whitelist. Original error: ` +
(e.stderr || e.message));
Expand Down Expand Up @@ -611,7 +612,7 @@ class EspressoDriver extends AndroidDriver {
}));
if (this.wasAnimationEnabled) {
try {
await this.adb.setAnimationState(true);
await this.settingsApp.setAnimationState(true);
} catch (err) {
this.log.warn(`Unable to reset animation: ${err.message}`);
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@
],
"dependencies": {
"appium-adb": "^11.0.1",
"appium-android-driver": "^7.6.1",
"appium-android-driver": "^7.8.0",
"asyncbox": "^3.0.0",
"bluebird": "^3.5.0",
"io.appium.settings": "^5.7.1",
"lodash": "^4.17.11",
"portscanner": "^2.1.1",
"source-map-support": "^0.x",
Expand Down

0 comments on commit 3f8a8e3

Please sign in to comment.