| 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 "content/browser/notification_service_impl.h" | 5 #include "content/browser/notification_service_impl.h" |
| 6 | 6 |
| 7 #include "content/public/browser/notification_observer.h" | 7 #include "content/public/browser/notification_observer.h" |
| 8 #include "content/public/browser/notification_registrar.h" | 8 #include "content/public/browser/notification_registrar.h" |
| 9 #include "content/public/browser/notification_types.h" | 9 #include "content/public/browser/notification_types.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Bogus class to act as a NotificationSource for the messages. | 16 // Bogus class to act as a NotificationSource for the messages. |
| 17 class TestSource {}; | 17 class TestSource {}; |
| 18 | 18 |
| 19 class TestObserver : public NotificationObserver { | 19 class TestObserver : public NotificationObserver { |
| 20 public: | 20 public: |
| 21 TestObserver() : notification_count_(0) {} | 21 TestObserver() : notification_count_(0) {} |
| 22 | 22 |
| 23 int notification_count() const { return notification_count_; } | 23 int notification_count() const { return notification_count_; } |
| 24 | 24 |
| 25 virtual void Observe(int type, | 25 void Observe(int type, |
| 26 const NotificationSource& source, | 26 const NotificationSource& source, |
| 27 const NotificationDetails& details) override { | 27 const NotificationDetails& details) override { |
| 28 ++notification_count_; | 28 ++notification_count_; |
| 29 } | 29 } |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 int notification_count_; | 32 int notification_count_; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 const int kNotification1 = 1; | 35 const int kNotification1 = 1; |
| 36 const int kNotification2 = 2; | 36 const int kNotification2 = 2; |
| 37 | 37 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 registrar_.Remove(&idle_test_source, NOTIFICATION_ALL, | 164 registrar_.Remove(&idle_test_source, NOTIFICATION_ALL, |
| 165 Source<TestSource>(&test_source)); | 165 Source<TestSource>(&test_source)); |
| 166 | 166 |
| 167 service->Notify(kNotification1, | 167 service->Notify(kNotification1, |
| 168 Source<TestSource>(&test_source), | 168 Source<TestSource>(&test_source), |
| 169 NotificationService::NoDetails()); | 169 NotificationService::NoDetails()); |
| 170 EXPECT_EQ(3, idle_test_source.notification_count()); | 170 EXPECT_EQ(3, idle_test_source.notification_count()); |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace content | 173 } // namespace content |
| OLD | NEW |