Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add activeAppInfo #1025

Merged
merged 2 commits into from
Aug 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/commands/activeAppInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let extensions = {}, commands = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const


/**
* Returns ActiveApp info.
*
* @returns {Object} The response of `/wda/activeAppInfo'`
* @throws {Error} if an error raised by command
*/
commands.mobileGetActiveAppInfo = async function mobileGetActiveAppInfo () {
return await this.proxyCommand('/wda/activeAppInfo', 'GET');
};

Object.assign(extensions, commands);
export { commands };
export default extensions;
1 change: 1 addition & 0 deletions lib/commands/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ extensions.executeMobile = async function executeMobile (mobileCommand, opts = {

batteryInfo: 'mobileGetBatteryInfo',
deviceInfo: 'mobileGetDeviceInfo',
activeAppInfo: 'mobileGetActiveAppInfo',

pressButton: 'mobilePressButton',

Expand Down
4 changes: 3 additions & 1 deletion lib/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import clipboardExtensions from './clipboard';
import certificateExtensions from './certificate';
import batteryExtensions from './battery';
import deviceInfoExtensions from './deviceInfo';
import activeAppnfoExtensions from './activeAppInfo';
import cookiesExtensions from './cookies';
import biometricExtensions from './biometric';
import keychainsExtensions from './keychains';
Expand All @@ -37,7 +38,8 @@ Object.assign(commands, contextCommands, executeExtensions,
alertExtensions, screenshotExtensions, pasteboardExtensions, locationExtensions,
lockExtensions, recordScreenExtensions, appManagementExtensions, performanceExtensions,
clipboardExtensions, certificateExtensions, batteryExtensions, cookiesExtensions,
biometricExtensions, keychainsExtensions, permissionsExtensions, deviceInfoExtensions
biometricExtensions, keychainsExtensions, permissionsExtensions, deviceInfoExtensions,
activeAppnfoExtensions
);

export default commands;
44 changes: 44 additions & 0 deletions test/unit/commands/activeAppInfo-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinon from 'sinon';
import XCUITestDriver from '../../../';

chai.should();
chai.use(chaiAsPromised);

describe('get activeapp commands', function () {
const driver = new XCUITestDriver();
// give the driver a spy-able proxy object
driver.wda = {jwproxy: {command: () => {}}};
let proxyStub;

this.beforeEach(function () {
proxyStub = sinon.stub(driver.wda.jwproxy, 'command');
});

afterEach(function () {
proxyStub.restore();
});

it('get active app info', async function () {
proxyStub.returns({
pid: 15438,
name: '',
bundleId: 'com.apple.DocumentsApp',
processArguments: { env: { HAPPY: 'testing' }, args: ['happy', 'testing'] }
});

const out = await driver.mobileGetActiveAppInfo();
out.pid.should.eq(15438);
out.name.should.eq('');
out.bundleId.should.eq('com.apple.DocumentsApp');
out.processArguments.env.HAPPY.should.eq('testing');
out.processArguments.args[0].should.eq('happy');
out.processArguments.args[1].should.eq('testing');
});

it('get active app info raise an error if the endpoint raises error', async function () {
proxyStub.throws();
await driver.mobileGetActiveAppInfo().should.eventually.be.rejected;
});
});