| 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 "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 | 18 |
| 19 #if defined(ENABLE_MESSAGE_CENTER) | 19 #if defined(ENABLE_MESSAGE_CENTER) |
| 20 #include "ui/message_center/message_center.h" | 20 #include "ui/message_center/message_center.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 #if defined(USE_ASH) | 23 #if defined(USE_ASH) |
| 24 #include "ash/shell.h" | 24 #include "ash/shell.h" |
| 25 #include "ash/test/test_shell_delegate.h" | 25 #include "ash/test/test_shell_delegate.h" |
| 26 #include "chrome/browser/ui/aura/active_desktop_monitor.h" | 26 #include "chrome/browser/ui/aura/active_desktop_monitor.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 27 #include "ui/aura/env.h" | 28 #include "ui/aura/env.h" |
| 28 #include "ui/aura/root_window.h" | 29 #include "ui/aura/root_window.h" |
| 29 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 30 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
| 33 #include "base/win/metro.h" | 34 #include "base/win/metro.h" |
| 34 #include "ui/base/ime/win/tsf_bridge.h" | 35 #include "ui/base/ime/win/tsf_bridge.h" |
| 35 #endif | 36 #endif |
| 36 | 37 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 106 |
| 106 DesktopNotificationsTest::~DesktopNotificationsTest() { | 107 DesktopNotificationsTest::~DesktopNotificationsTest() { |
| 107 } | 108 } |
| 108 | 109 |
| 109 void DesktopNotificationsTest::SetUp() { | 110 void DesktopNotificationsTest::SetUp() { |
| 110 #if defined(OS_WIN) | 111 #if defined(OS_WIN) |
| 111 if (base::win::IsTSFAwareRequired()) | 112 if (base::win::IsTSFAwareRequired()) |
| 112 ui::TSFBridge::Initialize(); | 113 ui::TSFBridge::Initialize(); |
| 113 #endif | 114 #endif |
| 114 #if defined(USE_ASH) | 115 #if defined(USE_ASH) |
| 116 WebKit::initialize(webkit_platform_support_.Get()); |
| 115 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 117 ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
| 116 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); | 118 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); |
| 117 #if defined(ENABLE_MESSAGE_CENTER) | 119 #if defined(ENABLE_MESSAGE_CENTER) |
| 118 // The message center is notmally initialized on |g_browser_process| which | 120 // The message center is notmally initialized on |g_browser_process| which |
| 119 // is not created for these tests. | 121 // is not created for these tests. |
| 120 message_center::MessageCenter::Initialize(); | 122 message_center::MessageCenter::Initialize(); |
| 121 #endif | 123 #endif |
| 122 // MockBalloonCollection retrieves information about the screen on creation. | 124 // MockBalloonCollection retrieves information about the screen on creation. |
| 123 // So it is necessary to make sure the desktop gets created first. | 125 // So it is necessary to make sure the desktop gets created first. |
| 124 ash::Shell::CreateInstance(new ash::test::TestShellDelegate); | 126 ash::Shell::CreateInstance(new ash::test::TestShellDelegate); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 140 profile_.reset(NULL); | 142 profile_.reset(NULL); |
| 141 #if defined(USE_ASH) | 143 #if defined(USE_ASH) |
| 142 active_desktop_monitor_.reset(); | 144 active_desktop_monitor_.reset(); |
| 143 ash::Shell::DeleteInstance(); | 145 ash::Shell::DeleteInstance(); |
| 144 #if defined(ENABLE_MESSAGE_CENTER) | 146 #if defined(ENABLE_MESSAGE_CENTER) |
| 145 // The message center is notmally shutdown on |g_browser_process| which | 147 // The message center is notmally shutdown on |g_browser_process| which |
| 146 // is not created for these tests. | 148 // is not created for these tests. |
| 147 message_center::MessageCenter::Shutdown(); | 149 message_center::MessageCenter::Shutdown(); |
| 148 #endif | 150 #endif |
| 149 aura::Env::DeleteInstance(); | 151 aura::Env::DeleteInstance(); |
| 152 WebKit::shutdown(); |
| 150 #endif | 153 #endif |
| 151 } | 154 } |
| 152 | 155 |
| 153 content::ShowDesktopNotificationHostMsgParams | 156 content::ShowDesktopNotificationHostMsgParams |
| 154 DesktopNotificationsTest::StandardTestNotification() { | 157 DesktopNotificationsTest::StandardTestNotification() { |
| 155 content::ShowDesktopNotificationHostMsgParams params; | 158 content::ShowDesktopNotificationHostMsgParams params; |
| 156 params.notification_id = 0; | 159 params.notification_id = 0; |
| 157 params.origin = GURL("http://www.google.com"); | 160 params.origin = GURL("http://www.google.com"); |
| 158 params.is_html = false; | 161 params.is_html = false; |
| 159 params.icon_url = GURL("/icon.png"); | 162 params.icon_url = GURL("/icon.png"); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 } | 580 } |
| 578 | 581 |
| 579 // Now change the position to upper left. Confirm that the X value for the | 582 // Now change the position to upper left. Confirm that the X value for the |
| 580 // balloons gets smaller. | 583 // balloons gets smaller. |
| 581 local_state_.SetInteger(prefs::kDesktopNotificationPosition, | 584 local_state_.SetInteger(prefs::kDesktopNotificationPosition, |
| 582 BalloonCollection::UPPER_LEFT); | 585 BalloonCollection::UPPER_LEFT); |
| 583 | 586 |
| 584 int current_x = (*balloons.begin())->GetPosition().x(); | 587 int current_x = (*balloons.begin())->GetPosition().x(); |
| 585 EXPECT_LT(current_x, last_x); | 588 EXPECT_LT(current_x, last_x); |
| 586 } | 589 } |
| OLD | NEW |