| 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 "chrome/test/test_notification_tracker.h" | 5 #include "chrome/test/test_notification_tracker.h" |
| 6 | 6 |
| 7 #include "content/common/notification_service.h" | 7 #include "content/common/notification_service.h" |
| 8 | 8 |
| 9 TestNotificationTracker::Event::Event() | 9 TestNotificationTracker::Event::Event() |
| 10 : type(NotificationType::ALL), | 10 : type(content::NOTIFICATION_ALL), |
| 11 source(NotificationService::AllSources()), | 11 source(NotificationService::AllSources()), |
| 12 details(NotificationService::NoDetails()) { | 12 details(NotificationService::NoDetails()) { |
| 13 } | 13 } |
| 14 TestNotificationTracker::Event::Event(NotificationType t, | 14 TestNotificationTracker::Event::Event(int t, |
| 15 NotificationSource s, | 15 NotificationSource s, |
| 16 NotificationDetails d) | 16 NotificationDetails d) |
| 17 : type(t), | 17 : type(t), |
| 18 source(s), | 18 source(s), |
| 19 details(d) { | 19 details(d) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 TestNotificationTracker::TestNotificationTracker() { | 22 TestNotificationTracker::TestNotificationTracker() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 TestNotificationTracker::~TestNotificationTracker() { | 25 TestNotificationTracker::~TestNotificationTracker() { |
| 26 } | 26 } |
| 27 | 27 |
| 28 void TestNotificationTracker::ListenFor(NotificationType type, | 28 void TestNotificationTracker::ListenFor(int type, |
| 29 const NotificationSource& source) { | 29 const NotificationSource& source) { |
| 30 registrar_.Add(this, type, source); | 30 registrar_.Add(this, type, source); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void TestNotificationTracker::Reset() { | 33 void TestNotificationTracker::Reset() { |
| 34 events_.clear(); | 34 events_.clear(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool TestNotificationTracker::Check1AndReset(NotificationType type) { | 37 bool TestNotificationTracker::Check1AndReset(int type) { |
| 38 if (size() != 1) { | 38 if (size() != 1) { |
| 39 Reset(); | 39 Reset(); |
| 40 return false; | 40 return false; |
| 41 } | 41 } |
| 42 bool success = events_[0].type == type; | 42 bool success = events_[0].type == type; |
| 43 Reset(); | 43 Reset(); |
| 44 return success; | 44 return success; |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool TestNotificationTracker::Check2AndReset(NotificationType type1, | 47 bool TestNotificationTracker::Check2AndReset(int type1, |
| 48 NotificationType type2) { | 48 int type2) { |
| 49 if (size() != 2) { | 49 if (size() != 2) { |
| 50 Reset(); | 50 Reset(); |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 bool success = events_[0].type == type1 && events_[1].type == type2; | 53 bool success = events_[0].type == type1 && events_[1].type == type2; |
| 54 Reset(); | 54 Reset(); |
| 55 return success; | 55 return success; |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool TestNotificationTracker::Check3AndReset(NotificationType type1, | 58 bool TestNotificationTracker::Check3AndReset(int type1, |
| 59 NotificationType type2, | 59 int type2, |
| 60 NotificationType type3) { | 60 int type3) { |
| 61 if (size() != 3) { | 61 if (size() != 3) { |
| 62 Reset(); | 62 Reset(); |
| 63 return false; | 63 return false; |
| 64 } | 64 } |
| 65 bool success = events_[0].type == type1 && | 65 bool success = events_[0].type == type1 && |
| 66 events_[1].type == type2 && | 66 events_[1].type == type2 && |
| 67 events_[2].type == type3; | 67 events_[2].type == type3; |
| 68 Reset(); | 68 Reset(); |
| 69 return success; | 69 return success; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void TestNotificationTracker::Observe(NotificationType type, | 72 void TestNotificationTracker::Observe(int type, |
| 73 const NotificationSource& source, | 73 const NotificationSource& source, |
| 74 const NotificationDetails& details) { | 74 const NotificationDetails& details) { |
| 75 events_.push_back(Event(type, source, details)); | 75 events_.push_back(Event(type, source, details)); |
| 76 } | 76 } |
| OLD | NEW |