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

Side by Side Diff: content/public/test/test_notification_tracker.h

Issue 13533007: Test extension reloading behavior. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_PUBLIC_TEST_TEST_NOTIFICATION_TRACKER_H_ 5 #ifndef CONTENT_PUBLIC_TEST_TEST_NOTIFICATION_TRACKER_H_
6 #define CONTENT_PUBLIC_TEST_TEST_NOTIFICATION_TRACKER_H_ 6 #define CONTENT_PUBLIC_TEST_TEST_NOTIFICATION_TRACKER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 27 matching lines...) Expand all
38 // Makes this object listen for the given notification with the given source. 38 // Makes this object listen for the given notification with the given source.
39 void ListenFor(int type, const NotificationSource& source); 39 void ListenFor(int type, const NotificationSource& source);
40 40
41 // Makes this object listen for notifications of the given type coming from 41 // Makes this object listen for notifications of the given type coming from
42 // any source. 42 // any source.
43 void ListenForAll(int type); 43 void ListenForAll(int type);
44 44
45 // Clears the list of events. 45 // Clears the list of events.
46 void Reset(); 46 void Reset();
47 47
48 // Given notifications type(sp, returns true if the list of notifications 48 // Given notifications type(sp, returns true if the list of notifications
Paweł Hajdan Jr. 2013/04/04 21:30:05 If you're adding methods below, please remove ones
Jeffrey Yasskin 2013/04/05 13:14:01 There are 81 calls to Check1AndReset across the co
Paweł Hajdan Jr. 2013/04/08 20:03:51 Please add TODOs then.
Jeffrey Yasskin 2013/04/08 22:09:38 Will do.
Jeffrey Yasskin 2013/04/08 22:38:02 Done.
49 // were exactly those listed in the given arg(s), and in the same order. 49 // were exactly those listed in the given arg(s), and in the same order.
50 // 50 //
51 // This will also reset the list so that the next call will only check for 51 // This will also reset the list so that the next call will only check for
52 // new notifications. Example: 52 // new notifications. Example:
53 // <do stuff> 53 // <do stuff>
54 // Check1AndReset(NOTIFY_A); 54 // Check1AndReset(NOTIFY_A);
55 // <do stuff> 55 // <do stuff>
56 // Check2AndReset(NOTIFY_B, NOTIFY_C) 56 // Check2AndReset(NOTIFY_B, NOTIFY_C)
57 bool Check1AndReset(int type); 57 bool Check1AndReset(int type);
58 bool Check2AndReset(int type1, 58 bool Check2AndReset(int type1,
59 int type2); 59 int type2);
60 bool Check3AndReset(int type1, 60 bool Check3AndReset(int type1,
61 int type2, 61 int type2,
62 int type3); 62 int type3);
63 63
64 // Returns the types of the received notifications in order. Usable
65 // with EXPECT_THAT(ElementsAre):
66 // EXPECT_THAT(tracker.GetTypesAndReset(),
67 // testing::ElementsAre(content::NOTIFICATION_LOAD_START, ...));
68 std::vector<int> GetTypes() const;
69
70 // Like GetTypes, but also calls Reset() so that the next call will
71 // only check for new notifications.
72 std::vector<int> GetTypesAndReset() {
73 std::vector<int> result = GetTypes();
74 Reset();
75 return result;
76 }
77
64 // Returns the number of notifications received since the last reset. 78 // Returns the number of notifications received since the last reset.
65 size_t size() const { return events_.size(); } 79 size_t size() const { return events_.size(); }
66 80
67 // Returns the information about the event at the given index. The index must 81 // Returns the information about the event at the given index. The index must
68 // be in [0, size). 82 // be in [0, size).
69 const Event& at(size_t i) const { return events_[i]; } 83 const Event& at(size_t i) const { return events_[i]; }
70 84
71 protected: 85 protected:
72 virtual void Observe(int type, 86 virtual void Observe(int type,
73 const NotificationSource& source, 87 const NotificationSource& source,
74 const NotificationDetails& details) OVERRIDE; 88 const NotificationDetails& details) OVERRIDE;
75 private: 89 private:
76 NotificationRegistrar registrar_; 90 NotificationRegistrar registrar_;
77 91
78 // Lists all received since last cleared, in the order they were received. 92 // Lists all received since last cleared, in the order they were received.
79 std::vector<Event> events_; 93 std::vector<Event> events_;
80 94
81 DISALLOW_COPY_AND_ASSIGN(TestNotificationTracker); 95 DISALLOW_COPY_AND_ASSIGN(TestNotificationTracker);
82 }; 96 };
83 97
84 } // namespace content 98 } // namespace content
85 99
86 #endif // CONTENT_PUBLIC_TEST_TEST_NOTIFICATION_TRACKER_H_ 100 #endif // CONTENT_PUBLIC_TEST_TEST_NOTIFICATION_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698