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