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" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 103 } |
104 | 104 |
105 // Busy loop to wait until the webkit give some size to the notification. | 105 // Busy loop to wait until the webkit give some size to the notification. |
106 void WaitForResize(BalloonViewImpl* view) { | 106 void WaitForResize(BalloonViewImpl* view) { |
107 while (view->bounds().IsEmpty()) { | 107 while (view->bounds().IsEmpty()) { |
108 ui_test_utils::RunAllPendingInMessageLoop(); | 108 ui_test_utils::RunAllPendingInMessageLoop(); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 // NotificationObserver overrides. | 112 // NotificationObserver overrides. |
113 virtual void Observe(NotificationType type, | 113 virtual void Observe(int type, |
114 const NotificationSource& source, | 114 const NotificationSource& source, |
115 const NotificationDetails& details) { | 115 const NotificationDetails& details) { |
116 ASSERT_TRUE(NotificationType::PANEL_STATE_CHANGED == type); | 116 ASSERT_TRUE(chrome::PANEL_STATE_CHANGED == type); |
117 PanelController::State* state = | 117 PanelController::State* state = |
118 reinterpret_cast<PanelController::State*>(details.map_key()); | 118 reinterpret_cast<PanelController::State*>(details.map_key()); |
119 state_ = *state; | 119 state_ = *state; |
120 if (under_chromeos_ && expected_ == state_) { | 120 if (under_chromeos_ && expected_ == state_) { |
121 expected_ = PanelController::INITIAL; | 121 expected_ = PanelController::INITIAL; |
122 MessageLoop::current()->Quit(); | 122 MessageLoop::current()->Quit(); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 private: | 126 private: |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // -stale-> [STICKY_NEW] -remove-> [STICKY_NEW] -remove sys-> | 294 // -stale-> [STICKY_NEW] -remove-> [STICKY_NEW] -remove sys-> |
295 // [MINIMIZED] -remove-> [CLOSED] | 295 // [MINIMIZED] -remove-> [CLOSED] |
296 // | 296 // |
297 // This test depends on the fact that the panel state change occurs | 297 // 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 | 298 // quicker than stale timeout, thus the stale timeout cannot be set to |
299 // 0. This test explicitly controls the stale state instead. | 299 // 0. This test explicitly controls the stale state instead. |
300 IN_PROC_BROWSER_TEST_F(NotificationTest, TestStateTransition2) { | 300 IN_PROC_BROWSER_TEST_F(NotificationTest, TestStateTransition2) { |
301 // Register observer here as the registration does not work in SetUp(). | 301 // Register observer here as the registration does not work in SetUp(). |
302 NotificationRegistrar registrar; | 302 NotificationRegistrar registrar; |
303 registrar.Add(this, | 303 registrar.Add(this, |
304 NotificationType::PANEL_STATE_CHANGED, | 304 chrome::PANEL_STATE_CHANGED, |
305 NotificationService::AllSources()); | 305 NotificationService::AllSources()); |
306 | 306 |
307 BalloonCollectionImpl* collection = GetBalloonCollectionImpl(); | 307 BalloonCollectionImpl* collection = GetBalloonCollectionImpl(); |
308 NotificationPanel* panel = GetNotificationPanel(); | 308 NotificationPanel* panel = GetNotificationPanel(); |
309 NotificationPanelTester* tester = panel->GetTester(); | 309 NotificationPanelTester* tester = panel->GetTester(); |
310 | 310 |
311 // See description above. | 311 // See description above. |
312 tester->SetStaleTimeout(100000); | 312 tester->SetStaleTimeout(100000); |
313 | 313 |
314 EXPECT_EQ(NotificationPanel::CLOSED, tester->state()); | 314 EXPECT_EQ(NotificationPanel::CLOSED, tester->state()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 ui_test_utils::RunAllPendingInMessageLoop(); | 361 ui_test_utils::RunAllPendingInMessageLoop(); |
362 EXPECT_EQ(0, tester->GetNotificationCount()); | 362 EXPECT_EQ(0, tester->GetNotificationCount()); |
363 EXPECT_EQ(NotificationPanel::CLOSED, tester->state()); | 363 EXPECT_EQ(NotificationPanel::CLOSED, tester->state()); |
364 | 364 |
365 ui_test_utils::RunAllPendingInMessageLoop(); | 365 ui_test_utils::RunAllPendingInMessageLoop(); |
366 } | 366 } |
367 | 367 |
368 IN_PROC_BROWSER_TEST_F(NotificationTest, TestCleanupOnExit) { | 368 IN_PROC_BROWSER_TEST_F(NotificationTest, TestCleanupOnExit) { |
369 NotificationRegistrar registrar; | 369 NotificationRegistrar registrar; |
370 registrar.Add(this, | 370 registrar.Add(this, |
371 NotificationType::PANEL_STATE_CHANGED, | 371 chrome::PANEL_STATE_CHANGED, |
372 NotificationService::AllSources()); | 372 NotificationService::AllSources()); |
373 | 373 |
374 BalloonCollectionImpl* collection = GetBalloonCollectionImpl(); | 374 BalloonCollectionImpl* collection = GetBalloonCollectionImpl(); |
375 NotificationPanel* panel = GetNotificationPanel(); | 375 NotificationPanel* panel = GetNotificationPanel(); |
376 NotificationPanelTester* tester = panel->GetTester(); | 376 NotificationPanelTester* tester = panel->GetTester(); |
377 | 377 |
378 // Don't become stale. | 378 // Don't become stale. |
379 tester->SetStaleTimeout(100000); | 379 tester->SetStaleTimeout(100000); |
380 | 380 |
381 collection->Add(NewMockNotification("1"), browser()->profile()); | 381 collection->Add(NewMockNotification("1"), browser()->profile()); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 EXPECT_TRUE(collection->AddWebUIMessageCallback( | 594 EXPECT_TRUE(collection->AddWebUIMessageCallback( |
595 NewMockNotification("1"), | 595 NewMockNotification("1"), |
596 "test", | 596 "test", |
597 NewCallback( | 597 NewCallback( |
598 static_cast<NotificationTest*>(this), | 598 static_cast<NotificationTest*>(this), |
599 &NotificationTest::HandleWebUIMessage))); | 599 &NotificationTest::HandleWebUIMessage))); |
600 MessageLoop::current()->Run(); | 600 MessageLoop::current()->Run(); |
601 } | 601 } |
602 | 602 |
603 } // namespace chromeos | 603 } // namespace chromeos |
OLD | NEW |