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/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/notifications/fake_balloon_view.h" | 9 #include "chrome/browser/notifications/fake_balloon_view.h" |
10 #include "chrome/browser/prefs/browser_prefs.h" | 10 #include "chrome/browser/prefs/browser_prefs.h" |
11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
12 #include "chrome/test/base/testing_pref_service.h" | 12 #include "chrome/test/base/testing_pref_service.h" |
13 #include "content/public/common/show_desktop_notification_params.h" | 13 #include "content/public/common/show_desktop_notification_params.h" |
14 | 14 |
15 #if defined(USE_AURA) | 15 #if defined(USE_ASH) |
16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/test/test_shell_delegate.h" |
| 18 #include "chrome/browser/ui/aura/active_desktop_monitor.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
18 #include "ui/aura/env.h" | 20 #include "ui/aura/env.h" |
19 #include "ui/aura/root_window.h" | 21 #include "ui/aura/root_window.h" |
20 #endif | 22 #endif |
21 | 23 |
22 using content::BrowserThread; | 24 using content::BrowserThread; |
23 | 25 |
24 // static | 26 // static |
25 const int MockBalloonCollection::kMockBalloonSpace = 5; | 27 const int MockBalloonCollection::kMockBalloonSpace = 5; |
26 | 28 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 91 } |
90 | 92 |
91 DesktopNotificationsTest::~DesktopNotificationsTest() { | 93 DesktopNotificationsTest::~DesktopNotificationsTest() { |
92 } | 94 } |
93 | 95 |
94 void DesktopNotificationsTest::SetUp() { | 96 void DesktopNotificationsTest::SetUp() { |
95 #if defined(USE_ASH) | 97 #if defined(USE_ASH) |
96 WebKit::initialize(webkit_platform_support_.Get()); | 98 WebKit::initialize(webkit_platform_support_.Get()); |
97 // MockBalloonCollection retrieves information about the screen on creation. | 99 // MockBalloonCollection retrieves information about the screen on creation. |
98 // So it is necessary to make sure the desktop gets created first. | 100 // So it is necessary to make sure the desktop gets created first. |
99 ash::Shell::CreateInstance(NULL); | 101 ash::Shell::CreateInstance(new ash::test::TestShellDelegate); |
| 102 active_desktop_monitor_.reset(new ActiveDesktopMonitor); |
100 #endif | 103 #endif |
101 | 104 |
102 chrome::RegisterLocalState(&local_state_); | 105 chrome::RegisterLocalState(&local_state_); |
103 profile_.reset(new TestingProfile()); | 106 profile_.reset(new TestingProfile()); |
104 balloon_collection_ = new MockBalloonCollection(); | 107 balloon_collection_ = new MockBalloonCollection(); |
105 ui_manager_.reset(NotificationUIManager::Create(&local_state_, | 108 ui_manager_.reset(NotificationUIManager::Create(&local_state_, |
106 balloon_collection_)); | 109 balloon_collection_)); |
107 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); | 110 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); |
108 log_output_.clear(); | 111 log_output_.clear(); |
109 } | 112 } |
110 | 113 |
111 void DesktopNotificationsTest::TearDown() { | 114 void DesktopNotificationsTest::TearDown() { |
112 service_.reset(NULL); | 115 service_.reset(NULL); |
113 ui_manager_.reset(NULL); | 116 ui_manager_.reset(NULL); |
114 profile_.reset(NULL); | 117 profile_.reset(NULL); |
115 #if defined(USE_ASH) | 118 #if defined(USE_ASH) |
| 119 active_desktop_monitor_.reset(); |
116 ash::Shell::DeleteInstance(); | 120 ash::Shell::DeleteInstance(); |
117 aura::Env::DeleteInstance(); | 121 aura::Env::DeleteInstance(); |
118 WebKit::shutdown(); | 122 WebKit::shutdown(); |
119 #endif | 123 #endif |
120 } | 124 } |
121 | 125 |
122 content::ShowDesktopNotificationHostMsgParams | 126 content::ShowDesktopNotificationHostMsgParams |
123 DesktopNotificationsTest::StandardTestNotification() { | 127 DesktopNotificationsTest::StandardTestNotification() { |
124 content::ShowDesktopNotificationHostMsgParams params; | 128 content::ShowDesktopNotificationHostMsgParams params; |
125 params.notification_id = 0; | 129 params.notification_id = 0; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 } | 470 } |
467 | 471 |
468 // Now change the position to upper left. Confirm that the X value for the | 472 // Now change the position to upper left. Confirm that the X value for the |
469 // balloons gets smaller. | 473 // balloons gets smaller. |
470 local_state_.SetInteger(prefs::kDesktopNotificationPosition, | 474 local_state_.SetInteger(prefs::kDesktopNotificationPosition, |
471 BalloonCollection::UPPER_LEFT); | 475 BalloonCollection::UPPER_LEFT); |
472 | 476 |
473 int current_x = (*balloons.begin())->GetPosition().x(); | 477 int current_x = (*balloons.begin())->GetPosition().x(); |
474 EXPECT_LT(current_x, last_x); | 478 EXPECT_LT(current_x, last_x); |
475 } | 479 } |
OLD | NEW |