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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/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 "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
16 #include "chrome/test/base/testing_profile_manager.h" | 16 #include "chrome/test/base/testing_profile_manager.h" |
17 #include "content/public/common/show_desktop_notification_params.h" | 17 #include "content/public/common/show_desktop_notification_params.h" |
18 #include "ui/base/ime/input_method_initializer.h" | 18 #include "ui/base/ime/input_method_initializer.h" |
19 #include "ui/message_center/message_center.h" | 19 #include "ui/message_center/message_center.h" |
20 | 20 |
21 #if defined(USE_ASH) | 21 #if defined(USE_ASH) |
22 #include "ash/shell.h" | 22 #include "ash/shell.h" |
23 #include "ash/test/test_shell_delegate.h" | 23 #include "ash/test/test_shell_delegate.h" |
24 #include "chrome/browser/ui/aura/active_desktop_monitor.h" | |
25 #include "third_party/WebKit/public/web/WebKit.h" | 24 #include "third_party/WebKit/public/web/WebKit.h" |
26 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
27 #include "ui/aura/root_window.h" | 26 #include "ui/aura/root_window.h" |
28 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 27 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
29 #endif | 28 #endif |
30 | 29 |
31 | 30 |
32 using content::BrowserThread; | 31 using content::BrowserThread; |
33 | 32 |
34 // static | 33 // static |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 #if defined(USE_ASH) | 105 #if defined(USE_ASH) |
107 WebKit::initialize(webkit_platform_support_.Get()); | 106 WebKit::initialize(webkit_platform_support_.Get()); |
108 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 107 ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
109 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); | 108 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); |
110 // The message center is notmally initialized on |g_browser_process| which | 109 // The message center is notmally initialized on |g_browser_process| which |
111 // is not created for these tests. | 110 // is not created for these tests. |
112 message_center::MessageCenter::Initialize(); | 111 message_center::MessageCenter::Initialize(); |
113 // MockBalloonCollection retrieves information about the screen on creation. | 112 // MockBalloonCollection retrieves information about the screen on creation. |
114 // So it is necessary to make sure the desktop gets created first. | 113 // So it is necessary to make sure the desktop gets created first. |
115 ash::Shell::CreateInstance(new ash::test::TestShellDelegate); | 114 ash::Shell::CreateInstance(new ash::test::TestShellDelegate); |
116 active_desktop_monitor_.reset(new ActiveDesktopMonitor); | |
117 #endif | 115 #endif |
118 | 116 |
119 chrome::RegisterLocalState(local_state_.registry()); | 117 chrome::RegisterLocalState(local_state_.registry()); |
120 profile_.reset(new TestingProfile()); | 118 profile_.reset(new TestingProfile()); |
121 ui_manager_.reset(new BalloonNotificationUIManager(&local_state_)); | 119 ui_manager_.reset(new BalloonNotificationUIManager(&local_state_)); |
122 balloon_collection_ = new MockBalloonCollection(); | 120 balloon_collection_ = new MockBalloonCollection(); |
123 ui_manager_->SetBalloonCollection(balloon_collection_); | 121 ui_manager_->SetBalloonCollection(balloon_collection_); |
124 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); | 122 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); |
125 log_output_.clear(); | 123 log_output_.clear(); |
126 } | 124 } |
127 | 125 |
128 void DesktopNotificationsTest::TearDown() { | 126 void DesktopNotificationsTest::TearDown() { |
129 service_.reset(NULL); | 127 service_.reset(NULL); |
130 ui_manager_.reset(NULL); | 128 ui_manager_.reset(NULL); |
131 profile_.reset(NULL); | 129 profile_.reset(NULL); |
132 #if defined(USE_ASH) | 130 #if defined(USE_ASH) |
133 active_desktop_monitor_.reset(); | |
134 ash::Shell::DeleteInstance(); | 131 ash::Shell::DeleteInstance(); |
135 // The message center is notmally shutdown on |g_browser_process| which | 132 // The message center is notmally shutdown on |g_browser_process| which |
136 // is not created for these tests. | 133 // is not created for these tests. |
137 message_center::MessageCenter::Shutdown(); | 134 message_center::MessageCenter::Shutdown(); |
138 aura::Env::DeleteInstance(); | 135 aura::Env::DeleteInstance(); |
139 WebKit::shutdown(); | 136 WebKit::shutdown(); |
140 #endif | 137 #endif |
141 ui::ShutdownInputMethodForTesting(); | 138 ui::ShutdownInputMethodForTesting(); |
142 } | 139 } |
143 | 140 |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 } | 565 } |
569 | 566 |
570 // Now change the position to upper left. Confirm that the X value for the | 567 // Now change the position to upper left. Confirm that the X value for the |
571 // balloons gets smaller. | 568 // balloons gets smaller. |
572 local_state_.SetInteger(prefs::kDesktopNotificationPosition, | 569 local_state_.SetInteger(prefs::kDesktopNotificationPosition, |
573 BalloonCollection::UPPER_LEFT); | 570 BalloonCollection::UPPER_LEFT); |
574 | 571 |
575 int current_x = (*balloons.begin())->GetPosition().x(); | 572 int current_x = (*balloons.begin())->GetPosition().x(); |
576 EXPECT_LT(current_x, last_x); | 573 EXPECT_LT(current_x, last_x); |
577 } | 574 } |
OLD | NEW |