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

launchers: pass URL arg to Android launchers (bug 1852787) #1453

Merged
merged 3 commits into from
Sep 27, 2023
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
20 changes: 14 additions & 6 deletions mozregression/launchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,14 @@ def _start(
self.adb.rm(self.remote_profile, recursive=True)
LOG.debug("Pushing profile to device (%s -> %s)" % (profile.profile, self.remote_profile))
self.adb.push(profile.profile, self.remote_profile)
self._launch()
if cmdargs and len(cmdargs) == 1 and not cmdargs[0].startswith("-"):
url = cmdargs[0]
else:
url = None
if isinstance(self, (FenixLauncher, FennecLauncher, FocusLauncher)):
self._launch(url=url)
else:
self._launch()

def _wait(self):
while self.adb.process_exist(self.package_name):
Expand Down Expand Up @@ -527,31 +534,32 @@ class FennecLauncher(AndroidLauncher):
def _get_package_name(self):
return "org.mozilla.fennec"

def _launch(self):
def _launch(self, url=None):
LOG.debug("Launching fennec")
self.launch_browser(self.package_name, "org.mozilla.gecko.BrowserApp")
self.launch_browser(self.package_name, "org.mozilla.gecko.BrowserApp", url=url)


@REGISTRY.register("fenix")
class FenixLauncher(AndroidLauncher):
def _get_package_name(self):
return "org.mozilla.fenix"

def _launch(self):
def _launch(self, url=None):
LOG.debug("Launching fenix")
self.launch_browser(self.package_name, ".IntentReceiverActivity")
self.launch_browser(self.package_name, ".IntentReceiverActivity", url=url)


@REGISTRY.register("focus")
class FocusLauncher(AndroidLauncher):
def _get_package_name(self):
return "org.mozilla.focus.nightly"

def _launch(self):
def _launch(self, url=None):
LOG.debug("Launching focus")
self.launch_browser(
self.package_name,
"org.mozilla.focus.activity.IntentReceiverActivity",
url=url,
)


Expand Down
19 changes: 19 additions & 0 deletions tests/unit/test_launchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,25 @@ def proc_exists(name):
launcher.wait()
self.adb.process_exist.assert_called_with(package_name)

def test_start_with_url(self, launcher_class, package_name, intended_activity, **kwargs):
with patch(
f"mozregression.launchers.{launcher_class.__name__}._create_profile"
) as _create_profile:
# Force use of existing profile
_create_profile.return_value = self.profile
launcher = self.create_launcher(launcher_class=launcher_class)
launcher.start(profile="my_profile", cmdargs=("https://example.org/",))
self.adb.launch_application.assert_called_once_with(
package_name,
intended_activity,
"android.intent.action.VIEW",
url="https://example.org/",
extras={"args": f"-profile {self.remote_profile_path}"},
wait=True,
fail_if_running=True,
timeout=None,
)


class Zipfile(object):
def __init__(self, *a):
Expand Down