Skip to content

Commit d61d94c

Browse files
authored
fix: Enable extensions to load on android build variants (#1918)
* fix: Enable extensions to load on android build variants * Use single quotes for strings * Improve coverage * Modify the apkComponent variable and add a comment
1 parent 04b1bf5 commit d61d94c

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/util/adb.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,14 @@ export default class ADBUtils {
271271
value: `-profile ${deviceProfileDir}`,
272272
}];
273273

274-
const component = apkComponent ?
275-
`${apk}/.${apkComponent}` : `${apk}/.App`;
274+
if (!apkComponent) {
275+
apkComponent = '.App';
276+
} else if (!apkComponent.includes('.')) {
277+
apkComponent = `.${apkComponent}`;
278+
}
279+
// if `apkComponent` starts with a '.', then adb will expand
280+
// the following to: `${apk}/${apk}.${apkComponent}`
281+
const component = `${apk}/${apkComponent}`;
276282
277283
await wrapADBCall(async () => {
278284
await adbClient.startActivity(deviceId, {

tests/unit/test-util/test.adb.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ describe('utils/adb', () => {
733733
adb.fakeADBClient.startActivity, 'device1', expectedAdbParams);
734734
});
735735

736-
it('starts a given APK component', async () => {
736+
it('starts a given APK component without a period', async () => {
737737
const adb = getFakeADBKit({
738738
adbClient: {
739739
startActivity: sinon.spy(() => Promise.resolve()),
@@ -765,7 +765,41 @@ describe('utils/adb', () => {
765765
wait: true,
766766
}
767767
);
768+
});
769+
770+
it('starts a given APK component with a period', async () => {
771+
const adb = getFakeADBKit({
772+
adbClient: {
773+
startActivity: sinon.spy(() => Promise.resolve()),
774+
},
775+
adbkitUtil: {
776+
readAll: sinon.spy(() => Promise.resolve(Buffer.from('\n'))),
777+
},
778+
});
779+
const adbUtils = new ADBUtils({adb});
780+
781+
const promise = adbUtils.startFirefoxAPK(
782+
'device1',
783+
'org.mozilla.geckoview_example',
784+
'org.mozilla.geckoview_example.GeckoViewActivity', // firefoxApkComponent
785+
'/fake/custom/profile/path',
786+
);
787+
788+
await assert.isFulfilled(promise);
768789

790+
sinon.assert.calledOnce(adb.fakeADBClient.startActivity);
791+
sinon.assert.calledWithMatch(
792+
adb.fakeADBClient.startActivity, 'device1', {
793+
action: 'android.activity.MAIN',
794+
component: 'org.mozilla.geckoview_example/' +
795+
'org.mozilla.geckoview_example.GeckoViewActivity',
796+
extras: [{
797+
key: 'args',
798+
value: '-profile /fake/custom/profile/path',
799+
}],
800+
wait: true,
801+
}
802+
);
769803
});
770804
});
771805

0 commit comments

Comments
 (0)