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.
5 #include "content/public/test/test_notification_tracker.h"
7 #include "content/public/browser/notification_service.h"
8 #include "content/public/browser/notification_types.h"
12 TestNotificationTracker::Event::Event()
13 : type(NOTIFICATION_ALL
),
14 source(NotificationService::AllSources()),
15 details(NotificationService::NoDetails()) {
17 TestNotificationTracker::Event::Event(int t
,
19 NotificationDetails d
)
25 TestNotificationTracker::TestNotificationTracker() {
28 TestNotificationTracker::~TestNotificationTracker() {
31 void TestNotificationTracker::ListenFor(
33 const NotificationSource
& source
) {
34 registrar_
.Add(this, type
, source
);
37 void TestNotificationTracker::Reset() {
41 bool TestNotificationTracker::Check1AndReset(int type
) {
46 bool success
= events_
[0].type
== type
;
51 bool TestNotificationTracker::Check2AndReset(int type1
,
57 bool success
= events_
[0].type
== type1
&& events_
[1].type
== type2
;
62 bool TestNotificationTracker::Check3AndReset(int type1
,
69 bool success
= events_
[0].type
== type1
&&
70 events_
[1].type
== type2
&&
71 events_
[2].type
== type3
;
76 void TestNotificationTracker::Observe(
78 const NotificationSource
& source
,
79 const NotificationDetails
& details
) {
80 events_
.push_back(Event(type
, source
, details
));
83 } // namespace content