| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/x11_util.h" | |
| 6 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 7 #include "base/ref_counted.h" | 6 #include "base/ref_counted.h" |
| 8 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 9 #include "base/string16.h" | 8 #include "base/string16.h" |
| 10 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 11 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 12 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chromeos/notifications/balloon_collection_impl.h" | 13 #include "chrome/browser/chromeos/notifications/balloon_collection_impl.h" |
| 15 #include "chrome/browser/chromeos/notifications/balloon_view.h" | 14 #include "chrome/browser/chromeos/notifications/balloon_view.h" |
| 16 #include "chrome/browser/chromeos/notifications/notification_panel.h" | 15 #include "chrome/browser/chromeos/notifications/notification_panel.h" |
| 17 #include "chrome/browser/chromeos/notifications/system_notification_factory.h" | 16 #include "chrome/browser/chromeos/notifications/system_notification_factory.h" |
| 18 #include "chrome/browser/notifications/notification_test_util.h" | 17 #include "chrome/browser/notifications/notification_test_util.h" |
| 19 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 20 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/common/notification_service.h" | 20 #include "chrome/common/notification_service.h" |
| 22 #include "chrome/test/in_process_browser_test.h" | 21 #include "chrome/test/in_process_browser_test.h" |
| 23 #include "chrome/test/ui_test_utils.h" | 22 #include "chrome/test/ui_test_utils.h" |
| 23 #include "ui/base/x/x11_util.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // The name of ChromeOS's window manager. | 27 // The name of ChromeOS's window manager. |
| 28 const char* kChromeOsWindowManagerName = "chromeos-wm"; | 28 const char* kChromeOsWindowManagerName = "chromeos-wm"; |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 namespace chromeos { | 32 namespace chromeos { |
| 33 | 33 |
| 34 class NotificationTest : public InProcessBrowserTest, | 34 class NotificationTest : public InProcessBrowserTest, |
| 35 public NotificationObserver { | 35 public NotificationObserver { |
| 36 public: | 36 public: |
| 37 NotificationTest() | 37 NotificationTest() |
| 38 : under_chromeos_(false), | 38 : under_chromeos_(false), |
| 39 state_(PanelController::INITIAL), | 39 state_(PanelController::INITIAL), |
| 40 expected_(PanelController::INITIAL) { | 40 expected_(PanelController::INITIAL) { |
| 41 } | 41 } |
| 42 | 42 |
| 43 void HandleDOMUIMessage(const ListValue* value) { | 43 void HandleDOMUIMessage(const ListValue* value) { |
| 44 MessageLoop::current()->Quit(); | 44 MessageLoop::current()->Quit(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 virtual void SetUp() { | 48 virtual void SetUp() { |
| 49 // Detect if we're running under ChromeOS WindowManager. See | 49 // Detect if we're running under ChromeOS WindowManager. See |
| 50 // the description for "under_chromeos_" below for why we need this. | 50 // the description for "under_chromeos_" below for why we need this. |
| 51 std::string wm_name; | 51 std::string wm_name; |
| 52 bool wm_name_valid = x11_util::GetWindowManagerName(&wm_name); | 52 bool wm_name_valid = ui::GetWindowManagerName(&wm_name); |
| 53 // NOTE: On Chrome OS the wm and Chrome are started in parallel. This | 53 // NOTE: On Chrome OS the wm and Chrome are started in parallel. This |
| 54 // means it's possible for us not to be able to get the name of the window | 54 // means it's possible for us not to be able to get the name of the window |
| 55 // manager. We assume that when this happens we're on Chrome OS. | 55 // manager. We assume that when this happens we're on Chrome OS. |
| 56 under_chromeos_ = (!wm_name_valid || | 56 under_chromeos_ = (!wm_name_valid || |
| 57 wm_name == kChromeOsWindowManagerName); | 57 wm_name == kChromeOsWindowManagerName); |
| 58 InProcessBrowserTest::SetUp(); | 58 InProcessBrowserTest::SetUp(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 BalloonCollectionImpl* GetBalloonCollectionImpl() { | 61 BalloonCollectionImpl* GetBalloonCollectionImpl() { |
| 62 return static_cast<BalloonCollectionImpl*>( | 62 return static_cast<BalloonCollectionImpl*>( |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 EXPECT_TRUE(collection->AddDOMUIMessageCallback( | 588 EXPECT_TRUE(collection->AddDOMUIMessageCallback( |
| 589 NewMockNotification("1"), | 589 NewMockNotification("1"), |
| 590 "test", | 590 "test", |
| 591 NewCallback( | 591 NewCallback( |
| 592 static_cast<NotificationTest*>(this), | 592 static_cast<NotificationTest*>(this), |
| 593 &NotificationTest::HandleDOMUIMessage))); | 593 &NotificationTest::HandleDOMUIMessage))); |
| 594 MessageLoop::current()->Run(); | 594 MessageLoop::current()->Run(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 } // namespace chromeos | 597 } // namespace chromeos |
| OLD | NEW |