OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/notifications/desktop_notifications_unittest.h" | 5 #include "chrome/browser/notifications/desktop_notifications_unittest.h" |
6 | 6 |
7 #include "base/prefs/testing_pref_service.h" | 7 #include "base/prefs/testing_pref_service.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" | 10 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" |
11 #include "chrome/browser/notifications/fake_balloon_view.h" | 11 #include "chrome/browser/notifications/fake_balloon_view.h" |
12 #include "chrome/browser/prefs/browser_prefs.h" | 12 #include "chrome/browser/prefs/browser_prefs.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "content/public/common/show_desktop_notification_params.h" | 14 #include "content/public/common/show_desktop_notification_params.h" |
15 | 15 |
| 16 #if defined(ENABLE_MESSAGE_CENTER) |
| 17 #include "ui/message_center/message_center.h" |
| 18 #endif |
| 19 |
16 #if defined(USE_ASH) | 20 #if defined(USE_ASH) |
17 #include "ash/shell.h" | 21 #include "ash/shell.h" |
18 #include "ash/test/test_shell_delegate.h" | 22 #include "ash/test/test_shell_delegate.h" |
19 #include "chrome/browser/ui/aura/active_desktop_monitor.h" | 23 #include "chrome/browser/ui/aura/active_desktop_monitor.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
21 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
22 #include "ui/aura/root_window.h" | 26 #include "ui/aura/root_window.h" |
23 #endif | 27 #endif |
24 | 28 |
25 using content::BrowserThread; | 29 using content::BrowserThread; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 DesktopNotificationsTest::DesktopNotificationsTest() | 94 DesktopNotificationsTest::DesktopNotificationsTest() |
91 : ui_thread_(BrowserThread::UI, &message_loop_) { | 95 : ui_thread_(BrowserThread::UI, &message_loop_) { |
92 } | 96 } |
93 | 97 |
94 DesktopNotificationsTest::~DesktopNotificationsTest() { | 98 DesktopNotificationsTest::~DesktopNotificationsTest() { |
95 } | 99 } |
96 | 100 |
97 void DesktopNotificationsTest::SetUp() { | 101 void DesktopNotificationsTest::SetUp() { |
98 #if defined(USE_ASH) | 102 #if defined(USE_ASH) |
99 WebKit::initialize(webkit_platform_support_.Get()); | 103 WebKit::initialize(webkit_platform_support_.Get()); |
| 104 #if defined(ENABLE_MESSAGE_CENTER) |
| 105 // The message center is notmally initialized on |g_browser_process| which |
| 106 // is not created for these tests. |
| 107 message_center::MessageCenter::Initialize(); |
| 108 #endif |
100 // MockBalloonCollection retrieves information about the screen on creation. | 109 // MockBalloonCollection retrieves information about the screen on creation. |
101 // So it is necessary to make sure the desktop gets created first. | 110 // So it is necessary to make sure the desktop gets created first. |
102 ash::Shell::CreateInstance(new ash::test::TestShellDelegate); | 111 ash::Shell::CreateInstance(new ash::test::TestShellDelegate); |
103 active_desktop_monitor_.reset(new ActiveDesktopMonitor); | 112 active_desktop_monitor_.reset(new ActiveDesktopMonitor); |
104 #endif | 113 #endif |
105 | 114 |
106 chrome::RegisterLocalState(local_state_.registry()); | 115 chrome::RegisterLocalState(local_state_.registry()); |
107 profile_.reset(new TestingProfile()); | 116 profile_.reset(new TestingProfile()); |
108 ui_manager_.reset(new BalloonNotificationUIManager(&local_state_)); | 117 ui_manager_.reset(new BalloonNotificationUIManager(&local_state_)); |
109 balloon_collection_ = new MockBalloonCollection(); | 118 balloon_collection_ = new MockBalloonCollection(); |
110 ui_manager_->SetBalloonCollection(balloon_collection_); | 119 ui_manager_->SetBalloonCollection(balloon_collection_); |
111 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); | 120 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); |
112 log_output_.clear(); | 121 log_output_.clear(); |
113 } | 122 } |
114 | 123 |
115 void DesktopNotificationsTest::TearDown() { | 124 void DesktopNotificationsTest::TearDown() { |
116 service_.reset(NULL); | 125 service_.reset(NULL); |
117 ui_manager_.reset(NULL); | 126 ui_manager_.reset(NULL); |
118 profile_.reset(NULL); | 127 profile_.reset(NULL); |
119 #if defined(USE_ASH) | 128 #if defined(USE_ASH) |
120 active_desktop_monitor_.reset(); | 129 active_desktop_monitor_.reset(); |
121 ash::Shell::DeleteInstance(); | 130 ash::Shell::DeleteInstance(); |
| 131 #if defined(ENABLE_MESSAGE_CENTER) |
| 132 // The message center is notmally shutdown on |g_browser_process| which |
| 133 // is not created for these tests. |
| 134 message_center::MessageCenter::Shutdown(); |
| 135 #endif |
122 aura::Env::DeleteInstance(); | 136 aura::Env::DeleteInstance(); |
123 WebKit::shutdown(); | 137 WebKit::shutdown(); |
124 #endif | 138 #endif |
125 } | 139 } |
126 | 140 |
127 content::ShowDesktopNotificationHostMsgParams | 141 content::ShowDesktopNotificationHostMsgParams |
128 DesktopNotificationsTest::StandardTestNotification() { | 142 DesktopNotificationsTest::StandardTestNotification() { |
129 content::ShowDesktopNotificationHostMsgParams params; | 143 content::ShowDesktopNotificationHostMsgParams params; |
130 params.notification_id = 0; | 144 params.notification_id = 0; |
131 params.origin = GURL("http://www.google.com"); | 145 params.origin = GURL("http://www.google.com"); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 } | 485 } |
472 | 486 |
473 // Now change the position to upper left. Confirm that the X value for the | 487 // Now change the position to upper left. Confirm that the X value for the |
474 // balloons gets smaller. | 488 // balloons gets smaller. |
475 local_state_.SetInteger(prefs::kDesktopNotificationPosition, | 489 local_state_.SetInteger(prefs::kDesktopNotificationPosition, |
476 BalloonCollection::UPPER_LEFT); | 490 BalloonCollection::UPPER_LEFT); |
477 | 491 |
478 int current_x = (*balloons.begin())->GetPosition().x(); | 492 int current_x = (*balloons.begin())->GetPosition().x(); |
479 EXPECT_LT(current_x, last_x); | 493 EXPECT_LT(current_x, last_x); |
480 } | 494 } |
OLD | NEW |