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

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: Add a ScopedOleInitializer for Windows 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 // TODO(jyasskin): Replace calls to Check*AndReset() with
49 // EXPECT_THAT(GetTypesAndReset()).
50 //
48 // Given notifications type(sp, returns true if the list of notifications 51 // Given notifications type(sp, returns true if the list of notifications
49 // were exactly those listed in the given arg(s), and in the same order. 52 // were exactly those listed in the given arg(s), and in the same order.
50 // 53 //
51 // This will also reset the list so that the next call will only check for 54 // This will also reset the list so that the next call will only check for
52 // new notifications. Example: 55 // new notifications. Example:
53 // <do stuff> 56 // <do stuff>
54 // Check1AndReset(NOTIFY_A); 57 // Check1AndReset(NOTIFY_A);
55 // <do stuff> 58 // <do stuff>
56 // Check2AndReset(NOTIFY_B, NOTIFY_C) 59 // Check2AndReset(NOTIFY_B, NOTIFY_C)
57 bool Check1AndReset(int type); 60 bool Check1AndReset(int type);
58 bool Check2AndReset(int type1, 61 bool Check2AndReset(int type1,
59 int type2); 62 int type2);
60 bool Check3AndReset(int type1, 63 bool Check3AndReset(int type1,
61 int type2, 64 int type2,
62 int type3); 65 int type3);
63 66
67 // Returns the types of the received notifications in order. Usable
68 // with EXPECT_THAT(ElementsAre):
69 // EXPECT_THAT(tracker.GetTypesAndReset(),
70 // testing::ElementsAre(content::NOTIFICATION_LOAD_START, ...));
71 std::vector<int> GetTypes() const;
72
73 // Like GetTypes, but also calls Reset() so that the next call will
74 // only check for new notifications.
75 std::vector<int> GetTypesAndReset() {
76 std::vector<int> result = GetTypes();
77 Reset();
78 return result;
79 }
80
64 // Returns the number of notifications received since the last reset. 81 // Returns the number of notifications received since the last reset.
65 size_t size() const { return events_.size(); } 82 size_t size() const { return events_.size(); }
66 83
67 // Returns the information about the event at the given index. The index must 84 // Returns the information about the event at the given index. The index must
68 // be in [0, size). 85 // be in [0, size).
69 const Event& at(size_t i) const { return events_[i]; } 86 const Event& at(size_t i) const { return events_[i]; }
70 87
71 protected: 88 protected:
72 virtual void Observe(int type, 89 virtual void Observe(int type,
73 const NotificationSource& source, 90 const NotificationSource& source,
74 const NotificationDetails& details) OVERRIDE; 91 const NotificationDetails& details) OVERRIDE;
75 private: 92 private:
76 NotificationRegistrar registrar_; 93 NotificationRegistrar registrar_;
77 94
78 // Lists all received since last cleared, in the order they were received. 95 // Lists all received since last cleared, in the order they were received.
79 std::vector<Event> events_; 96 std::vector<Event> events_;
80 97
81 DISALLOW_COPY_AND_ASSIGN(TestNotificationTracker); 98 DISALLOW_COPY_AND_ASSIGN(TestNotificationTracker);
82 }; 99 };
83 100
84 } // namespace content 101 } // namespace content
85 102
86 #endif // CONTENT_PUBLIC_TEST_TEST_NOTIFICATION_TRACKER_H_ 103 #endif // CONTENT_PUBLIC_TEST_TEST_NOTIFICATION_TRACKER_H_
OLDNEW
« no previous file with comments | « content/public/test/mock_render_process_host.cc ('k') | content/public/test/test_notification_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698