Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos_unittest.cc

Issue 2198363002: Pass Notification into NotificationBlocker ShouldShow* methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ash build errors Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/wm_shell.h" 6 #include "ash/common/wm_shell.h"
7 #include "ash/test/ash_test_base.h" 7 #include "ash/test/ash_test_base.h"
8 #include "ash/test/ash_test_helper.h" 8 #include "ash/test/ash_test_helper.h"
9 #include "ash/test/test_session_state_delegate.h" 9 #include "ash/test/test_session_state_delegate.h"
10 #include "ash/test/test_shell_delegate.h" 10 #include "ash/test/test_shell_delegate.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 13 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
13 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 14 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
14 #include "chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chrom eos.h" 15 #include "chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chrom eos.h"
15 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" 16 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
16 #include "chrome/test/base/testing_browser_process.h" 17 #include "chrome/test/base/testing_browser_process.h"
17 #include "chrome/test/base/testing_profile_manager.h" 18 #include "chrome/test/base/testing_profile_manager.h"
18 #include "components/signin/core/account_id/account_id.h" 19 #include "components/signin/core/account_id/account_id.h"
19 #include "components/user_manager/fake_user_manager.h" 20 #include "components/user_manager/fake_user_manager.h"
20 #include "components/user_manager/user_info.h" 21 #include "components/user_manager/user_info.h"
21 #include "ui/message_center/message_center.h" 22 #include "ui/message_center/message_center.h"
22 #include "ui/message_center/notification.h" 23 #include "ui/message_center/notification.h"
23 24
25 using base::UTF8ToUTF16;
26
24 class MultiUserNotificationBlockerChromeOSTest 27 class MultiUserNotificationBlockerChromeOSTest
25 : public ash::test::AshTestBase, 28 : public ash::test::AshTestBase,
26 public message_center::NotificationBlocker::Observer { 29 public message_center::NotificationBlocker::Observer {
27 public: 30 public:
28 MultiUserNotificationBlockerChromeOSTest() 31 MultiUserNotificationBlockerChromeOSTest()
29 : state_changed_count_(0), 32 : state_changed_count_(0),
30 testing_profile_manager_(TestingBrowserProcess::GetGlobal()), 33 testing_profile_manager_(TestingBrowserProcess::GetGlobal()),
31 window_id_(0), 34 window_id_(0),
32 fake_user_manager_(new user_manager::FakeUserManager), 35 fake_user_manager_(new user_manager::FakeUserManager),
33 user_manager_enabler_(fake_user_manager_) {} 36 user_manager_enabler_(fake_user_manager_) {}
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 int result = state_changed_count_; 112 int result = state_changed_count_;
110 state_changed_count_ = 0; 113 state_changed_count_ = 0;
111 return result; 114 return result;
112 } 115 }
113 116
114 bool ShouldShowNotificationAsPopup( 117 bool ShouldShowNotificationAsPopup(
115 const message_center::NotifierId& notifier_id, 118 const message_center::NotifierId& notifier_id,
116 const std::string profile_id) { 119 const std::string profile_id) {
117 message_center::NotifierId id_with_profile = notifier_id; 120 message_center::NotifierId id_with_profile = notifier_id;
118 id_with_profile.profile_id = profile_id; 121 id_with_profile.profile_id = profile_id;
119 return blocker()->ShouldShowNotificationAsPopup(id_with_profile); 122
123 message_center::Notification notification(
124 message_center::NOTIFICATION_TYPE_SIMPLE, "popup-id",
125 UTF8ToUTF16("popup-title"), UTF8ToUTF16("popup-message"), gfx::Image(),
126 UTF8ToUTF16("popup-source"), GURL(), id_with_profile,
127 message_center::RichNotificationData(), NULL);
128
129 return blocker()->ShouldShowNotificationAsPopup(notification);
120 } 130 }
121 131
122 bool ShouldShowNotification( 132 bool ShouldShowNotification(
123 const message_center::NotifierId& notifier_id, 133 const message_center::NotifierId& notifier_id,
124 const std::string profile_id) { 134 const std::string profile_id) {
125 message_center::NotifierId id_with_profile = notifier_id; 135 message_center::NotifierId id_with_profile = notifier_id;
126 id_with_profile.profile_id = profile_id; 136 id_with_profile.profile_id = profile_id;
127 return blocker()->ShouldShowNotification(id_with_profile); 137
138 message_center::Notification notification(
139 message_center::NOTIFICATION_TYPE_SIMPLE, "notification-id",
140 UTF8ToUTF16("notification-title"), UTF8ToUTF16("notification-message"),
141 gfx::Image(), UTF8ToUTF16("notification-source"), GURL(),
142 id_with_profile, message_center::RichNotificationData(), NULL);
143
144 return blocker()->ShouldShowNotification(notification);
128 } 145 }
129 146
130 aura::Window* CreateWindowForProfile(const std::string& name) { 147 aura::Window* CreateWindowForProfile(const std::string& name) {
131 aura::Window* window = CreateTestWindowInShellWithId(window_id_++); 148 aura::Window* window = CreateTestWindowInShellWithId(window_id_++);
132 chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner( 149 chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner(
133 window, AccountId::FromUserEmail(name)); 150 window, AccountId::FromUserEmail(name));
134 return window; 151 return window;
135 } 152 }
136 153
137 private: 154 private:
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 EXPECT_FALSE(ShouldShowNotification(notifier_id, "")); 242 EXPECT_FALSE(ShouldShowNotification(notifier_id, ""));
226 EXPECT_TRUE(ShouldShowNotification(ash_system_notifier, "")); 243 EXPECT_TRUE(ShouldShowNotification(ash_system_notifier, ""));
227 EXPECT_FALSE(ShouldShowNotification(random_system_notifier, "")); 244 EXPECT_FALSE(ShouldShowNotification(random_system_notifier, ""));
228 EXPECT_TRUE(ShouldShowNotification(notifier_id, GetDefaultUserId())); 245 EXPECT_TRUE(ShouldShowNotification(notifier_id, GetDefaultUserId()));
229 EXPECT_FALSE(ShouldShowNotification(notifier_id, "test2@example.com")); 246 EXPECT_FALSE(ShouldShowNotification(notifier_id, "test2@example.com"));
230 EXPECT_TRUE(ShouldShowNotification(random_system_notifier, 247 EXPECT_TRUE(ShouldShowNotification(random_system_notifier,
231 GetDefaultUserId())); 248 GetDefaultUserId()));
232 EXPECT_FALSE(ShouldShowNotification(random_system_notifier, 249 EXPECT_FALSE(ShouldShowNotification(random_system_notifier,
233 "test2@example.com")); 250 "test2@example.com"));
234 } 251 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698