| 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 #ifndef CONTENT_TEST_TEST_NOTIFICATION_TRACKER_H_ | 5 #ifndef CONTENT_TEST_TEST_NOTIFICATION_TRACKER_H_ |
| 6 #define CONTENT_TEST_TEST_NOTIFICATION_TRACKER_H_ | 6 #define CONTENT_TEST_TEST_NOTIFICATION_TRACKER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" |
| 11 #include "content/public/browser/notification_details.h" | 12 #include "content/public/browser/notification_details.h" |
| 12 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 14 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
| 15 | 16 |
| 16 // Provides an easy way for tests to verify that a given set of notifications | 17 // Provides an easy way for tests to verify that a given set of notifications |
| 17 // was received during test execution. | 18 // was received during test execution. |
| 18 class TestNotificationTracker : public content::NotificationObserver { | 19 class TestNotificationTracker : public content::NotificationObserver { |
| 19 public: | 20 public: |
| 20 // Records one received notification. | 21 // Records one received notification. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Returns the number of notifications received since the last reset. | 63 // Returns the number of notifications received since the last reset. |
| 63 size_t size() const { return events_.size(); } | 64 size_t size() const { return events_.size(); } |
| 64 | 65 |
| 65 // Returns the information about the event at the given index. The index must | 66 // Returns the information about the event at the given index. The index must |
| 66 // be in [0, size). | 67 // be in [0, size). |
| 67 const Event& at(size_t i) const { return events_[i]; } | 68 const Event& at(size_t i) const { return events_[i]; } |
| 68 | 69 |
| 69 protected: | 70 protected: |
| 70 virtual void Observe(int type, | 71 virtual void Observe(int type, |
| 71 const content::NotificationSource& source, | 72 const content::NotificationSource& source, |
| 72 const content::NotificationDetails& details); | 73 const content::NotificationDetails& details) OVERRIDE; |
| 73 private: | 74 private: |
| 74 content::NotificationRegistrar registrar_; | 75 content::NotificationRegistrar registrar_; |
| 75 | 76 |
| 76 // Lists all received since last cleared, in the order they were received. | 77 // Lists all received since last cleared, in the order they were received. |
| 77 std::vector<Event> events_; | 78 std::vector<Event> events_; |
| 78 | 79 |
| 79 DISALLOW_COPY_AND_ASSIGN(TestNotificationTracker); | 80 DISALLOW_COPY_AND_ASSIGN(TestNotificationTracker); |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 #endif // CONTENT_TEST_TEST_NOTIFICATION_TRACKER_H_ | 83 #endif // CONTENT_TEST_TEST_NOTIFICATION_TRACKER_H_ |
| OLD | NEW |