diff --git a/src/util/adb.js b/src/util/adb.js index 5f18230ad5..77315022e6 100644 --- a/src/util/adb.js +++ b/src/util/adb.js @@ -271,8 +271,14 @@ export default class ADBUtils { value: `-profile ${deviceProfileDir}`, }]; - const component = apkComponent ? - `${apk}/.${apkComponent}` : `${apk}/.App`; + if (!apkComponent) { + apkComponent = '.App'; + } else if (!apkComponent.includes('.')) { + apkComponent = `.${apkComponent}`; + } + // if `apkComponent` starts with a '.', then adb will expand + // the following to: `${apk}/${apk}.${apkComponent}` + const component = `${apk}/${apkComponent}`; await wrapADBCall(async () => { await adbClient.startActivity(deviceId, { diff --git a/tests/unit/test-util/test.adb.js b/tests/unit/test-util/test.adb.js index a86f4bb3eb..7fc35e589a 100644 --- a/tests/unit/test-util/test.adb.js +++ b/tests/unit/test-util/test.adb.js @@ -733,7 +733,7 @@ describe('utils/adb', () => { adb.fakeADBClient.startActivity, 'device1', expectedAdbParams); }); - it('starts a given APK component', async () => { + it('starts a given APK component without a period', async () => { const adb = getFakeADBKit({ adbClient: { startActivity: sinon.spy(() => Promise.resolve()), @@ -765,7 +765,41 @@ describe('utils/adb', () => { wait: true, } ); + }); + + it('starts a given APK component with a period', async () => { + const adb = getFakeADBKit({ + adbClient: { + startActivity: sinon.spy(() => Promise.resolve()), + }, + adbkitUtil: { + readAll: sinon.spy(() => Promise.resolve(Buffer.from('\n'))), + }, + }); + const adbUtils = new ADBUtils({adb}); + + const promise = adbUtils.startFirefoxAPK( + 'device1', + 'org.mozilla.geckoview_example', + 'org.mozilla.geckoview_example.GeckoViewActivity', // firefoxApkComponent + '/fake/custom/profile/path', + ); + + await assert.isFulfilled(promise); + sinon.assert.calledOnce(adb.fakeADBClient.startActivity); + sinon.assert.calledWithMatch( + adb.fakeADBClient.startActivity, 'device1', { + action: 'android.activity.MAIN', + component: 'org.mozilla.geckoview_example/' + + 'org.mozilla.geckoview_example.GeckoViewActivity', + extras: [{ + key: 'args', + value: '-profile /fake/custom/profile/path', + }], + wait: true, + } + ); }); });