Add ICU message format support
[chromium-blink-merge.git] / content / public / test / test_notification_tracker.cc
blobbf166e724ae2fdae6670e7383bc9d42b41bf1214
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"
10 namespace content {
12 TestNotificationTracker::Event::Event()
13 : type(NOTIFICATION_ALL),
14 source(NotificationService::AllSources()),
15 details(NotificationService::NoDetails()) {
17 TestNotificationTracker::Event::Event(int t,
18 NotificationSource s,
19 NotificationDetails d)
20 : type(t),
21 source(s),
22 details(d) {
25 TestNotificationTracker::TestNotificationTracker() {
28 TestNotificationTracker::~TestNotificationTracker() {
31 void TestNotificationTracker::ListenFor(
32 int type,
33 const NotificationSource& source) {
34 registrar_.Add(this, type, source);
37 void TestNotificationTracker::Reset() {
38 events_.clear();
41 bool TestNotificationTracker::Check1AndReset(int type) {
42 if (size() != 1) {
43 Reset();
44 return false;
46 bool success = events_[0].type == type;
47 Reset();
48 return success;
51 bool TestNotificationTracker::Check2AndReset(int type1,
52 int type2) {
53 if (size() != 2) {
54 Reset();
55 return false;
57 bool success = events_[0].type == type1 && events_[1].type == type2;
58 Reset();
59 return success;
62 bool TestNotificationTracker::Check3AndReset(int type1,
63 int type2,
64 int type3) {
65 if (size() != 3) {
66 Reset();
67 return false;
69 bool success = events_[0].type == type1 &&
70 events_[1].type == type2 &&
71 events_[2].type == type3;
72 Reset();
73 return success;
76 void TestNotificationTracker::Observe(
77 int type,
78 const NotificationSource& source,
79 const NotificationDetails& details) {
80 events_.push_back(Event(type, source, details));
83 } // namespace content