| OLD | NEW |
| 1 // Copyright (c) 2010 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/chromeos/notifications/desktop_notifications_unittest.h
" | 5 #include "chrome/browser/chromeos/notifications/desktop_notifications_unittest.h
" |
| 6 | 6 |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/prefs/browser_prefs.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/common/render_messages_params.h" | 11 #include "chrome/common/render_messages_params.h" |
| 10 #include "chrome/test/testing_pref_service.h" | |
| 11 | 12 |
| 12 namespace chromeos { | 13 namespace chromeos { |
| 13 | 14 |
| 14 // static | 15 // static |
| 15 std::string DesktopNotificationsTest::log_output_; | 16 std::string DesktopNotificationsTest::log_output_; |
| 16 | 17 |
| 17 class MockNotificationUI : public BalloonCollectionImpl::NotificationUI { | 18 class MockNotificationUI : public BalloonCollectionImpl::NotificationUI { |
| 18 public: | 19 public: |
| 19 virtual void Add(Balloon* balloon) {} | 20 virtual void Add(Balloon* balloon) {} |
| 20 virtual bool Update(Balloon* balloon) { return false; } | 21 virtual bool Update(Balloon* balloon) { return false; } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 70 } |
| 70 | 71 |
| 71 DesktopNotificationsTest::DesktopNotificationsTest() | 72 DesktopNotificationsTest::DesktopNotificationsTest() |
| 72 : ui_thread_(BrowserThread::UI, &message_loop_) { | 73 : ui_thread_(BrowserThread::UI, &message_loop_) { |
| 73 } | 74 } |
| 74 | 75 |
| 75 DesktopNotificationsTest::~DesktopNotificationsTest() { | 76 DesktopNotificationsTest::~DesktopNotificationsTest() { |
| 76 } | 77 } |
| 77 | 78 |
| 78 void DesktopNotificationsTest::SetUp() { | 79 void DesktopNotificationsTest::SetUp() { |
| 80 browser::RegisterLocalState(&local_state_); |
| 79 profile_.reset(new TestingProfile()); | 81 profile_.reset(new TestingProfile()); |
| 80 balloon_collection_ = new MockBalloonCollection(); | 82 balloon_collection_ = new MockBalloonCollection(); |
| 81 ui_manager_.reset( | 83 ui_manager_.reset(new NotificationUIManager(&local_state_)); |
| 82 new NotificationUIManager(profile_->GetTestingPrefService())); | |
| 83 ui_manager_->Initialize(balloon_collection_); | 84 ui_manager_->Initialize(balloon_collection_); |
| 84 balloon_collection_->set_space_change_listener(ui_manager_.get()); | 85 balloon_collection_->set_space_change_listener(ui_manager_.get()); |
| 85 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); | 86 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); |
| 86 log_output_.clear(); | 87 log_output_.clear(); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void DesktopNotificationsTest::TearDown() { | 90 void DesktopNotificationsTest::TearDown() { |
| 90 service_.reset(NULL); | 91 service_.reset(NULL); |
| 91 ui_manager_.reset(NULL); | 92 ui_manager_.reset(NULL); |
| 92 profile_.reset(NULL); | 93 profile_.reset(NULL); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 262 |
| 262 MessageLoopForUI::current()->RunAllPending(); | 263 MessageLoopForUI::current()->RunAllPending(); |
| 263 EXPECT_EQ(1, balloon_collection_->count()); | 264 EXPECT_EQ(1, balloon_collection_->count()); |
| 264 Balloon* balloon = (*balloon_collection_->balloons().begin()); | 265 Balloon* balloon = (*balloon_collection_->balloons().begin()); |
| 265 GURL data_url = balloon->notification().content_url(); | 266 GURL data_url = balloon->notification().content_url(); |
| 266 EXPECT_EQ(std::string::npos, data_url.spec().find("<script>")); | 267 EXPECT_EQ(std::string::npos, data_url.spec().find("<script>")); |
| 267 EXPECT_EQ(std::string::npos, data_url.spec().find("<i>")); | 268 EXPECT_EQ(std::string::npos, data_url.spec().find("<i>")); |
| 268 } | 269 } |
| 269 | 270 |
| 270 } // namespace chromeos | 271 } // namespace chromeos |
| OLD | NEW |