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

fix: Enable extensions to load on android build variants #1918

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
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