Commit baafbcac authored by Yunke Zhou's avatar Yunke Zhou Committed by Commit Bot

oobe update screen: refactor to use LoginScreenBehavior

Bug: 1090331
Change-Id: Ic0489afae9948ead9817ae41b44b796c1201168f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2230462Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Commit-Queue: Yunke Zhou <yunkez@google.com>
Cr-Commit-Position: refs/heads/master@{#776068}
parent 16cf5769
......@@ -40,19 +40,25 @@ namespace chromeos {
namespace {
const char kStubWifiGuid[] = "wlan0";
const std::initializer_list<base::StringPiece> kCheckingForUpdatesDialogPath = {
"oobe-update-md", "checking-downloading-update",
"checking-for-updates-dialog"};
const std::initializer_list<base::StringPiece> kUpdatingDialogPath = {
"oobe-update-md", "checking-downloading-update", "updating-dialog"};
const std::initializer_list<base::StringPiece> kUpdatingProgressPath = {
"oobe-update-md", "checking-downloading-update", "updating-progress"};
const std::initializer_list<base::StringPiece> kProgressMessagePath = {
"oobe-update-md", "checking-downloading-update", "progress-message"};
const std::initializer_list<base::StringPiece> kUpdateCompletedDialog = {
"oobe-update-md", "checking-downloading-update", "update-complete-dialog"};
const std::initializer_list<base::StringPiece> kCellularPermissionDialog = {
"oobe-update-md", "cellular-permission-dialog"};
const test::UIPath kCheckingDownloadingUpdate = {"oobe-update",
"checking-downloading-update"};
const test::UIPath kCheckingForUpdatesDialog = {"oobe-update",
"checking-downloading-update",
"checking-for-updates-dialog"};
const test::UIPath kUpdatingDialog = {
"oobe-update", "checking-downloading-update", "updating-dialog"};
const test::UIPath kUpdatingProgress = {
"oobe-update", "checking-downloading-update", "updating-progress"};
const test::UIPath kProgressMessage = {
"oobe-update", "checking-downloading-update", "progress-message"};
const test::UIPath kUpdateCompletedDialog = {
"oobe-update", "checking-downloading-update", "update-complete-dialog"};
const test::UIPath kCellularPermissionDialog = {"oobe-update",
"cellular-permission-dialog"};
const test::UIPath kCellularPermissionNext = {"oobe-update",
"cellular-permission-next"};
const test::UIPath kCellularPermissionBack = {"oobe-update",
"cellular-permission-back"};
// These values should be kept in sync with the progress bar values in
// chrome/browser/chromeos/login/version_updater/version_updater.cc.
......@@ -167,12 +173,11 @@ void UpdateScreenTest::CheckPathVisiblity(
void UpdateScreenTest::CheckUpdatingDialogComponents(
const int updating_progress_value,
const std::string& progress_message_value) {
CheckPathVisiblity(kUpdatingDialogPath, true);
CheckPathVisiblity(kUpdatingDialog, true);
test::OobeJS().ExpectEQ(
test::GetOobeElementPath(kUpdatingProgressPath) + ".value",
test::GetOobeElementPath(kUpdatingProgress) + ".value",
updating_progress_value);
test::OobeJS().ExpectElementText(progress_message_value,
kProgressMessagePath);
test::OobeJS().ExpectElementText(progress_message_value, kProgressMessage);
}
IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateCheckDoneBeforeShow) {
......@@ -229,10 +234,10 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateNotFoundAfterScreenShow) {
update_screen_waiter.set_assert_next_screen();
update_screen_waiter.Wait();
test::OobeJS().ExpectVisible("oobe-update-md");
test::OobeJS().ExpectVisiblePath(kCheckingForUpdatesDialogPath);
test::OobeJS().ExpectVisible("oobe-update");
test::OobeJS().ExpectVisiblePath(kCheckingForUpdatesDialog);
test::OobeJS().ExpectHiddenPath(kCellularPermissionDialog);
test::OobeJS().ExpectHiddenPath(kUpdatingDialogPath);
test::OobeJS().ExpectHiddenPath(kUpdatingDialog);
status.set_current_operation(update_engine::Operation::IDLE);
// GetLastStatus() will be called via ExitUpdate() called from
......@@ -265,9 +270,9 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateAvailable) {
update_screen_waiter.set_assert_next_screen();
update_screen_waiter.Wait();
test::OobeJS().ExpectVisible("oobe-update-md");
test::OobeJS().ExpectVisiblePath(kCheckingForUpdatesDialogPath);
test::OobeJS().ExpectHiddenPath(kUpdatingDialogPath);
test::OobeJS().ExpectVisible("oobe-update");
test::OobeJS().ExpectVisiblePath(kCheckingForUpdatesDialog);
test::OobeJS().ExpectHiddenPath(kUpdatingDialog);
test::OobeJS().ExpectHiddenPath(kCellularPermissionDialog);
test::OobeJS().ExpectHiddenPath(kUpdateCompletedDialog);
......@@ -281,8 +286,8 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateAvailable) {
update_engine_client()->set_default_status(status);
update_engine_client()->NotifyObserversThatStatusChanged(status);
test::OobeJS().CreateVisibilityWaiter(true, kUpdatingDialogPath)->Wait();
test::OobeJS().ExpectHiddenPath(kCheckingForUpdatesDialogPath);
test::OobeJS().CreateVisibilityWaiter(true, kUpdatingDialog)->Wait();
test::OobeJS().ExpectHiddenPath(kCheckingForUpdatesDialog);
test::OobeJS().ExpectHiddenPath(kCellularPermissionDialog);
test::OobeJS().ExpectHiddenPath(kUpdateCompletedDialog);
......@@ -364,7 +369,7 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateAvailable) {
ASSERT_TRUE(version_updater_->GetRebootTimerForTesting()->IsRunning());
version_updater_->GetRebootTimerForTesting()->FireNow();
test::OobeJS().ExpectHiddenPath(kUpdatingDialogPath);
test::OobeJS().ExpectHiddenPath(kUpdatingDialog);
test::OobeJS().ExpectVisiblePath(kUpdateCompletedDialog);
}
......@@ -454,10 +459,10 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestTemporaryPortalNetwork) {
update_screen_waiter.set_assert_next_screen();
update_screen_waiter.Wait();
test::OobeJS().ExpectVisible("oobe-update-md");
test::OobeJS().ExpectVisiblePath(kCheckingForUpdatesDialogPath);
test::OobeJS().ExpectVisible("oobe-update");
test::OobeJS().ExpectVisiblePath(kCheckingForUpdatesDialog);
test::OobeJS().ExpectHiddenPath(kCellularPermissionDialog);
test::OobeJS().ExpectHiddenPath(kUpdatingDialogPath);
test::OobeJS().ExpectHiddenPath(kUpdatingDialog);
status.set_current_operation(update_engine::Operation::IDLE);
update_engine_client()->set_default_status(status);
......@@ -597,21 +602,19 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, UpdateOverCellularAccepted) {
update_screen_waiter.set_assert_next_screen();
update_screen_waiter.Wait();
test::OobeJS().ExpectVisible("oobe-update-md");
test::OobeJS().ExpectVisible("oobe-update");
test::OobeJS().ExpectVisiblePath(kCellularPermissionDialog);
test::OobeJS().ExpectHiddenPath(
{"oobe-update-md", "checking-downloading-update"});
test::OobeJS().ExpectHiddenPath(kCheckingDownloadingUpdate);
test::OobeJS().TapOnPath({"oobe-update-md", "cellular-permission-next"});
test::OobeJS().TapOnPath(kCellularPermissionNext);
test::OobeJS()
.CreateVisibilityWaiter(true,
{"oobe-update-md", "checking-downloading-update"})
.CreateVisibilityWaiter(true, kCheckingDownloadingUpdate)
->Wait();
test::OobeJS().ExpectHiddenPath(kCellularPermissionDialog);
test::OobeJS().ExpectHiddenPath(kCheckingForUpdatesDialogPath);
test::OobeJS().ExpectVisiblePath(kUpdatingDialogPath);
test::OobeJS().ExpectHiddenPath(kCheckingForUpdatesDialog);
test::OobeJS().ExpectVisiblePath(kUpdatingDialog);
status.set_current_operation(update_engine::Operation::UPDATED_NEED_REBOOT);
version_updater_->UpdateStatusChangedForTesting(status);
......@@ -642,12 +645,11 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, UpdateOverCellularRejected) {
update_screen_waiter.set_assert_next_screen();
update_screen_waiter.Wait();
test::OobeJS().ExpectVisible("oobe-update-md");
test::OobeJS().ExpectVisible("oobe-update");
test::OobeJS().ExpectVisiblePath(kCellularPermissionDialog);
test::OobeJS().ExpectHiddenPath(
{"oobe-update-md", "checking-downloading-update"});
test::OobeJS().ExpectHiddenPath(kCheckingDownloadingUpdate);
test::OobeJS().ClickOnPath({"oobe-update-md", "cellular-permission-back"});
test::OobeJS().ClickOnPath(kCellularPermissionBack);
WaitForScreenResult();
EXPECT_EQ(UpdateScreen::Result::UPDATE_ERROR, last_screen_result_.value());
......
......@@ -65,7 +65,7 @@ void TapNetworkSelectionNext() {
void WaitForUpdateScreen() {
WaitFor(UpdateView::kScreenId);
test::OobeJS().CreateVisibilityWaiter(true, {"update"})->Wait();
test::OobeJS().CreateVisibilityWaiter(true, {"oobe-update"})->Wait();
}
void ExitUpdateScreenNoUpdate() {
......
......@@ -238,6 +238,7 @@ js_library("oobe_supervision_transition") {
js_library("oobe_update") {
deps = [
"components:login_screen_behavior",
"components:oobe_dialog_host_behavior",
"components:oobe_i18n_behavior",
]
......
......@@ -134,8 +134,22 @@ cr.define('cr.ui.login.debug', function() {
suffix: 'demo',
},
{
id: 'update',
id: 'oobe-update',
kind: ScreenKind.NORMAL,
states: [
{
// Checking for update
id: 'check-update',
},
{
// Ask for permission to update over celluar
id: 'require-permission-celluar',
trigger: (screen) => {
screen.onBeforeShow();
screen.setRequiresPermissionForCellular(true);
},
},
]
},
{
id: 'auto-enrollment-check',
......
......@@ -43,7 +43,6 @@
// <include src="oobe_screen_eula.js">
// <include src="oobe_screen_network.js">
// <include src="oobe_screen_oauth_enrollment.js">
// <include src="oobe_screen_update.js">
// <include src="multi_tap_detector.js">
// <include src="web_view_helper.js">
......@@ -58,7 +57,6 @@ cr.define('cr.ui.Oobe', function() {
login.WrongHWIDScreen.register();
login.NetworkScreen.register();
login.EulaScreen.register();
login.UpdateScreen.register();
login.AutoEnrollmentCheckScreen.register();
login.EnableDebuggingScreen.register();
login.AutolaunchScreen.register();
......
<div class="step right hidden animated" id="update" role="group"
i18n-values="aria-label:updateScreenAccessibleTitle" hidden>
<oobe-update-md id="oobe-update-md"></oobe-update-md>
</div>
// Copyright (c) 2012 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.
/**
* @fileoverview Oobe update screen implementation.
*/
login.createScreen('UpdateScreen', 'update', function() {
var USER_ACTION_CANCEL_UPDATE_SHORTCUT = 'cancel-update';
return {
EXTERNAL_API: [
'setEstimatedTimeLeft',
'showEstimatedTimeLeft',
'setUpdateCompleted',
'showUpdateCurtain',
'setProgressMessage',
'setUpdateProgress',
'setRequiresPermissionForCellular',
'setCancelUpdateShortcutEnabled',
],
/** @param {boolean} enabled */
setCancelUpdateShortcutEnabled(enabled) {
$('oobe-update-md').cancelAllowed = enabled;
},
/**
* Returns default event target element.
* @type {Object}
*/
get defaultControl() {
return $('oobe-update-md');
},
/**
* Cancels the screen.
*/
cancel() {
$('oobe-update-md').cancelHint = 'cancelledUpdateMessage';
this.send(
login.Screen.CALLBACK_USER_ACTED, USER_ACTION_CANCEL_UPDATE_SHORTCUT);
},
/**
* Sets update's progress bar value.
* @param {number} progress Percentage of the progress bar.
*/
setUpdateProgress(progress) {
$('oobe-update-md').progressValue = progress;
},
setRequiresPermissionForCellular(requiresPermission) {
$('oobe-update-md').requiresPermissionForCellular = requiresPermission;
},
/**
* Shows or hides downloading ETA message.
* @param {boolean} visible Are ETA message visible?
*/
showEstimatedTimeLeft(visible) {
$('oobe-update-md').estimatedTimeLeftShown = visible;
},
/**
* Sets estimated time left until download will complete.
* @param {number} seconds Time left in seconds.
*/
setEstimatedTimeLeft(seconds) {
$('oobe-update-md').estimatedTimeLeft = seconds;
},
/**
* Sets message below progress bar. Hide the message by setting an empty
* string.
* @param {string} message Message that should be shown.
*/
setProgressMessage(message) {
var visible = !!message;
$('oobe-update-md').progressMessage = message;
$('oobe-update-md').estimatedTimeLeftShown = !visible;
},
/**
* Marks update completed. Shows "update completed" message.
* @param {boolean} is_completed True if update process is completed.
*/
setUpdateCompleted(is_completed) {
$('oobe-update-md').updateCompleted = is_completed;
},
/**
* Shows or hides update curtain.
* @param {boolean} visible Are curtains visible?
*/
showUpdateCurtain(visible) {
$('oobe-update-md').checkingForUpdate = visible;
},
};
});
......@@ -6,12 +6,13 @@
<link rel="import" href="chrome://resources/polymer/v1_0/paper-progress/paper-progress.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
<dom-module id="oobe-update-md">
<dom-module id="oobe-update">
<template>
<style include="oobe-dialog-host"></style>
<link rel="stylesheet" href="oobe_update.css">
<checking-downloading-update id="checking-downloading-update"
full-screen-dialog
aria-label$="[[i18nDynamic(locale, 'updateScreenAccessibleTitle')]]"
hidden="[[requiresPermissionForCellular]]"
checking-for-update="[[checkingForUpdate]]"
cancel-allowed="[[cancelAllowed]]"
......
......@@ -6,10 +6,29 @@
* @fileoverview Polymer element for displaying material design Update screen.
*/
'use strict';
(function() {
const USER_ACTION_ACCEPT_UPDATE_OVER_CELLUAR = 'update-accept-cellular';
const USER_ACTION_REJECT_UPDATE_OVER_CELLUAR = 'update-reject-cellular';
const USER_ACTION_CANCEL_UPDATE_SHORTCUT = 'cancel-update';
Polymer({
is: 'oobe-update-md',
is: 'oobe-update',
behaviors: [OobeI18nBehavior, OobeDialogHostBehavior, LoginScreenBehavior],
behaviors: [OobeI18nBehavior, OobeDialogHostBehavior],
EXTERNAL_API: [
'setEstimatedTimeLeft',
'showEstimatedTimeLeft',
'setUpdateCompleted',
'showUpdateCurtain',
'setProgressMessage',
'setUpdateProgress',
'setRequiresPermissionForCellular',
'setCancelUpdateShortcutEnabled',
],
properties: {
/**
......@@ -85,16 +104,97 @@ Polymer({
},
},
ready() {
this.initializeLoginScreen('UpdateScreen', {
resetAllowed: true,
});
},
/**
* Cancels the screen.
*/
cancel() {
this.cancelHint = 'cancelledUpdateMessage';
this.userActed(USER_ACTION_CANCEL_UPDATE_SHORTCUT);
},
onBeforeShow() {
cr.ui.login.invokePolymerMethod(
this.$['checking-downloading-update'], 'onBeforeShow');
},
onBackClicked_() {
chrome.send('login.UpdateScreen.userActed', ['update-reject-cellular']);
this.userActed(USER_ACTION_REJECT_UPDATE_OVER_CELLUAR);
},
onNextClicked_() {
chrome.send('login.UpdateScreen.userActed', ['update-accept-cellular']);
this.userActed(USER_ACTION_ACCEPT_UPDATE_OVER_CELLUAR);
},
/** @param {boolean} enabled */
setCancelUpdateShortcutEnabled(enabled) {
this.cancelAllowed = enabled;
},
/**
* Sets update's progress bar value.
* @param {number} progress Percentage of the progress bar.
*/
setUpdateProgress(progress) {
this.progressValue = progress;
},
/**
* Shows or hides the warning that asks the user for permission to update
* over celluar.
* @param {boolean} requiresPermission Are the warning visible?
*/
setRequiresPermissionForCellular(requiresPermission) {
this.requiresPermissionForCellular = requiresPermission;
},
/**
* Shows or hides downloading ETA message.
* @param {boolean} visible Are ETA message visible?
*/
showEstimatedTimeLeft(visible) {
this.estimatedTimeLeftShown = visible;
},
/**
* Sets estimated time left until download will complete.
* @param {number} seconds Time left in seconds.
*/
setEstimatedTimeLeft(seconds) {
this.estimatedTimeLeft = seconds;
},
/**
* Sets message below progress bar. Hide the message by setting an empty
* string.
* @param {string} message Message that should be shown.
*/
setProgressMessage(message) {
let visible = !!message;
this.progressMessage = message;
this.estimatedTimeLeftShown = !visible;
},
/**
* Marks update completed. Shows "update completed" message.
* @param {boolean} is_completed True if update process is completed.
*/
setUpdateCompleted(is_completed) {
this.updateCompleted = is_completed;
},
/**
* Shows or hides update curtain.
* @param {boolean} visible Are curtains visible?
*/
showUpdateCurtain(visible) {
this.checkingForUpdate = visible;
},
});
})();
......@@ -14,7 +14,8 @@
<include src="../oobe_screen_demo_setup.html">
<include src="../oobe_screen_network.html">
<include src="../oobe_screen_eula.html">
<include src="../oobe_screen_update.html">
<oobe-update id="oobe-update" class="step right hidden animated" hidden>
</oobe-update>
<include src="../oobe_screen_auto_enrollment_check.html">
<include src="../oobe_screen_demo_preferences.html">
<include src="../oobe_screen_oauth_enrollment.html">
......
......@@ -19,7 +19,7 @@ class UpdateScreen;
// representation. Owned by UpdateScreen.
class UpdateView {
public:
constexpr static StaticOobeScreenId kScreenId{"update"};
constexpr static StaticOobeScreenId kScreenId{"oobe-update"};
virtual ~UpdateView() {}
......
......@@ -139,7 +139,7 @@ TEST_F('OobeWebUITest', 'DISABLED_OobeEula', function() {
// Fails on chromeos, http://crbug.com/665315
TEST_F('OobeWebUITest', 'DISABLED_OobeUpdate', function() {
Oobe.getInstance().showScreen({'id':'update'});
Oobe.getInstance().showScreen({'id':'oobe-update'});
});
// Fails on chromeos, http://crbug.com/665315
......
......@@ -13,7 +13,7 @@
/** @const */ var SCREEN_OOBE_HID_DETECTION = 'hid-detection';
/** @const */ var SCREEN_OOBE_EULA = 'eula';
/** @const */ var SCREEN_OOBE_ENABLE_DEBUGGING = 'debugging';
/** @const */ var SCREEN_OOBE_UPDATE = 'update';
/** @const */ var SCREEN_OOBE_UPDATE = 'oobe-update';
/** @const */ var SCREEN_OOBE_RESET = 'reset';
/** @const */ var SCREEN_OOBE_ENROLLMENT = 'oauth-enrollment';
/** @const */ var SCREEN_OOBE_DEMO_SETUP = 'demo-setup';
......
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