| 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 #ifndef CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ | 
| 6 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_ | 
| 7 #pragma once | 7 #pragma once | 
| 8 | 8 | 
| 9 #include <set> | 9 #include <set> | 
| 10 #include <string> | 10 #include <string> | 
| 11 | 11 | 
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" | 
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" | 
| 14 #include "chrome/browser/browser_list.h" | 14 #include "chrome/browser/browser_list.h" | 
| 15 #include "chrome/browser/browser_thread.h" | 15 #include "chrome/browser/browser_thread.h" | 
| 16 #include "chrome/browser/chromeos/notifications/balloon_collection_impl.h" | 16 #include "chrome/browser/chromeos/notifications/balloon_collection_impl.h" | 
| 17 #include "chrome/browser/notifications/balloon.h" | 17 #include "chrome/browser/notifications/balloon.h" | 
| 18 #include "chrome/browser/notifications/desktop_notification_service.h" | 18 #include "chrome/browser/notifications/desktop_notification_service.h" | 
| 19 #include "chrome/browser/notifications/notification.h" | 19 #include "chrome/browser/notifications/notification.h" | 
| 20 #include "chrome/browser/notifications/notification_object_proxy.h" |  | 
| 21 #include "chrome/browser/notifications/notification_test_util.h" | 20 #include "chrome/browser/notifications/notification_test_util.h" | 
| 22 #include "chrome/browser/notifications/notification_ui_manager.h" | 21 #include "chrome/browser/notifications/notification_ui_manager.h" | 
| 23 #include "chrome/browser/notifications/notifications_prefs_cache.h" | 22 #include "chrome/browser/notifications/notifications_prefs_cache.h" | 
| 24 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" | 
| 25 #include "chrome/test/testing_profile.h" | 24 #include "chrome/test/testing_profile.h" | 
| 26 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" | 
| 27 | 26 | 
| 28 namespace chromeos { | 27 namespace chromeos { | 
| 29 | 28 | 
| 30 class DesktopNotificationsTest; | 29 class DesktopNotificationsTest; | 
| 31 typedef LoggingNotificationProxyBase<DesktopNotificationsTest> | 30 typedef LoggingNotificationDelegate<DesktopNotificationsTest> | 
| 32     LoggingNotificationProxy; | 31     LoggingNotificationProxy; | 
| 33 | 32 | 
| 34 // Test version of the balloon collection which counts the number | 33 // Test version of the balloon collection which counts the number | 
| 35 // of notifications that are added to it. | 34 // of notifications that are added to it. | 
| 36 class MockBalloonCollection : public BalloonCollectionImpl { | 35 class MockBalloonCollection : public BalloonCollectionImpl { | 
| 37  public: | 36  public: | 
| 38   MockBalloonCollection(); | 37   MockBalloonCollection(); | 
| 39 | 38 | 
| 40   // BalloonCollectionImpl overrides | 39   // BalloonCollectionImpl overrides | 
| 41   virtual void Add(const Notification& notification, | 40   virtual void Add(const Notification& notification, | 
| 42                    Profile* profile); | 41                    Profile* profile); | 
| 43   virtual bool Remove(const Notification& notification); |  | 
| 44   virtual Balloon* MakeBalloon(const Notification& notification, | 42   virtual Balloon* MakeBalloon(const Notification& notification, | 
| 45                                Profile* profile); | 43                                Profile* profile); | 
| 46   virtual void OnBalloonClosed(Balloon* source); | 44   virtual void OnBalloonClosed(Balloon* source); | 
| 47 | 45 | 
| 48   // Number of balloons being shown. | 46   // Number of balloons being shown. | 
| 49   std::set<Balloon*>& balloons() { return balloons_; } | 47   std::set<Balloon*>& balloons() { return balloons_; } | 
| 50   int count() const { return balloons_.size(); } | 48   int count() const { return balloons_.size(); } | 
| 51 | 49 | 
| 52   // Returns the highest y-coordinate of all the balloons in the collection. | 50   // Returns the highest y-coordinate of all the balloons in the collection. | 
| 53   int UppermostVerticalPosition(); | 51   int UppermostVerticalPosition(); | 
| 54 | 52 | 
| 55  private: | 53  private: | 
| 56   std::set<Balloon*> balloons_; | 54   std::set<Balloon*> balloons_; | 
| 57   scoped_refptr<LoggingNotificationProxy> log_proxy_; |  | 
| 58 }; | 55 }; | 
| 59 | 56 | 
| 60 class DesktopNotificationsTest : public testing::Test { | 57 class DesktopNotificationsTest : public testing::Test { | 
| 61  public: | 58  public: | 
| 62   DesktopNotificationsTest(); | 59   DesktopNotificationsTest(); | 
| 63   ~DesktopNotificationsTest(); | 60   ~DesktopNotificationsTest(); | 
| 64 | 61 | 
| 65   static void log(const std::string& message) { | 62   static void log(const std::string& message) { | 
| 66     log_output_.append(message); | 63     log_output_.append(message); | 
| 67   } | 64   } | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 105   // Real DesktopNotificationService | 102   // Real DesktopNotificationService | 
| 106   scoped_ptr<DesktopNotificationService> service_; | 103   scoped_ptr<DesktopNotificationService> service_; | 
| 107 | 104 | 
| 108   // Contains the cumulative output of the unit test. | 105   // Contains the cumulative output of the unit test. | 
| 109   static std::string log_output_; | 106   static std::string log_output_; | 
| 110 }; | 107 }; | 
| 111 | 108 | 
| 112 }  // namespace chromeos | 109 }  // namespace chromeos | 
| 113 | 110 | 
| 114 #endif  // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_
     H_ | 111 #endif  // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_
     H_ | 
| OLD | NEW | 
|---|