| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/common/render_messages_params.h" | 9 #include "chrome/common/render_messages_params.h" | 
| 10 | 10 | 
| 11 namespace chromeos { | 11 namespace chromeos { | 
| 12 | 12 | 
| 13 // static | 13 // static | 
| 14 std::string DesktopNotificationsTest::log_output_; | 14 std::string DesktopNotificationsTest::log_output_; | 
| 15 | 15 | 
| 16 class MockNotificationUI : public BalloonCollectionImpl::NotificationUI { | 16 class MockNotificationUI : public BalloonCollectionImpl::NotificationUI { | 
| 17  public: | 17  public: | 
| 18   virtual void Add(Balloon* balloon) {} | 18   virtual void Add(Balloon* balloon) {} | 
| 19   virtual bool Update(Balloon* balloon) { return false; } | 19   virtual bool Update(Balloon* balloon) { return false; } | 
| 20   virtual void Remove(Balloon* balloon) {} | 20   virtual void Remove(Balloon* balloon) {} | 
| 21   virtual void Show(Balloon* balloon) {} | 21   virtual void Show(Balloon* balloon) {} | 
| 22   virtual void ResizeNotification(Balloon* balloon, | 22   virtual void ResizeNotification(Balloon* balloon, | 
| 23                                   const gfx::Size& size) {} | 23                                   const gfx::Size& size) {} | 
| 24   virtual void SetActiveView(BalloonViewImpl* view) {} | 24   virtual void SetActiveView(BalloonViewImpl* view) {} | 
| 25 }; | 25 }; | 
| 26 | 26 | 
| 27 MockBalloonCollection::MockBalloonCollection() | 27 MockBalloonCollection::MockBalloonCollection() { | 
| 28     : log_proxy_(new LoggingNotificationProxy()) { |  | 
| 29   set_notification_ui(new MockNotificationUI()); | 28   set_notification_ui(new MockNotificationUI()); | 
| 30 } | 29 } | 
| 31 | 30 | 
| 32 void MockBalloonCollection::Add(const Notification& notification, | 31 void MockBalloonCollection::Add(const Notification& notification, | 
| 33                                 Profile* profile) { | 32                                 Profile* profile) { | 
| 34   // Swap in the logging proxy for the purpose of logging calls that | 33   // Swap in a logging proxy for the purpose of logging calls that | 
| 35   // would be made into javascript, then pass this down to the | 34   // would be made into javascript, then pass this down to the | 
| 36   // balloon collection. | 35   // balloon collection. | 
| 37   Notification test_notification(notification.origin_url(), | 36   Notification test_notification( | 
| 38                                  notification.content_url(), | 37       notification.origin_url(), | 
| 39                                  notification.display_source(), | 38       notification.content_url(), | 
| 40                                  string16(), /* replace_id */ | 39       notification.display_source(), | 
| 41                                  log_proxy_.get()); | 40       notification.replace_id(), | 
|  | 41       new LoggingNotificationProxy(notification.notification_id())); | 
| 42   BalloonCollectionImpl::Add(test_notification, profile); | 42   BalloonCollectionImpl::Add(test_notification, profile); | 
| 43 } | 43 } | 
| 44 | 44 | 
| 45 bool MockBalloonCollection::Remove(const Notification& notification) { |  | 
| 46   Notification test_notification(notification.origin_url(), |  | 
| 47                                  notification.content_url(), |  | 
| 48                                  notification.display_source(), |  | 
| 49                                  string16(), /* replace_id */ |  | 
| 50                                  log_proxy_.get()); |  | 
| 51   return BalloonCollectionImpl::Remove(test_notification); |  | 
| 52 } |  | 
| 53 |  | 
| 54 Balloon* MockBalloonCollection::MakeBalloon(const Notification& notification, | 45 Balloon* MockBalloonCollection::MakeBalloon(const Notification& notification, | 
| 55                                             Profile* profile) { | 46                                             Profile* profile) { | 
| 56   // Start with a normal balloon but mock out the view. | 47   // Start with a normal balloon but mock out the view. | 
| 57   Balloon* balloon = BalloonCollectionImpl::MakeBalloon(notification, profile); | 48   Balloon* balloon = BalloonCollectionImpl::MakeBalloon(notification, profile); | 
| 58   balloon->set_view(new MockBalloonView(balloon)); | 49   balloon->set_view(new MockBalloonView(balloon)); | 
| 59   balloons_.insert(balloon); | 50   balloons_.insert(balloon); | 
| 60   return balloon; | 51   return balloon; | 
| 61 } | 52 } | 
| 62 | 53 | 
| 63 void MockBalloonCollection::OnBalloonClosed(Balloon* source) { | 54 void MockBalloonCollection::OnBalloonClosed(Balloon* source) { | 
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 268 | 259 | 
| 269   MessageLoopForUI::current()->RunAllPending(); | 260   MessageLoopForUI::current()->RunAllPending(); | 
| 270   EXPECT_EQ(1, balloon_collection_->count()); | 261   EXPECT_EQ(1, balloon_collection_->count()); | 
| 271   Balloon* balloon = (*balloon_collection_->balloons().begin()); | 262   Balloon* balloon = (*balloon_collection_->balloons().begin()); | 
| 272   GURL data_url = balloon->notification().content_url(); | 263   GURL data_url = balloon->notification().content_url(); | 
| 273   EXPECT_EQ(std::string::npos, data_url.spec().find("<script>")); | 264   EXPECT_EQ(std::string::npos, data_url.spec().find("<script>")); | 
| 274   EXPECT_EQ(std::string::npos, data_url.spec().find("<i>")); | 265   EXPECT_EQ(std::string::npos, data_url.spec().find("<i>")); | 
| 275 } | 266 } | 
| 276 | 267 | 
| 277 }  // namespace chromeos | 268 }  // namespace chromeos | 
| OLD | NEW | 
|---|