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

Side by Side Diff: chrome/browser/notifications/message_center_notifications_browsertest.cc

Issue 19027005: Hide notifications popups when entering fullscreen mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ChromeOS support. Created 7 years, 5 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/notifications/message_center_notification_manager.h" 15 #include "chrome/browser/notifications/message_center_notification_manager.h"
15 #include "chrome/browser/notifications/notification.h" 16 #include "chrome/browser/notifications/notification.h"
16 #include "chrome/browser/notifications/notification_ui_manager.h" 17 #include "chrome/browser/notifications/notification_ui_manager.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
19 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
21 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_source.h"
20 #include "ui/message_center/message_center.h" 24 #include "ui/message_center/message_center.h"
21 #include "ui/message_center/message_center_switches.h" 25 #include "ui/message_center/message_center_switches.h"
22 #include "ui/message_center/message_center_util.h" 26 #include "ui/message_center/message_center_util.h"
23 27
24 class TestAddObserver : public message_center::MessageCenterObserver { 28 class TestAddObserver : public message_center::MessageCenterObserver {
25 public: 29 public:
26 TestAddObserver(const std::string& id, 30 TestAddObserver(const std::string& id,
27 message_center::MessageCenter* message_center) 31 message_center::MessageCenter* message_center)
28 : id_(id), message_center_(message_center) { 32 : id_(id), message_center_(message_center) {
29 quit_closure_ = run_loop_.QuitClosure(); 33 quit_closure_ = run_loop_.QuitClosure();
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 256
253 message_center()->SetMessageCenterVisible(false); 257 message_center()->SetMessageCenterVisible(false);
254 observer.Run(); 258 observer.Run();
255 259
256 EXPECT_EQ("_n_n2", observer.log()); 260 EXPECT_EQ("_n_n2", observer.log());
257 261
258 delegate->Release(); 262 delegate->Release();
259 delegate2->Release(); 263 delegate2->Release();
260 } 264 }
261 265
266 // MessaceCenter-specific test.
267 #if defined(RUN_MESSAGE_CENTER_TESTS)
268 #define MAYBE_HideWhenFullscreenEnabled HideWhenFullscreenEnabled
269 #else
270 #define MAYBE_HideWhenFullscreenEnabled DISABLED_HideWhenFullscreenEnabled
271 #endif
272
273 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
274 MAYBE_HideWhenFullscreenEnabled) {
275 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter());
276
277 TestDelegate* delegate;
278 manager()->Add(CreateTestNotification("n", &delegate), profile());
279
280 EXPECT_EQ("Display_", delegate->log());
281 EXPECT_TRUE(message_center()->HasPopupNotifications());
282 bool is_fullscreen = true;
283 // Cast so that Observe() is public.
284 content::NotificationObserver* observer =
285 static_cast<content::NotificationObserver*>(manager());
286 observer->Observe(chrome::NOTIFICATION_FULLSCREEN_CHANGED,
287 content::Source<Profile>(profile()),
288 content::Details<bool>(&is_fullscreen));
289 EXPECT_FALSE(message_center()->HasPopupNotifications());
290 }
291
262 #endif // !defined(OS_MACOSX) 292 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698