| 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" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 DesktopNotificationsTest::DesktopNotificationsTest() | 100 DesktopNotificationsTest::DesktopNotificationsTest() |
| 101 : ui_thread_(BrowserThread::UI, &message_loop_), | 101 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 102 balloon_collection_(NULL) { | 102 balloon_collection_(NULL) { |
| 103 } | 103 } |
| 104 | 104 |
| 105 DesktopNotificationsTest::~DesktopNotificationsTest() { | 105 DesktopNotificationsTest::~DesktopNotificationsTest() { |
| 106 } | 106 } |
| 107 | 107 |
| 108 void DesktopNotificationsTest::SetUp() { | 108 void DesktopNotificationsTest::SetUp() { |
| 109 ui::InitializeInputMethodForTesting(); | 109 ui::InitializeInputMethodForTesting(); |
| 110 #if defined(OS_WIN) && defined(USE_ASH) | |
| 111 // The system tray under Windows ash contains a volume slider which needs | |
| 112 // to talk to the audio hardware using COM. | |
| 113 com_initializer_.reset(new base::win::ScopedCOMInitializer()); | |
| 114 #endif | |
| 115 #if defined(USE_AURA) | 110 #if defined(USE_AURA) |
| 116 wm_state_.reset(new views::corewm::WMState); | 111 wm_state_.reset(new views::corewm::WMState); |
| 117 #endif | 112 #endif |
| 118 #if defined(USE_ASH) | 113 #if defined(USE_ASH) |
| 119 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 114 ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
| 120 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); | 115 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); |
| 121 // The message center is notmally initialized on |g_browser_process| which | 116 // The message center is notmally initialized on |g_browser_process| which |
| 122 // is not created for these tests. | 117 // is not created for these tests. |
| 123 message_center::MessageCenter::Initialize(); | 118 message_center::MessageCenter::Initialize(); |
| 124 // The ContextFactory must exist before any Compositors are created. | 119 // The ContextFactory must exist before any Compositors are created. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 145 ash::Shell::DeleteInstance(); | 140 ash::Shell::DeleteInstance(); |
| 146 // The message center is notmally shutdown on |g_browser_process| which | 141 // The message center is notmally shutdown on |g_browser_process| which |
| 147 // is not created for these tests. | 142 // is not created for these tests. |
| 148 message_center::MessageCenter::Shutdown(); | 143 message_center::MessageCenter::Shutdown(); |
| 149 aura::Env::DeleteInstance(); | 144 aura::Env::DeleteInstance(); |
| 150 ui::TerminateContextFactoryForTests(); | 145 ui::TerminateContextFactoryForTests(); |
| 151 #endif | 146 #endif |
| 152 #if defined(USE_AURA) | 147 #if defined(USE_AURA) |
| 153 wm_state_.reset(); | 148 wm_state_.reset(); |
| 154 #endif | 149 #endif |
| 155 #if defined(OS_WIN) && defined(USE_ASH) | |
| 156 com_initializer_.reset(); | |
| 157 #endif | |
| 158 ui::ShutdownInputMethodForTesting(); | 150 ui::ShutdownInputMethodForTesting(); |
| 159 } | 151 } |
| 160 | 152 |
| 161 content::ShowDesktopNotificationHostMsgParams | 153 content::ShowDesktopNotificationHostMsgParams |
| 162 DesktopNotificationsTest::StandardTestNotification() { | 154 DesktopNotificationsTest::StandardTestNotification() { |
| 163 content::ShowDesktopNotificationHostMsgParams params; | 155 content::ShowDesktopNotificationHostMsgParams params; |
| 164 params.notification_id = 0; | 156 params.notification_id = 0; |
| 165 params.origin = GURL("http://www.google.com"); | 157 params.origin = GURL("http://www.google.com"); |
| 166 params.icon_url = GURL("/icon.png"); | 158 params.icon_url = GURL("/icon.png"); |
| 167 params.title = base::ASCIIToUTF16("Title"); | 159 params.title = base::ASCIIToUTF16("Title"); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 } | 575 } |
| 584 | 576 |
| 585 // Now change the position to upper left. Confirm that the X value for the | 577 // Now change the position to upper left. Confirm that the X value for the |
| 586 // balloons gets smaller. | 578 // balloons gets smaller. |
| 587 local_state_.SetInteger(prefs::kDesktopNotificationPosition, | 579 local_state_.SetInteger(prefs::kDesktopNotificationPosition, |
| 588 BalloonCollection::UPPER_LEFT); | 580 BalloonCollection::UPPER_LEFT); |
| 589 | 581 |
| 590 int current_x = (*balloons.begin())->GetPosition().x(); | 582 int current_x = (*balloons.begin())->GetPosition().x(); |
| 591 EXPECT_LT(current_x, last_x); | 583 EXPECT_LT(current_x, last_x); |
| 592 } | 584 } |
| OLD | NEW |