Commit 5f73f588 authored by Ossama Mahmoud's avatar Ossama Mahmoud Committed by Chromium LUCI CQ

Migrate AutolaunchScreen to LoginScreenBehavior

Bug: 1153306
Change-Id: I425eba7b9d8b15c6538f4dc49ddd4db893779128
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2566993Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Commit-Queue: Ossama Mahmoud <osamafathy@google.com>
Cr-Commit-Position: refs/heads/master@{#836580}
parent e2b5130c
......@@ -134,6 +134,8 @@ namespace chromeos {
namespace {
const test::UIPath kConfigNetwork = {"app-launch-splash", "configNetwork"};
const test::UIPath kAutolaunchConfirmButton = {"autolaunch", "confirmButton"};
const test::UIPath kAutolaunchCancelButton = {"autolaunch", "cancelButton"};
// This is a simple test app that creates an app window and immediately closes
// it again. Webstore data json is in
......@@ -805,7 +807,7 @@ class KioskTest : public OobeBaseTest {
}
}
void WaitForAuthLaunchWarning(bool visibility) {
void WaitForAutoLaunchWarning(bool visibility) {
test::OobeJS().CreateVisibilityWaiter(visibility, {"autolaunch"})->Wait();
}
......@@ -1137,12 +1139,11 @@ IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) {
wizard_controller->SkipToLoginForTesting();
// Wait for the auto launch warning come up.
WaitForAuthLaunchWarning(/*visibility=*/true);
test::ExecuteOobeJS(
"login.AutolaunchScreen.confirmAutoLaunchForTesting(false);");
WaitForAutoLaunchWarning(/*visibility=*/true);
test::OobeJS().ClickOnPath(kAutolaunchCancelButton);
// Wait for the auto launch warning to go away.
WaitForAuthLaunchWarning(/*visibility=*/false);
WaitForAutoLaunchWarning(/*visibility=*/false);
EXPECT_FALSE(KioskAppManager::Get()->IsAutoLaunchEnabled());
}
......@@ -1164,13 +1165,12 @@ IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningConfirm) {
wizard_controller->SkipToLoginForTesting();
// Wait for the auto launch warning come up.
WaitForAuthLaunchWarning(/*visibility=*/true);
WaitForAutoLaunchWarning(/*visibility=*/true);
test::ExecuteOobeJS(
"login.AutolaunchScreen.confirmAutoLaunchForTesting(true);");
test::OobeJS().ClickOnPath(kAutolaunchConfirmButton);
// Wait for the auto launch warning to go away.
WaitForAuthLaunchWarning(/*visibility=*/false);
WaitForAutoLaunchWarning(/*visibility=*/false);
EXPECT_FALSE(KioskAppManager::Get()->GetAutoLaunchApp().empty());
EXPECT_TRUE(KioskAppManager::Get()->IsAutoLaunchEnabled());
......@@ -1323,14 +1323,13 @@ IN_PROC_BROWSER_TEST_F(KioskTest, NoConsumerAutoLaunchWhenUntrusted) {
wizard_controller->AdvanceToScreen(WelcomeView::kScreenId);
ReloadAutolaunchKioskApps();
wizard_controller->SkipToLoginForTesting();
WaitForAuthLaunchWarning(/*visibility=*/true);
WaitForAutoLaunchWarning(/*visibility=*/true);
// Make cros settings untrusted.
settings_helper_.SetTrustedStatus(
CrosSettingsProvider::PERMANENTLY_UNTRUSTED);
test::ExecuteOobeJS(
"login.AutolaunchScreen.confirmAutoLaunchForTesting(true);");
test::OobeJS().ClickOnPath(kAutolaunchConfirmButton);
// Check that the attempt to auto-launch a kiosk app fails with an error.
OobeScreenWaiter(ErrorScreenView::kScreenId).Wait();
......@@ -2786,7 +2785,7 @@ IN_PROC_BROWSER_TEST_F(KioskHiddenWebUITest, AutolaunchWarning) {
EXPECT_FALSE(KioskAppManager::Get()->IsAutoLaunchEnabled());
// Wait for the auto launch warning come up.
WaitForAuthLaunchWarning(/*visibility=*/true);
WaitForAutoLaunchWarning(/*visibility=*/true);
// Wait for the wallpaper to load.
WaitForWallpaper();
......
......@@ -54,7 +54,6 @@
<script src="chrome://oobe/strings.js"></script>
<script defer src="chrome://oobe/test_api.js"></script>
<link rel="stylesheet" href="api_keys_notice.css">
<link rel="stylesheet" href="oobe_screen_autolaunch.css">
<link rel="stylesheet" href="screen_error_message.css">
<script src="chrome://oobe/keyboard_utils.js"></script>
......
......@@ -19,7 +19,6 @@
// <include
// src="../../../../../ui/login/account_picker/chromeos_user_pod_row.js">
// <include src="cr_ui.js">
// <include src="oobe_screen_autolaunch.js">
// <include src="oobe_select.js">
// <include src="screen_error_message.js">
......@@ -48,7 +47,6 @@ HTMLImports.whenReady(() => {
initialize() {
cr.ui.login.DisplayManager.initialize();
login.AccountPickerScreen.register();
login.AutolaunchScreen.register();
login.ErrorMessageScreen.register();
login.DiscoverScreen.register();
......
......@@ -59,8 +59,6 @@
<script defer src="chrome://oobe/test_api.js"></script>
<link rel="stylesheet" href="api_keys_notice.css">
<link rel="stylesheet" href="oobe_screen_autolaunch.css">
<link rel="stylesheet" href="screen_error_message.css">
<script src="chrome://oobe/keyboard_utils.js"></script>
......
......@@ -20,7 +20,6 @@
// <include
// src="../../../../../ui/login/account_picker/chromeos_user_pod_row.js">
// <include src="cr_ui.js">
// <include src="oobe_screen_autolaunch.js">
// <include src="oobe_select.js">
// <include src="screen_error_message.js">
......@@ -39,7 +38,6 @@ HTMLImports.whenReady(() => {
*/
initialize() {
cr.ui.login.DisplayManager.initialize();
login.AutolaunchScreen.register();
login.AccountPickerScreen.register();
login.ErrorMessageScreen.register();
login.DiscoverScreen.register();
......
/* Copyright 2013 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
#autolaunch {
min-height: 423px;
padding: 40px 17px 80px;
text-align: center;
width: 722px;
}
#autolaunch-controls {
bottom: 80px;
justify-content: center;
}
#autolaunch-warning-title {
color: #606060;
font-size: 22px;
padding: 5px 45px 30px;
}
#autolaunch-warning {
color: #606060;
font-size: 16px;
padding: 35px 40px 10px;
}
#autolaunch-app {
padding-bottom: 40px;
}
#autolaunch-app-container {
-webkit-align-items: center;
-webkit-justify-content: center;
display: -webkit-flex;
}
#autolaunch-app-name {
color: #404040;
font-size: 22px;
padding-left: 10px;
}
<div class="step hidden" id="autolaunch" hidden>
<div class="step-contents">
<div id="autolaunch-warning-title" i18n-content="autolaunchTitle"></div>
<div id="autolaunch-app-container">
<img id="autolaunch-app-icon" alt="">
<div id="autolaunch-app-name"></div>
<dom-module id="autolaunch-element">
<template>
<style include="oobe-dialog-host">
#warning{
color: #606060;
}
#appName {
color: #404040;
font-size: 22px;
}
</style>
<oobe-dialog id="autolaunch" role="dialog" title-key="autolaunchTitle"
aria-label$="[[i18nDynamic(locale, 'autolaunchTitle')]]" has-buttons>
<div id="footer" slot="footer">
<img id="appIcon" src="[[appIcon_]]" alt="">
<div id="appName">[[appName_]]</div>
<div id="warning" slot="subtitle">[[i18nDynamic(locale, 'autolaunchWarning')]]</div>
</div>
<div id="autolaunch-warning" i18n-content="autolaunchWarning"></div>
<div slot="bottom-buttons" class="layout horizontal end-justified">
<oobe-text-button id="cancelButton" on-click="onCancel_" text-key="autolaunchCancelButton"
class="focus-on-show">
</oobe-text-button>
<oobe-text-button id="confirmButton" on-click="onConfirm_"
text-key="autolaunchConfirmButton" inverse>
</oobe-text-button>
</div>
<div id="autolaunch-controls" class="step-controls"></div>
</div>
</oobe-dialog>
</template>
</dom-module>
\ No newline at end of file
......@@ -6,37 +6,33 @@
* @fileoverview Oobe reset screen implementation.
*/
login.createScreen('AutolaunchScreen', 'autolaunch', function() {
return {
EXTERNAL_API: ['updateApp', 'confirmAutoLaunchForTesting'],
Polymer({
is: 'autolaunch-element',
/**
* Buttons in oobe wizard's button strip.
* @type {array} Array of Buttons.
*/
get buttons() {
var buttons = [];
behaviors: [OobeI18nBehavior, OobeDialogHostBehavior, LoginScreenBehavior],
var confirmButton = this.ownerDocument.createElement('button');
confirmButton.id = 'autolaunch-confirm-button';
confirmButton.textContent =
loadTimeData.getString('autolaunchConfirmButton');
confirmButton.addEventListener('click', function(e) {
chrome.send('autolaunchOnConfirm');
e.stopPropagation();
EXTERNAL_API: [
'updateApp',
],
properties: {
appName_: {type: String, value: ''},
appIconUrl_: {type: String, value: ''},
},
ready() {
this.initializeLoginScreen('AutolaunchScreen', {
resetAllowed: true,
});
buttons.push(confirmButton);
},
onConfirm_() {
chrome.send('autolaunchOnConfirm');
},
var cancelButton = this.ownerDocument.createElement('button');
cancelButton.id = 'autolaunch-cancel-button';
cancelButton.textContent =
loadTimeData.getString('autolaunchCancelButton');
cancelButton.addEventListener('click', function(e) {
onCancel_() {
chrome.send('autolaunchOnCancel');
e.stopPropagation();
});
buttons.push(cancelButton);
return buttons;
},
/**
......@@ -46,13 +42,6 @@ login.createScreen('AutolaunchScreen', 'autolaunch', function() {
chrome.send('autolaunchVisible');
},
/**
* Returns a control which should receive an initial focus.
*/
get defaultControl() {
return $('autolaunch-cancel-button');
},
/**
* Cancels the reset and drops the user back to the login screen.
*/
......@@ -65,22 +54,8 @@ login.createScreen('AutolaunchScreen', 'autolaunch', function() {
* @param {!Object} app An dictionary with app info.
*/
updateApp(app) {
this.appName_ = app.appName;
if (app.appIconUrl && app.appIconUrl.length)
$('autolaunch-app-icon').src = app.appIconUrl;
$('autolaunch-app-name').innerText = app.appName;
this.appIconUrl_ = app.appIconUrl;
},
/**
* Initiates confirm/cancel response for testing.
* @param {boolean} confirm True if the screen should confirm auto-launch.
*/
confirmAutoLaunchForTesting(confirm) {
var button = confirm ? $('autolaunch-confirm-button') :
$('autolaunch-cancel-button');
var clickEvent = document.createEvent('Event');
clickEvent.initEvent('click', true, true);
button.dispatchEvent(clickEvent);
}
};
});
......@@ -54,6 +54,7 @@
<include src="../screen_signin_fatal_error.html">
<include src="../parental_handoff.html">
<include src="../screen_app_launch_splash.html">
<include src="../oobe_screen_autolaunch.html">
<include src="components_[OOBE].html">
......
......@@ -53,6 +53,7 @@ function loadCommonComponents() {
// <include src="../screen_signin_fatal_error.js">
// <include src="../parental_handoff.js">
// <include src="../screen_app_launch_splash.js">
// <include src="../oobe_screen_autolaunch.js">
// <include src="components_[OOBE].js">
// TODO(crbug.com/1111387) - Remove excessive logging.
......
......@@ -4,7 +4,8 @@
<!-- Screens that can appear both in OOBE and Login modes. -->
<oobe-reset-element id="reset" class="step" hidden></oobe-reset-element>
<include src="../oobe_screen_autolaunch.html">
<autolaunch-element id="autolaunch" class="step hidden" hidden>
</autolaunch-element>
<oobe-adb-sideloading-element id="adb-sideloading" class="step hidden" hidden>
</oobe-adb-sideloading-element>
<kiosk-enable-element id="kiosk-enable" class="step hidden" hidden>
......
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