OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/common/system/system_notifier.h" | 5 #include "ash/common/system/system_notifier.h" |
6 #include "ash/shell.h" | 6 #include "ash/shell.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/chromeos/login/login_manager_test.h" | 10 #include "chrome/browser/chromeos/login/login_manager_test.h" |
10 #include "chrome/browser/chromeos/login/startup_utils.h" | 11 #include "chrome/browser/chromeos/login/startup_utils.h" |
11 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 12 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
12 #include "chrome/browser/notifications/login_state_notification_blocker_chromeos
.h" | 13 #include "chrome/browser/notifications/login_state_notification_blocker_chromeos
.h" |
13 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
14 #include "ui/message_center/message_center.h" | 15 #include "ui/message_center/message_center.h" |
15 | 16 |
| 17 using base::UTF8ToUTF16; |
16 using namespace testing; | 18 using namespace testing; |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 const char* kTestUsers[] = {"test-user@gmail.com", | 22 const char* kTestUsers[] = {"test-user@gmail.com", |
21 "test-user1@gmail.com"}; | 23 "test-user1@gmail.com"}; |
22 | 24 |
23 class UserAddingFinishObserver : public chromeos::UserAddingScreen::Observer { | 25 class UserAddingFinishObserver : public chromeos::UserAddingScreen::Observer { |
24 public: | 26 public: |
25 UserAddingFinishObserver() { | 27 UserAddingFinishObserver() { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 91 } |
90 | 92 |
91 int GetStateChangedCountAndReset() { | 93 int GetStateChangedCountAndReset() { |
92 int result = state_changed_count_; | 94 int result = state_changed_count_; |
93 state_changed_count_ = 0; | 95 state_changed_count_ = 0; |
94 return result; | 96 return result; |
95 } | 97 } |
96 | 98 |
97 bool ShouldShowNotificationAsPopup( | 99 bool ShouldShowNotificationAsPopup( |
98 const message_center::NotifierId& notifier_id) { | 100 const message_center::NotifierId& notifier_id) { |
99 return blocker_->ShouldShowNotificationAsPopup(notifier_id); | 101 message_center::Notification notification( |
| 102 message_center::NOTIFICATION_TYPE_SIMPLE, "browser-id", |
| 103 UTF8ToUTF16("browser-title"), UTF8ToUTF16("browser-message"), |
| 104 gfx::Image(), UTF8ToUTF16("browser-source"), GURL(), |
| 105 notifier_id, message_center::RichNotificationData(), NULL); |
| 106 return blocker_->ShouldShowNotificationAsPopup(notification); |
100 } | 107 } |
101 | 108 |
102 private: | 109 private: |
103 int state_changed_count_; | 110 int state_changed_count_; |
104 std::unique_ptr<message_center::NotificationBlocker> blocker_; | 111 std::unique_ptr<message_center::NotificationBlocker> blocker_; |
105 | 112 |
106 DISALLOW_COPY_AND_ASSIGN(LoginStateNotificationBlockerChromeOSBrowserTest); | 113 DISALLOW_COPY_AND_ASSIGN(LoginStateNotificationBlockerChromeOSBrowserTest); |
107 }; | 114 }; |
108 | 115 |
109 IN_PROC_BROWSER_TEST_F(LoginStateNotificationBlockerChromeOSBrowserTest, | 116 IN_PROC_BROWSER_TEST_F(LoginStateNotificationBlockerChromeOSBrowserTest, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 EXPECT_EQ(1, GetStateChangedCountAndReset()); | 174 EXPECT_EQ(1, GetStateChangedCountAndReset()); |
168 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); | 175 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); |
169 | 176 |
170 // Multi-login user switch off. | 177 // Multi-login user switch off. |
171 chromeos::UserAddingScreen::Get()->Cancel(); | 178 chromeos::UserAddingScreen::Get()->Cancel(); |
172 observer.WaitUntilUserAddingFinishedOrCancelled(); | 179 observer.WaitUntilUserAddingFinishedOrCancelled(); |
173 content::RunAllPendingInMessageLoop(); | 180 content::RunAllPendingInMessageLoop(); |
174 EXPECT_EQ(1, GetStateChangedCountAndReset()); | 181 EXPECT_EQ(1, GetStateChangedCountAndReset()); |
175 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); | 182 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); |
176 } | 183 } |
OLD | NEW |