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

feat: Support for android build variants without requiring a fully qualified value in the --apk-component flag #1941

Conversation

MikeM711
Copy link
Contributor

Fixes #1935

Desired behavior from the original issue:

web-ext run -t firefox-android --android-device=<device ID here> --firefox-apk=org.mozilla.fenix.performancetest --firefox-apk-component=HomeActivity

@coveralls
Copy link

coveralls commented Jun 26, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 819d5a2 on MikeM711:pr/support-variants-without-fully-qualified-value into 515e8cf on mozilla:master.

'org.mozilla.geckoview_example',
'org.mozilla.geckoview_example.GeckoViewActivity', // firefoxApkComponent
'org.mozilla.geckoview_example.release',
'GeckoViewActivity', // firefoxApkComponent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those tests should not be modified (because the old syntax should still work).

Please add a new test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing - I'll add a new test for org.mozilla.fenix.nightly


export const browserList = [
'org.mozilla.fennec',
'org.mozilla.fenix',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you run an actual test with org.mozilla.fenix.nightly to verify that it works, and if it does work, add a unit test for it? It is not entirely obvious that org.mozilla.fenix.nightly ought to use org.mozilla.fenix as the name.

Copy link
Contributor Author

@MikeM711 MikeM711 Jul 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, just added the test in the new commit

@@ -0,0 +1,10 @@
/* @flow */

export const browserList = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to packageIdBases ?

or just export default. The file name, packageIdentifiers, is already a nice name on its own.

if (!apkComponent) {
apkComponent = '.App';
} else if (!apkComponent.includes('.')) {
apkComponent = `.${apkComponent}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This original logic should be kept. It allows users to use a custom app that isn't in the hardcoded list. For example if they develop their own GeckoView-based app.

The change that you need is to check if apk starts with any of the known prefixes, and if it is, prepend that prefix before .${apkComponent}.

…to support full and shortened apkComponents, added org.mozilla.fenix.nightly test
src/util/adb.js Outdated
break;
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully this isn't too hacky - it's mainly due to wanting to leave the loop if geckoview_example has been checked, so it doesn't check again on geckoview

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break after finding the matching apk is not a hack, it looks normal.

src/util/adb.js Outdated
break;
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break after finding the matching apk is not a hack, it looks normal.

src/util/adb.js Outdated
@@ -271,6 +272,17 @@ export default class ADBUtils {
value: `-profile ${deviceProfileDir}`,
}];

for (const browser of packageIdentifiers) {
if (apk.startsWith(browser) && apkComponent) {
if (apk !== browser && !apkComponent.includes('.')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic should be after the following block below, to make sure that the browser is also prepended by default (.App):

    if (!apkComponent) {
      apkComponent = '.App';
    } else if (!apkComponent.includes('.')) {
      apkComponent = `.${apkComponent}`;
    }

It would be nice to have unit tests to cover these cases.

And then the logic should be like this:

if (apkComponent.startsWith(".")) {
  // loop over packageIdentifiers,
  // and if apk is either identical to the package,
  // or apk starts with `${package}.`,
  // prepend the package identifier before `apkComponent`
  // and break. 
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or apk starts with ${package}.

Ah! That's a good idea for the whole "geckoview" vs "geckoview_example"

src/util/adb.js Outdated
// before `apkComponent`
if (apkComponent.startsWith('.')) {
for (const browser of packageIdentifiers) {
if (apk.startsWith(`${browser}.`)) {
Copy link
Contributor Author

@MikeM711 MikeM711 Jul 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick note (before I move on to adding tests):

In the previous comment, there was the condition:

if apk is either identical to the package, or apk starts with `${package}.`

For the tests to work, I took out the apk is identical to the package part of the or condition.

The offended test was: starts a given APK component without a period

  • Incoming apk: org.mozilla.geckoview_example
  • Incoming apkComponent: GeckoViewActivity
  • Expected result: org.mozilla.geckoview_example/.GeckoViewActivity
  • Result received: org.mozilla.geckoview_example/org.mozilla.geckoview_example.GeckoViewActivity

Would you like me to expand out the Expected Result of this test to match the received result and use the apk is identical to the package condition on this line?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ADB the two results are equivalent.

The behavior of the received result is probably more desirable to support the .debug/. performancetest scenarios.

@MikeM711
Copy link
Contributor Author

Hey, sorry I've been spotty on this PR - backlogged with work and class.

On Aug 23rd I should have a nice break - this PR is a simple fix, but I like to have full attention for it before proceeding. Should be good then.

@Rob--W
Copy link
Member

Rob--W commented Aug 12, 2020

Thanks for the heads-up @MikeM711 and no worries! Your contributions are appreciated, regardless of how much time it takes.

@MikeM711
Copy link
Contributor Author

MikeM711 commented Aug 24, 2020

Assuming that the previous commit looks good to you,

For APK tests we currently have:

Test name Incoming apk Incoming apkComponent
rejects an UsageError on adb binary not found' org.mozilla.firefox_mybuild undefined
starts Firefox APK on a custom profile (only used by Fennec) org.mozilla.firefox_mybuild undefined
starts a given APK component without a period org.mozilla.geckoview_example GeckoViewActivity
starts a given APK component with a period org.mozilla.geckoview_example org.mozilla.geckoview_example.GeckoViewActivity
starts a given APK component on fenix.nightly org.mozilla.fenix.nightly HomeActivity

To take care of, #1941 (comment), what do you think about these few tests?

Test name Incoming apk Incoming apkComponent
starts an undefined APK component
starts without specifying an APK component
org.mozilla.geckoview_example undefined
starts a fully-qualified APK component on the build-variant: fenix.nightly org.mozilla.fenix.nightly org.mozilla.fenix.HomeActivity
starts a given APK component that begins with a period org.mozilla.fenix.nightly .HomeActivity

@Rob--W
Copy link
Member

Rob--W commented Aug 25, 2020

The proposed tests look good. Thanks for the table with the clear summarizing overview.

starts an undefined APK component

I would make this "starts without specifying an APK component"

@MikeM711
Copy link
Contributor Author

MikeM711 commented Aug 27, 2020

No problem! Let me know how it looks

Copy link
Member

@Rob--W Rob--W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for android build variants without requiring a fully qualified value in the --apk-component flag
4 participants