Commit 332168be authored by James Cook's avatar James Cook Committed by Chromium LUCI CQ

lacros: Enable the crosapi mojo interface in interactive_ui_tests

This is a step towards allowing existing interactive_ui_tests to
use the TestController crosapi interface to interact with the
ash window manager.

We have to filter out one test, because hooking up crosapi applies
a restriction to the main browser profile that it is a "regular"
profile that matches the device account. This restriction matches
production behavior, so this is desirable in general.

Bug: 1166936
Test: interactive_ui_tests

Change-Id: I20ace7c9f98be32596437de8223c069bd7fcffaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631746Reviewed-by: default avatarYuke Liao <liaoyuke@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844285}
parent 7eb8453c
......@@ -91,11 +91,20 @@ _TARGETS_REQUIRE_ASH_CHROME = [
'views_unittests',
'wm_unittests',
# regex patters.
# regex patterns.
'.*_browsertests',
'.*interactive_ui_tests'
]
# List of targets that require ash-chrome to support crosapi mojo APIs.
_TARGETS_REQUIRE_MOJO_CROSAPI = [
# TODO(jamescook): Add 'browser_tests' after multiple crosapi connections
# are allowed. For now we only enable crosapi in targets that run tests
# serially.
'interactive_ui_tests',
'lacros_chrome_browsertests'
]
def _GetAshChromeDirPath(version):
"""Returns a path to the dir storing the downloaded version of ash-chrome."""
......@@ -218,40 +227,41 @@ def _GetLatestVersionOfAshChrome():
def _WaitForAshChromeToStart(tmp_xdg_dir, lacros_mojo_socket_file,
is_lacros_chrome_browsertests):
enable_mojo_crosapi):
"""Waits for Ash-Chrome to be up and running and returns a boolean indicator.
Determine whether ash-chrome is up and running by checking whether two files
(lock file + socket) have been created in the |XDG_RUNTIME_DIR| and the lacros
mojo socket file has been created if running lacros_chrome_browsertests.
mojo socket file has been created if enabling the mojo "crosapi" interface.
TODO(crbug.com/1107966): Figure out a more reliable hook to determine the
status of ash-chrome, likely through mojo connection.
Args:
tmp_xdg_dir (str): Path to the XDG_RUNTIME_DIR.
lacros_mojo_socket_file (str): Path to the lacros mojo socket file.
is_lacros_chrome_browsertests (bool): is running lacros_chrome_browsertests.
enable_mojo_crosapi (bool): Whether to bootstrap the crosapi mojo interface
between ash and the lacros test binary.
Returns:
A boolean indicating whether Ash-chrome is up and running.
"""
def IsAshChromeReady(tmp_xdg_dir, lacros_mojo_socket_file,
is_lacros_chrome_browsertests):
enable_mojo_crosapi):
return (len(os.listdir(tmp_xdg_dir)) >= 2
and (not is_lacros_chrome_browsertests
and (not enable_mojo_crosapi
or os.path.exists(lacros_mojo_socket_file)))
time_counter = 0
while not IsAshChromeReady(tmp_xdg_dir, lacros_mojo_socket_file,
is_lacros_chrome_browsertests):
enable_mojo_crosapi):
time.sleep(0.5)
time_counter += 0.5
if time_counter > ASH_CHROME_TIMEOUT_SECONDS:
break
return IsAshChromeReady(tmp_xdg_dir, lacros_mojo_socket_file,
is_lacros_chrome_browsertests)
enable_mojo_crosapi)
def _RunTestWithAshChrome(args, forward_args):
......@@ -281,8 +291,8 @@ def _RunTestWithAshChrome(args, forward_args):
lacros_mojo_socket_file = '%s/lacros.sock' % tmp_ash_data_dir_name
lacros_mojo_socket_arg = ('--lacros-mojo-socket-for-testing=%s' %
lacros_mojo_socket_file)
is_lacros_chrome_browsertests = (os.path.basename(
args.command) == 'lacros_chrome_browsertests')
enable_mojo_crosapi = any(t == os.path.basename(args.command)
for t in _TARGETS_REQUIRE_MOJO_CROSAPI)
ash_process = None
ash_env = os.environ.copy()
......@@ -293,7 +303,7 @@ def _RunTestWithAshChrome(args, forward_args):
'--enable-wayland-server',
'--no-startup-window',
]
if is_lacros_chrome_browsertests:
if enable_mojo_crosapi:
ash_cmd.append(lacros_mojo_socket_arg)
ash_process_has_started = False
......@@ -303,8 +313,7 @@ def _RunTestWithAshChrome(args, forward_args):
num_tries += 1
ash_process = subprocess.Popen(ash_cmd, env=ash_env)
ash_process_has_started = _WaitForAshChromeToStart(
tmp_xdg_dir_name, lacros_mojo_socket_file,
is_lacros_chrome_browsertests)
tmp_xdg_dir_name, lacros_mojo_socket_file, enable_mojo_crosapi)
if ash_process_has_started:
break
......@@ -319,7 +328,7 @@ def _RunTestWithAshChrome(args, forward_args):
raise RuntimeError('Timed out waiting for ash-chrome to start')
# Starts tests.
if is_lacros_chrome_browsertests:
if enable_mojo_crosapi:
forward_args.append(lacros_mojo_socket_arg)
reason_of_jobs_1 = (
......
......@@ -44,6 +44,11 @@
-WidgetCaptureTest.SystemModalWindowReleasesCapture
-WidgetInputMethodInteractiveTest*
# TODO(https://crbug.com/991596): Setup guest profiles correctly for tests.
# Lacros has restrictions on the main profile (it must match the device account
# profile) so this test doesn't pass.
-AllGuestProfileTypes/GuestToolbarViewWithExtensionsToolbarMenuTest.*
# crbug.com/1121486
# Following tests were flaky. We disable them first until we have time to investigate.
-BrowserCommandControllerInteractiveTest.ShortcutsShouldTakeEffectInBrowserFullscreen
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment