| 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/public/test/test_notification_tracker.h" | 5 #include "content/public/test/test_notification_tracker.h" |
| 6 | 6 |
| 7 #include "content/public/browser/notification_service.h" | 7 #include "content/public/browser/notification_service.h" |
| 8 #include "content/public/browser/notification_types.h" | 8 #include "content/public/browser/notification_types.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 TestNotificationTracker::~TestNotificationTracker() { | 28 TestNotificationTracker::~TestNotificationTracker() { |
| 29 } | 29 } |
| 30 | 30 |
| 31 void TestNotificationTracker::ListenFor( | 31 void TestNotificationTracker::ListenFor( |
| 32 int type, | 32 int type, |
| 33 const NotificationSource& source) { | 33 const NotificationSource& source) { |
| 34 registrar_.Add(this, type, source); | 34 registrar_.Add(this, type, source); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void TestNotificationTracker::ListenForAll(int type) { |
| 38 registrar_.Add(this, type, |
| 39 NotificationService::AllBrowserContextsAndSources()); |
| 40 } |
| 41 |
| 37 void TestNotificationTracker::Reset() { | 42 void TestNotificationTracker::Reset() { |
| 38 events_.clear(); | 43 events_.clear(); |
| 39 } | 44 } |
| 40 | 45 |
| 41 bool TestNotificationTracker::Check1AndReset(int type) { | 46 bool TestNotificationTracker::Check1AndReset(int type) { |
| 42 if (size() != 1) { | 47 if (size() != 1) { |
| 43 Reset(); | 48 Reset(); |
| 44 return false; | 49 return false; |
| 45 } | 50 } |
| 46 bool success = events_[0].type == type; | 51 bool success = events_[0].type == type; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 66 Reset(); | 71 Reset(); |
| 67 return false; | 72 return false; |
| 68 } | 73 } |
| 69 bool success = events_[0].type == type1 && | 74 bool success = events_[0].type == type1 && |
| 70 events_[1].type == type2 && | 75 events_[1].type == type2 && |
| 71 events_[2].type == type3; | 76 events_[2].type == type3; |
| 72 Reset(); | 77 Reset(); |
| 73 return success; | 78 return success; |
| 74 } | 79 } |
| 75 | 80 |
| 81 std::vector<int> TestNotificationTracker::GetTypes() const { |
| 82 std::vector<int> types; |
| 83 for (size_t i = 0; i < size(); ++i) |
| 84 types.push_back(at(i).type); |
| 85 return types; |
| 86 } |
| 87 |
| 76 void TestNotificationTracker::Observe( | 88 void TestNotificationTracker::Observe( |
| 77 int type, | 89 int type, |
| 78 const NotificationSource& source, | 90 const NotificationSource& source, |
| 79 const NotificationDetails& details) { | 91 const NotificationDetails& details) { |
| 80 events_.push_back(Event(type, source, details)); | 92 events_.push_back(Event(type, source, details)); |
| 81 } | 93 } |
| 82 | 94 |
| 83 } // namespace content | 95 } // namespace content |
| OLD | NEW |