OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/chromeos/notifications/balloon_collection_impl.h" | 13 #include "chrome/browser/chromeos/notifications/balloon_collection_impl.h" |
14 #include "chrome/browser/chromeos/notifications/balloon_view.h" | 14 #include "chrome/browser/chromeos/notifications/balloon_view.h" |
15 #include "chrome/browser/chromeos/notifications/notification_panel.h" | 15 #include "chrome/browser/chromeos/notifications/notification_panel.h" |
16 #include "chrome/browser/chromeos/notifications/system_notification_factory.h" | 16 #include "chrome/browser/chromeos/notifications/system_notification_factory.h" |
17 #include "chrome/browser/notifications/notification_test_util.h" | 17 #include "chrome/browser/notifications/notification_test_util.h" |
18 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" |
19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/test/in_process_browser_test.h" | 21 #include "chrome/test/in_process_browser_test.h" |
21 #include "chrome/test/ui_test_utils.h" | 22 #include "chrome/test/ui_test_utils.h" |
22 #include "content/common/notification_service.h" | 23 #include "content/common/notification_service.h" |
23 #include "ui/base/x/x11_util.h" | 24 #include "ui/base/x/x11_util.h" |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // The name of ChromeOS's window manager. | 28 // The name of ChromeOS's window manager. |
28 const char* kChromeOsWindowManagerName = "chromeos-wm"; | 29 const char* kChromeOsWindowManagerName = "chromeos-wm"; |
29 | 30 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 104 } |
104 | 105 |
105 // Busy loop to wait until the webkit give some size to the notification. | 106 // Busy loop to wait until the webkit give some size to the notification. |
106 void WaitForResize(BalloonViewImpl* view) { | 107 void WaitForResize(BalloonViewImpl* view) { |
107 while (view->bounds().IsEmpty()) { | 108 while (view->bounds().IsEmpty()) { |
108 ui_test_utils::RunAllPendingInMessageLoop(); | 109 ui_test_utils::RunAllPendingInMessageLoop(); |
109 } | 110 } |
110 } | 111 } |
111 | 112 |
112 // NotificationObserver overrides. | 113 // NotificationObserver overrides. |
113 virtual void Observe(NotificationType type, | 114 virtual void Observe(int type, |
114 const NotificationSource& source, | 115 const NotificationSource& source, |
115 const NotificationDetails& details) { | 116 const NotificationDetails& details) { |
116 ASSERT_TRUE(NotificationType::PANEL_STATE_CHANGED == type); | 117 ASSERT_TRUE(chrome::NOTIFICATION_PANEL_STATE_CHANGED == type); |
117 PanelController::State* state = | 118 PanelController::State* state = |
118 reinterpret_cast<PanelController::State*>(details.map_key()); | 119 reinterpret_cast<PanelController::State*>(details.map_key()); |
119 state_ = *state; | 120 state_ = *state; |
120 if (under_chromeos_ && expected_ == state_) { | 121 if (under_chromeos_ && expected_ == state_) { |
121 expected_ = PanelController::INITIAL; | 122 expected_ = PanelController::INITIAL; |
122 MessageLoop::current()->Quit(); | 123 MessageLoop::current()->Quit(); |
123 } | 124 } |
124 } | 125 } |
125 | 126 |
126 private: | 127 private: |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // -stale-> [STICKY_NEW] -remove-> [STICKY_NEW] -remove sys-> | 295 // -stale-> [STICKY_NEW] -remove-> [STICKY_NEW] -remove sys-> |
295 // [MINIMIZED] -remove-> [CLOSED] | 296 // [MINIMIZED] -remove-> [CLOSED] |
296 // | 297 // |
297 // This test depends on the fact that the panel state change occurs | 298 // This test depends on the fact that the panel state change occurs |
298 // quicker than stale timeout, thus the stale timeout cannot be set to | 299 // quicker than stale timeout, thus the stale timeout cannot be set to |
299 // 0. This test explicitly controls the stale state instead. | 300 // 0. This test explicitly controls the stale state instead. |
300 IN_PROC_BROWSER_TEST_F(NotificationTest, TestStateTransition2) { | 301 IN_PROC_BROWSER_TEST_F(NotificationTest, TestStateTransition2) { |
301 // Register observer here as the registration does not work in SetUp(). | 302 // Register observer here as the registration does not work in SetUp(). |
302 NotificationRegistrar registrar; | 303 NotificationRegistrar registrar; |
303 registrar.Add(this, | 304 registrar.Add(this, |
304 NotificationType::PANEL_STATE_CHANGED, | 305 chrome::NOTIFICATION_PANEL_STATE_CHANGED, |
305 NotificationService::AllSources()); | 306 NotificationService::AllSources()); |
306 | 307 |
307 BalloonCollectionImpl* collection = GetBalloonCollectionImpl(); | 308 BalloonCollectionImpl* collection = GetBalloonCollectionImpl(); |
308 NotificationPanel* panel = GetNotificationPanel(); | 309 NotificationPanel* panel = GetNotificationPanel(); |
309 NotificationPanelTester* tester = panel->GetTester(); | 310 NotificationPanelTester* tester = panel->GetTester(); |
310 | 311 |
311 // See description above. | 312 // See description above. |
312 tester->SetStaleTimeout(100000); | 313 tester->SetStaleTimeout(100000); |
313 | 314 |
314 EXPECT_EQ(NotificationPanel::CLOSED, tester->state()); | 315 EXPECT_EQ(NotificationPanel::CLOSED, tester->state()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 ui_test_utils::RunAllPendingInMessageLoop(); | 362 ui_test_utils::RunAllPendingInMessageLoop(); |
362 EXPECT_EQ(0, tester->GetNotificationCount()); | 363 EXPECT_EQ(0, tester->GetNotificationCount()); |
363 EXPECT_EQ(NotificationPanel::CLOSED, tester->state()); | 364 EXPECT_EQ(NotificationPanel::CLOSED, tester->state()); |
364 | 365 |
365 ui_test_utils::RunAllPendingInMessageLoop(); | 366 ui_test_utils::RunAllPendingInMessageLoop(); |
366 } | 367 } |
367 | 368 |
368 IN_PROC_BROWSER_TEST_F(NotificationTest, TestCleanupOnExit) { | 369 IN_PROC_BROWSER_TEST_F(NotificationTest, TestCleanupOnExit) { |
369 NotificationRegistrar registrar; | 370 NotificationRegistrar registrar; |
370 registrar.Add(this, | 371 registrar.Add(this, |
371 NotificationType::PANEL_STATE_CHANGED, | 372 chrome::NOTIFICATION_PANEL_STATE_CHANGED, |
372 NotificationService::AllSources()); | 373 NotificationService::AllSources()); |
373 | 374 |
374 BalloonCollectionImpl* collection = GetBalloonCollectionImpl(); | 375 BalloonCollectionImpl* collection = GetBalloonCollectionImpl(); |
375 NotificationPanel* panel = GetNotificationPanel(); | 376 NotificationPanel* panel = GetNotificationPanel(); |
376 NotificationPanelTester* tester = panel->GetTester(); | 377 NotificationPanelTester* tester = panel->GetTester(); |
377 | 378 |
378 // Don't become stale. | 379 // Don't become stale. |
379 tester->SetStaleTimeout(100000); | 380 tester->SetStaleTimeout(100000); |
380 | 381 |
381 collection->Add(NewMockNotification("1"), browser()->profile()); | 382 collection->Add(NewMockNotification("1"), browser()->profile()); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 EXPECT_TRUE(collection->AddWebUIMessageCallback( | 595 EXPECT_TRUE(collection->AddWebUIMessageCallback( |
595 NewMockNotification("1"), | 596 NewMockNotification("1"), |
596 "test", | 597 "test", |
597 NewCallback( | 598 NewCallback( |
598 static_cast<NotificationTest*>(this), | 599 static_cast<NotificationTest*>(this), |
599 &NotificationTest::HandleWebUIMessage))); | 600 &NotificationTest::HandleWebUIMessage))); |
600 MessageLoop::current()->Run(); | 601 MessageLoop::current()->Run(); |
601 } | 602 } |
602 | 603 |
603 } // namespace chromeos | 604 } // namespace chromeos |
OLD | NEW |