diff --git a/README.md b/README.md index 85072168..1f700379 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,6 @@ console.log(await adb.getPIDsByName('com.android.phone')); - `killProcessByPID` - `broadcastProcessEnd` - `broadcast` -- `endAndroidCoverage` -- `instrument` -- `androidCoverage` - `packageAndLaunchActivityFromManifest` - `compileManifest` - `insertManifest` diff --git a/lib/adb.ts b/lib/adb.ts index 244a5bd5..f8088112 100644 --- a/lib/adb.ts +++ b/lib/adb.ts @@ -13,7 +13,6 @@ export const DEFAULT_OPTS = { executable: {path: 'adb', defaultArgs: []}, tmpDir: os.tmpdir(), binaries: {}, - jars: {}, adbPort: DEFAULT_ADB_PORT, adbExecTimeout: DEFAULT_ADB_EXEC_TIMEOUT, remoteAppsCacheLimit: 10, diff --git a/lib/options.ts b/lib/options.ts index c730075d..1c74fca0 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -17,9 +17,7 @@ export interface ADBOptions { emulatorPort?: number; logcat?: Logcat; binaries?: StringRecord; - instrumentProc?: SubProcess; suppressKillServer?: boolean; - jars?: StringRecord; adbPort?: number; adbHost?: string; adbExecTimeout?: number; @@ -30,7 +28,6 @@ export interface ADBOptions { remoteAdbHost?: string; remoteAdbPort?: number; clearDeviceLogsOnStart?: boolean; - emPort?: number; } export interface ADBExecutable { diff --git a/lib/tools/adb-commands.js b/lib/tools/adb-commands.js index 9d931130..bdb065dc 100644 --- a/lib/tools/adb-commands.js +++ b/lib/tools/adb-commands.js @@ -1477,79 +1477,6 @@ methods.broadcast = async function broadcast (intent) { await this.shell(['am', 'broadcast', '-a', intent]); }; -/** - * Kill Android instruments if they are currently running. - * @this {import('../adb.js').ADB} - */ -methods.endAndroidCoverage = async function endAndroidCoverage () { - if (this.instrumentProc && this.instrumentProc.isRunning) { - await this.instrumentProc.stop(); - } -}; - -/** - * Instrument the particular activity. - * - * @this {import('../adb.js').ADB} - * @param {string} pkg - The name of the package to be instrumented. - * @param {string} activity - The name of the main activity in this package. - * @param {string} instrumentWith - The name of the package to instrument - * the activity with. - * @throws {error} If any exception is reported by adb shell. - */ -methods.instrument = async function instrument (pkg, activity, instrumentWith) { - if (activity[0] !== '.') { - pkg = ''; - } - let pkgActivity = (pkg + activity).replace(/\.+/g, '.'); // Fix pkg..activity error - let stdout = await this.shell([ - 'am', 'instrument', - '-e', 'main_activity', - pkgActivity, - instrumentWith, - ]); - if (stdout.indexOf('Exception') !== -1) { - throw new Error(`Unknown exception during instrumentation. Original error ${stdout.split('\n')[0]}`); - } -}; - -/** - * Collect Android coverage by instrumenting the particular activity. - * - * @this {import('../adb.js').ADB} - * @param {string} instrumentClass - The name of the instrumentation class. - * @param {string} waitPkg - The name of the package to be instrumented. - * @param {string} waitActivity - The name of the main activity in this package. - * - * @return {Promise} The promise is successfully resolved if the instrumentation starts - * without errors. - */ -methods.androidCoverage = async function androidCoverage (instrumentClass, waitPkg, waitActivity) { - if (!this.isValidClass(instrumentClass)) { - throw new Error(`Invalid class ${instrumentClass}`); - } - return await new B(async (resolve, reject) => { - let args = this.executable.defaultArgs - .concat(['shell', 'am', 'instrument', '-e', 'coverage', 'true', '-w']) - .concat([instrumentClass]); - log.debug(`Collecting coverage data with: ${[this.executable.path].concat(args).join(' ')}`); - try { - // am instrument runs for the life of the app process. - this.instrumentProc = new SubProcess(this.executable.path, args); - await this.instrumentProc.start(0); - this.instrumentProc.on('output', (stdout, stderr) => { - if (stderr) { - reject(new Error(`Failed to run instrumentation. Original error: ${stderr}`)); - } - }); - await this.waitForActivity(waitPkg, waitActivity); - resolve(); - } catch (e) { - reject(new Error(`Android coverage failed. Original error: ${(/**@type {Error} */ (e)).message}`)); - } - }); -}; - /** * Get the particular property of the device under test. * diff --git a/test/unit/adb-commands-specs.js b/test/unit/adb-commands-specs.js index 0e6a550b..1563a0b5 100644 --- a/test/unit/adb-commands-specs.js +++ b/test/unit/adb-commands-specs.js @@ -3,7 +3,6 @@ import chaiAsPromised from 'chai-as-promised'; // eslint-disable-next-line import/no-unresolved import {ADB} from '../../lib/adb'; import net from 'net'; -import events from 'events'; import Logcat from '../../lib/logcat.js'; import * as teen_process from 'teen_process'; import { withMocks } from '@appium/test-support'; @@ -872,37 +871,6 @@ describe('adb commands', withMocks({adb, logcat, teen_process, net}, function (m await adb.broadcast(intent); }); }); - describe('instrument', function () { - it('should call shell with correct arguments', async function () { - let intent = 'intent'; - mocks.adb.expects('shell') - .once().withExactArgs(['am', 'broadcast', '-a', intent]) - .returns(''); - await adb.broadcast(intent); - }); - }); - describe('androidCoverage', function () { - it('should call shell with correct arguments', async function () { - adb.executable.defaultArgs = []; - adb.executable.path = 'dummy_adb_path'; - let conn = new events.EventEmitter(); - conn.start = () => { }; // do nothing - const instrumentClass = 'instrumentClass', - waitPkg = 'waitPkg', - waitActivity = 'waitActivity'; - let args = adb.executable.defaultArgs - .concat(['shell', 'am', 'instrument', '-e', 'coverage', 'true', '-w']) - .concat([instrumentClass]); - mocks.teen_process.expects('SubProcess') - .withArgs('dummy_adb_path', args) - .onFirstCall() - .returns(conn); - mocks.adb.expects('waitForActivity') - .once().withExactArgs(waitPkg, waitActivity) - .returns(''); - await adb.androidCoverage(instrumentClass, waitPkg, waitActivity); - }); - }); }); describe('device info', function () { it('should get device model', async function () {