Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/test/test_notification_tracker.h

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/plugin/pdf_browsertest.cc ('k') | chrome/test/test_notification_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CHROME_TEST_TEST_NOTIFICATION_TRACKER_H_ 5 #ifndef CHROME_TEST_TEST_NOTIFICATION_TRACKER_H_
6 #define CHROME_TEST_TEST_NOTIFICATION_TRACKER_H_ 6 #define CHROME_TEST_TEST_NOTIFICATION_TRACKER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "content/common/notification_details.h" 11 #include "content/common/notification_details.h"
12 #include "content/common/notification_observer.h" 12 #include "content/common/notification_observer.h"
13 #include "content/common/notification_registrar.h" 13 #include "content/common/notification_registrar.h"
14 #include "content/common/notification_source.h" 14 #include "content/common/notification_source.h"
15 15
16 // Provides an easy way for tests to verify that a given set of notifications 16 // Provides an easy way for tests to verify that a given set of notifications
17 // was received during test execution. 17 // was received during test execution.
18 class TestNotificationTracker : public NotificationObserver { 18 class TestNotificationTracker : public NotificationObserver {
19 public: 19 public:
20 // Records one received notification. 20 // Records one received notification.
21 struct Event { 21 struct Event {
22 Event(); 22 Event();
23 Event(NotificationType t, NotificationSource s, NotificationDetails d); 23 Event(int t, NotificationSource s, NotificationDetails d);
24 24
25 NotificationType type; 25 int type;
26 NotificationSource source; 26 NotificationSource source;
27 NotificationDetails details; 27 NotificationDetails details;
28 }; 28 };
29 29
30 // By default, it won't listen for any notifications. You'll need to call 30 // By default, it won't listen for any notifications. You'll need to call
31 // ListenFor for the notifications you are interested in. 31 // ListenFor for the notifications you are interested in.
32 TestNotificationTracker(); 32 TestNotificationTracker();
33 33
34 virtual ~TestNotificationTracker(); 34 virtual ~TestNotificationTracker();
35 35
36 // Makes this object listen for the given notification with the given source. 36 // Makes this object listen for the given notification with the given source.
37 void ListenFor(NotificationType type, const NotificationSource& source); 37 void ListenFor(int type, const NotificationSource& source);
38 38
39 // Makes this object listen for notifications of the given type coming from 39 // Makes this object listen for notifications of the given type coming from
40 // any source. 40 // any source.
41 void ListenForAll(NotificationType type); 41 void ListenForAll(int type);
42 42
43 // Clears the list of events. 43 // Clears the list of events.
44 void Reset(); 44 void Reset();
45 45
46 // Given notifications type(sp, returns true if the list of notifications 46 // Given notifications type(sp, returns true if the list of notifications
47 // were exactly those listed in the given arg(s), and in the same order. 47 // were exactly those listed in the given arg(s), and in the same order.
48 // 48 //
49 // This will also reset the list so that the next call will only check for 49 // This will also reset the list so that the next call will only check for
50 // new notifications. Example: 50 // new notifications. Example:
51 // <do stuff> 51 // <do stuff>
52 // Check1AndReset(NOTIFY_A); 52 // Check1AndReset(NOTIFY_A);
53 // <do stuff> 53 // <do stuff>
54 // Check2AndReset(NOTIFY_B, NOTIFY_C) 54 // Check2AndReset(NOTIFY_B, NOTIFY_C)
55 bool Check1AndReset(NotificationType type); 55 bool Check1AndReset(int type);
56 bool Check2AndReset(NotificationType type1, 56 bool Check2AndReset(int type1,
57 NotificationType type2); 57 int type2);
58 bool Check3AndReset(NotificationType type1, 58 bool Check3AndReset(int type1,
59 NotificationType type2, 59 int type2,
60 NotificationType type3); 60 int type3);
61 61
62 // Returns the number of notifications received since the last reset. 62 // Returns the number of notifications received since the last reset.
63 size_t size() const { return events_.size(); } 63 size_t size() const { return events_.size(); }
64 64
65 // Returns the information about the event at the given index. The index must 65 // Returns the information about the event at the given index. The index must
66 // be in [0, size). 66 // be in [0, size).
67 const Event& at(size_t i) const { return events_[i]; } 67 const Event& at(size_t i) const { return events_[i]; }
68 68
69 protected: 69 protected:
70 virtual void Observe(NotificationType type, 70 virtual void Observe(int type,
71 const NotificationSource& source, 71 const NotificationSource& source,
72 const NotificationDetails& details); 72 const NotificationDetails& details);
73 private: 73 private:
74 NotificationRegistrar registrar_; 74 NotificationRegistrar registrar_;
75 75
76 // Lists all received since last cleared, in the order they were received. 76 // Lists all received since last cleared, in the order they were received.
77 std::vector<Event> events_; 77 std::vector<Event> events_;
78 78
79 DISALLOW_COPY_AND_ASSIGN(TestNotificationTracker); 79 DISALLOW_COPY_AND_ASSIGN(TestNotificationTracker);
80 }; 80 };
81 81
82 #endif // CHROME_TEST_TEST_NOTIFICATION_TRACKER_H_ 82 #endif // CHROME_TEST_TEST_NOTIFICATION_TRACKER_H_
OLDNEW
« no previous file with comments | « chrome/test/plugin/pdf_browsertest.cc ('k') | chrome/test/test_notification_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698