Commit 26090862 authored by Ossama Mahmoud's avatar Ossama Mahmoud Committed by Commit Bot

Fix shelf buttons order in RebootOnShutdown policy

Previously, on the login screen in kiosk mode, the shutdown button is
to the left of the Apps button. But when DeviceRebootOnShutdown
policy is turned on, the restart button is to the right of the Apps
button.

To make the order more consistent, now both shutdown and restart
buttons are to the left of the Apps button.

R=antrim@chromium.org, rsorokin@chromium.org

Bug: 1113244
Change-Id: I410f8122cd5c5024d2f8f558d842fdf5124a97e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2387055
Commit-Queue: Ossama Mahmoud <osamafathy@google.com>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805395}
parent 5f16dae4
......@@ -485,11 +485,11 @@ LoginShelfView::LoginShelfView(
};
add_button(kShutdown, IDS_ASH_SHELF_SHUTDOWN_BUTTON,
kShelfShutdownButtonIcon);
add_button(kRestart, IDS_ASH_SHELF_RESTART_BUTTON, kShelfShutdownButtonIcon);
add_button(kSignOut, IDS_ASH_SHELF_SIGN_OUT_BUTTON, kShelfSignOutButtonIcon);
kiosk_apps_button_ = new KioskAppsButton();
kiosk_apps_button_->SetID(kApps);
AddChildView(kiosk_apps_button_);
add_button(kRestart, IDS_ASH_SHELF_RESTART_BUTTON, kShelfShutdownButtonIcon);
add_button(kSignOut, IDS_ASH_SHELF_SIGN_OUT_BUTTON, kShelfSignOutButtonIcon);
add_button(kCloseNote, IDS_ASH_SHELF_UNLOCK_BUTTON, kShelfUnlockButtonIcon);
add_button(kCancel, IDS_ASH_SHELF_CANCEL_BUTTON, kShelfCancelButtonIcon);
add_button(kBrowseAsGuest, IDS_ASH_BROWSE_AS_GUEST_BUTTON,
......
......@@ -130,6 +130,14 @@ class LoginShelfViewTest : public LoginTestBase {
return visible_buttons == ids.size();
}
// Check if the former button is shown before the latter button
bool AreButtonsInOrder(LoginShelfView::ButtonId former, LoginShelfView::ButtonId latter){
auto* former_button_view = login_shelf_view_->GetViewByID(former);
auto* latter_button_view = login_shelf_view_->GetViewByID(latter);
EXPECT_TRUE(former_button_view->GetVisible() && latter_button_view->GetVisible());
return login_shelf_view_->GetIndexOf(former_button_view) < login_shelf_view_->GetIndexOf(latter_button_view);
}
// Check whether the button is enabled.
bool IsButtonEnabled(LoginShelfView::ButtonId id) {
return login_shelf_view_->GetViewByID(id)->GetEnabled();
......@@ -205,10 +213,14 @@ TEST_F(LoginShelfViewTest,
NotifyShutdownPolicyChanged(true /*reboot_on_shutdown*/);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kRestart, LoginShelfView::kSignOut}));
EXPECT_TRUE(
AreButtonsInOrder(LoginShelfView::kRestart, LoginShelfView::kSignOut));
NotifyShutdownPolicyChanged(false /*reboot_on_shutdown*/);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
EXPECT_TRUE(
AreButtonsInOrder(LoginShelfView::kShutdown, LoginShelfView::kSignOut));
}
// Checks shutdown policy change during another session state (e.g. ACTIVE)
......@@ -223,6 +235,30 @@ TEST_F(LoginShelfViewTest, ShouldUpdateUiBasedOnShutdownPolicyInActiveSession) {
NotifySessionStateChanged(SessionState::LOCKED);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kRestart, LoginShelfView::kSignOut}));
EXPECT_TRUE(
AreButtonsInOrder(LoginShelfView::kRestart, LoginShelfView::kSignOut));
}
// Checks that the shutdown or restart buttons shown before the Apps button when
// kiosk mode is enabled at GAIA_SIGNIN state
TEST_F(LoginShelfViewTest, ShouldShowShutdownOrRestartButtonsBeforeApps){
NotifySessionStateChanged(SessionState::LOGIN_PRIMARY);
std::vector<KioskAppMenuEntry> kiosk_apps(1);
login_shelf_view_->SetKioskApps(kiosk_apps, {}, {});
login_shelf_view_->SetLoginDialogState(OobeDialogState::GAIA_SIGNIN);
// |reboot_on_shutdown| is initially off
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kApps}));
EXPECT_TRUE(
AreButtonsInOrder(LoginShelfView::kShutdown, LoginShelfView::kApps));
NotifyShutdownPolicyChanged(true /*reboot_on_shutdown*/);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kRestart, LoginShelfView::kApps}));
EXPECT_TRUE(
AreButtonsInOrder(LoginShelfView::kRestart, LoginShelfView::kApps));
}
// Checks the login shelf updates UI after lock screen note state changes.
......@@ -283,6 +319,8 @@ TEST_F(LoginShelfViewTest, ShouldUpdateUiAfterKioskAppsLoaded) {
EXPECT_TRUE(ShowsShelfButtons(
{LoginShelfView::kShutdown, LoginShelfView::kBrowseAsGuest,
LoginShelfView::kAddUser, LoginShelfView::kApps}));
EXPECT_TRUE(
AreButtonsInOrder(LoginShelfView::kShutdown, LoginShelfView::kApps));
login_shelf_view_->SetKioskApps({}, {}, {});
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown,
......@@ -363,16 +401,22 @@ TEST_F(LoginShelfViewTest, ShouldUpdateUiAfterDialogStateChange) {
login_shelf_view_->SetKioskApps(kiosk_apps, {}, {});
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kApps}));
EXPECT_TRUE(
AreButtonsInOrder(LoginShelfView::kShutdown, LoginShelfView::kApps));
login_shelf_view_->SetLoginDialogState(
OobeDialogState::SAML_PASSWORD_CONFIRM);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kApps}));
EXPECT_TRUE(
AreButtonsInOrder(LoginShelfView::kShutdown, LoginShelfView::kApps));
login_shelf_view_->SetLoginDialogState(OobeDialogState::HIDDEN);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kAddUser,
LoginShelfView::kApps}));
EXPECT_TRUE(
AreButtonsInOrder(LoginShelfView::kShutdown, LoginShelfView::kApps));
// Kiosk app button is hidden when no app exists.
login_shelf_view_->SetKioskApps({}, {}, {});
......
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