| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/prefs/browser_prefs.h" | 9 #include "chrome/browser/prefs/browser_prefs.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/test/base/testing_pref_service.h" | 11 #include "chrome/test/base/testing_pref_service.h" |
| 12 #include "content/public/common/show_desktop_notification_params.h" | 12 #include "content/public/common/show_desktop_notification_params.h" |
| 13 | 13 |
| 14 #if defined(USE_AURA) | 14 #if defined(USE_AURA) |
| 15 #if defined(USE_WEBKIT_COMPOSITOR) | |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 17 #endif | |
| 18 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
| 19 #endif | 17 #endif |
| 20 | 18 |
| 21 using content::BrowserThread; | 19 using content::BrowserThread; |
| 22 | 20 |
| 23 // static | 21 // static |
| 24 const int MockBalloonCollection::kMockBalloonSpace = 5; | 22 const int MockBalloonCollection::kMockBalloonSpace = 5; |
| 25 | 23 |
| 26 // static | 24 // static |
| 27 std::string DesktopNotificationsTest::log_output_; | 25 std::string DesktopNotificationsTest::log_output_; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 83 |
| 86 DesktopNotificationsTest::DesktopNotificationsTest() | 84 DesktopNotificationsTest::DesktopNotificationsTest() |
| 87 : ui_thread_(BrowserThread::UI, &message_loop_) { | 85 : ui_thread_(BrowserThread::UI, &message_loop_) { |
| 88 } | 86 } |
| 89 | 87 |
| 90 DesktopNotificationsTest::~DesktopNotificationsTest() { | 88 DesktopNotificationsTest::~DesktopNotificationsTest() { |
| 91 } | 89 } |
| 92 | 90 |
| 93 void DesktopNotificationsTest::SetUp() { | 91 void DesktopNotificationsTest::SetUp() { |
| 94 #if defined(USE_AURA) | 92 #if defined(USE_AURA) |
| 95 #if defined(USE_WEBKIT_COMPOSITOR) | |
| 96 WebKit::initialize(&webkit_platform_support_); | 93 WebKit::initialize(&webkit_platform_support_); |
| 97 #endif | |
| 98 // MockBalloonCollection retrieves information about the screen on creation. | 94 // MockBalloonCollection retrieves information about the screen on creation. |
| 99 // So it is necessary to make sure the desktop gets created first. | 95 // So it is necessary to make sure the desktop gets created first. |
| 100 aura::RootWindow::GetInstance(); | 96 aura::RootWindow::GetInstance(); |
| 101 #endif | 97 #endif |
| 102 | 98 |
| 103 browser::RegisterLocalState(&local_state_); | 99 browser::RegisterLocalState(&local_state_); |
| 104 profile_.reset(new TestingProfile()); | 100 profile_.reset(new TestingProfile()); |
| 105 balloon_collection_ = new MockBalloonCollection(); | 101 balloon_collection_ = new MockBalloonCollection(); |
| 106 ui_manager_.reset(NotificationUIManager::Create(&local_state_, | 102 ui_manager_.reset(NotificationUIManager::Create(&local_state_, |
| 107 balloon_collection_)); | 103 balloon_collection_)); |
| 108 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); | 104 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); |
| 109 log_output_.clear(); | 105 log_output_.clear(); |
| 110 } | 106 } |
| 111 | 107 |
| 112 void DesktopNotificationsTest::TearDown() { | 108 void DesktopNotificationsTest::TearDown() { |
| 113 service_.reset(NULL); | 109 service_.reset(NULL); |
| 114 ui_manager_.reset(NULL); | 110 ui_manager_.reset(NULL); |
| 115 profile_.reset(NULL); | 111 profile_.reset(NULL); |
| 116 #if defined(USE_AURA) | 112 #if defined(USE_AURA) |
| 117 aura::RootWindow::DeleteInstance(); | 113 aura::RootWindow::DeleteInstance(); |
| 118 #if defined(USE_WEBKIT_COMPOSITOR) | |
| 119 WebKit::shutdown(); | 114 WebKit::shutdown(); |
| 120 #endif | 115 #endif |
| 121 #endif | |
| 122 } | 116 } |
| 123 | 117 |
| 124 content::ShowDesktopNotificationHostMsgParams | 118 content::ShowDesktopNotificationHostMsgParams |
| 125 DesktopNotificationsTest::StandardTestNotification() { | 119 DesktopNotificationsTest::StandardTestNotification() { |
| 126 content::ShowDesktopNotificationHostMsgParams params; | 120 content::ShowDesktopNotificationHostMsgParams params; |
| 127 params.notification_id = 0; | 121 params.notification_id = 0; |
| 128 params.origin = GURL("http://www.google.com"); | 122 params.origin = GURL("http://www.google.com"); |
| 129 params.is_html = false; | 123 params.is_html = false; |
| 130 params.icon_url = GURL("/icon.png"); | 124 params.icon_url = GURL("/icon.png"); |
| 131 params.title = ASCIIToUTF16("Title"); | 125 params.title = ASCIIToUTF16("Title"); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 } | 462 } |
| 469 | 463 |
| 470 // Now change the position to upper left. Confirm that the X value for the | 464 // Now change the position to upper left. Confirm that the X value for the |
| 471 // balloons gets smaller. | 465 // balloons gets smaller. |
| 472 local_state_.SetInteger(prefs::kDesktopNotificationPosition, | 466 local_state_.SetInteger(prefs::kDesktopNotificationPosition, |
| 473 BalloonCollection::UPPER_LEFT); | 467 BalloonCollection::UPPER_LEFT); |
| 474 | 468 |
| 475 int current_x = (*balloons.begin())->GetPosition().x(); | 469 int current_x = (*balloons.begin())->GetPosition().x(); |
| 476 EXPECT_LT(current_x, last_x); | 470 EXPECT_LT(current_x, last_x); |
| 477 } | 471 } |
| OLD | NEW |