Skip to content

Commit

Permalink
fix: Enable extensions to load on android build variants (#1918)
Browse files Browse the repository at this point in the history
* fix: Enable extensions to load on android build variants

* Use single quotes for strings

* Improve coverage

* Modify the apkComponent variable and add a comment
  • Loading branch information
MikeM711 authored Jun 17, 2020
1 parent 04b1bf5 commit d61d94c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/util/adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
36 changes: 35 additions & 1 deletion tests/unit/test-util/test.adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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,
}
);
});
});

Expand Down

0 comments on commit d61d94c

Please sign in to comment.