From fd7cd42c765c6c06a2dc348ae3c0a00e83a4df47 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 2 Jun 2020 20:23:20 -0400 Subject: [PATCH 1/4] fix: Enable extensions to load on android build variants --- src/util/adb.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/util/adb.js b/src/util/adb.js index 5f18230ad5..41ca6f205b 100644 --- a/src/util/adb.js +++ b/src/util/adb.js @@ -271,8 +271,17 @@ export default class ADBUtils { value: `-profile ${deviceProfileDir}`, }]; - const component = apkComponent ? - `${apk}/.${apkComponent}` : `${apk}/.App`; + let component; + + if (!apkComponent) { + component = `${apk}/.App`; + } else if (apkComponent.includes(".")) { + component = `${apk}/${apkComponent}`; + } else if (apkComponent) { + component = `${apk}/.${apkComponent}`; + } else { + component = `${apk}/.App`; + } await wrapADBCall(async () => { await adbClient.startActivity(deviceId, { From aa1cf5725e448d2fe833fe68d3b58cc739298ccf Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 3 Jun 2020 19:36:16 -0400 Subject: [PATCH 2/4] Use single quotes for strings --- src/util/adb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/adb.js b/src/util/adb.js index 41ca6f205b..1f7946629f 100644 --- a/src/util/adb.js +++ b/src/util/adb.js @@ -275,7 +275,7 @@ export default class ADBUtils { if (!apkComponent) { component = `${apk}/.App`; - } else if (apkComponent.includes(".")) { + } else if (apkComponent.includes('.')) { component = `${apk}/${apkComponent}`; } else if (apkComponent) { component = `${apk}/.${apkComponent}`; From 3882af6054829111d8c9c57bf1d92619821616d8 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 3 Jun 2020 20:48:28 -0400 Subject: [PATCH 3/4] Improve coverage --- src/util/adb.js | 4 +--- tests/unit/test-util/test.adb.js | 36 +++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/util/adb.js b/src/util/adb.js index 1f7946629f..fbbf5cb597 100644 --- a/src/util/adb.js +++ b/src/util/adb.js @@ -277,10 +277,8 @@ export default class ADBUtils { component = `${apk}/.App`; } else if (apkComponent.includes('.')) { component = `${apk}/${apkComponent}`; - } else if (apkComponent) { - component = `${apk}/.${apkComponent}`; } else { - component = `${apk}/.App`; + component = `${apk}/.${apkComponent}`; } await wrapADBCall(async () => { 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, + } + ); }); }); From b61d311d1b36d7297c8fc908639d1d890ad64a13 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 12 Jun 2020 18:32:12 -0400 Subject: [PATCH 4/4] Modify the apkComponent variable and add a comment --- src/util/adb.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/util/adb.js b/src/util/adb.js index fbbf5cb597..77315022e6 100644 --- a/src/util/adb.js +++ b/src/util/adb.js @@ -271,15 +271,14 @@ export default class ADBUtils { value: `-profile ${deviceProfileDir}`, }]; - let component; - if (!apkComponent) { - component = `${apk}/.App`; - } else if (apkComponent.includes('.')) { - component = `${apk}/${apkComponent}`; - } else { - component = `${apk}/.${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, {