Commit d6554e1c authored by Andre Le's avatar Andre Le Committed by Commit Bot

ash: Enable notification in OOBE to display system notification.

BUG=1093614

Change-Id: Ie5a368ff723970b10527d9249f6bc490d7ba1b4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261852Reviewed-by: default avatarTim Song <tengs@chromium.org>
Commit-Queue: Tim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782698}
parent b0584531
...@@ -26,6 +26,10 @@ bool CalculateShouldShowPopup() { ...@@ -26,6 +26,10 @@ bool CalculateShouldShowPopup() {
SessionControllerImpl* const session_controller = SessionControllerImpl* const session_controller =
Shell::Get()->session_controller(); Shell::Get()->session_controller();
// Enable popup in OOBE to display system notifications (wifi, etc.).
if (session_controller->GetSessionState() == SessionState::OOBE)
return true;
if (session_controller->IsRunningInAppMode() || if (session_controller->IsRunningInAppMode() ||
session_controller->GetSessionState() != SessionState::ACTIVE) { session_controller->GetSessionState() != SessionState::ACTIVE) {
return false; return false;
......
...@@ -81,14 +81,16 @@ class SessionStateNotificationBlockerTest ...@@ -81,14 +81,16 @@ class SessionStateNotificationBlockerTest
}; };
TEST_F(SessionStateNotificationBlockerTest, BaseTest) { TEST_F(SessionStateNotificationBlockerTest, BaseTest) {
// Default status: OOBE. // OOBE.
GetSessionControllerClient()->SetSessionState(SessionState::OOBE);
EXPECT_EQ(1, GetStateChangedCountAndReset());
message_center::NotifierId notifier_id( message_center::NotifierId notifier_id(
message_center::NotifierType::APPLICATION, "test-notifier"); message_center::NotifierType::APPLICATION, "test-notifier");
EXPECT_FALSE(ShouldShowNotificationAsPopup(notifier_id)); EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id));
// Login screen. // Login screen.
GetSessionControllerClient()->SetSessionState(SessionState::LOGIN_PRIMARY); GetSessionControllerClient()->SetSessionState(SessionState::LOGIN_PRIMARY);
EXPECT_EQ(0, GetStateChangedCountAndReset()); EXPECT_EQ(1, GetStateChangedCountAndReset());
EXPECT_FALSE(ShouldShowNotificationAsPopup(notifier_id)); EXPECT_FALSE(ShouldShowNotificationAsPopup(notifier_id));
// Logged in as a normal user. // Logged in as a normal user.
...@@ -112,12 +114,14 @@ TEST_F(SessionStateNotificationBlockerTest, AlwaysAllowedNotifier) { ...@@ -112,12 +114,14 @@ TEST_F(SessionStateNotificationBlockerTest, AlwaysAllowedNotifier) {
message_center::NotifierId notifier_id( message_center::NotifierId notifier_id(
message_center::NotifierType::SYSTEM_COMPONENT, kNotifierSystemPriority); message_center::NotifierType::SYSTEM_COMPONENT, kNotifierSystemPriority);
// Default status: OOBE. // OOBE.
GetSessionControllerClient()->SetSessionState(SessionState::OOBE);
EXPECT_EQ(1, GetStateChangedCountAndReset());
EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id));
// Login screen. // Login screen.
GetSessionControllerClient()->SetSessionState(SessionState::LOGIN_PRIMARY); GetSessionControllerClient()->SetSessionState(SessionState::LOGIN_PRIMARY);
EXPECT_EQ(0, GetStateChangedCountAndReset()); EXPECT_EQ(1, GetStateChangedCountAndReset());
EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id));
// Logged in as a normal user. // Logged in as a normal user.
...@@ -137,14 +141,16 @@ TEST_F(SessionStateNotificationBlockerTest, AlwaysAllowedNotifier) { ...@@ -137,14 +141,16 @@ TEST_F(SessionStateNotificationBlockerTest, AlwaysAllowedNotifier) {
} }
TEST_F(SessionStateNotificationBlockerTest, BlockOnPrefService) { TEST_F(SessionStateNotificationBlockerTest, BlockOnPrefService) {
// Default status: OOBE. // OOBE.
GetSessionControllerClient()->SetSessionState(SessionState::OOBE);
EXPECT_EQ(1, GetStateChangedCountAndReset());
message_center::NotifierId notifier_id( message_center::NotifierId notifier_id(
message_center::NotifierType::APPLICATION, "test-notifier"); message_center::NotifierType::APPLICATION, "test-notifier");
EXPECT_FALSE(ShouldShowNotificationAsPopup(notifier_id)); EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id));
// Login screen. // Login screen.
GetSessionControllerClient()->SetSessionState(SessionState::LOGIN_PRIMARY); GetSessionControllerClient()->SetSessionState(SessionState::LOGIN_PRIMARY);
EXPECT_EQ(0, GetStateChangedCountAndReset()); EXPECT_EQ(1, GetStateChangedCountAndReset());
EXPECT_FALSE(ShouldShowNotificationAsPopup(notifier_id)); EXPECT_FALSE(ShouldShowNotificationAsPopup(notifier_id));
// Simulates login event sequence in production code: // Simulates login event sequence in production code:
......
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