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

Side by Side Diff: net/base/net_log_unittest.h

Issue 3119027: Adds HostResolveImpl Requests and Jobs to log. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 | « net/base/net_log_source_type_list.h ('k') | net/proxy/proxy_script_fetcher_unittest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 NET_BASE_NET_LOG_UNITTEST_H_ 5 #ifndef NET_BASE_NET_LOG_UNITTEST_H_
6 #define NET_BASE_NET_LOG_UNITTEST_H_ 6 #define NET_BASE_NET_LOG_UNITTEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <cstddef> 9 #include <cstddef>
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 if (j >= entries.size()) 99 if (j >= entries.size())
100 return ::testing::AssertionFailure() << j << " is out of bounds."; 100 return ::testing::AssertionFailure() << j << " is out of bounds.";
101 const CapturingNetLog::Entry& entry = entries[j]; 101 const CapturingNetLog::Entry& entry = entries[j];
102 if (entry.type != type) 102 if (entry.type != type)
103 return ::testing::AssertionFailure() << "Type does not match."; 103 return ::testing::AssertionFailure() << "Type does not match.";
104 return ::testing::AssertionSuccess(); 104 return ::testing::AssertionSuccess();
105 } 105 }
106 106
107 107
108 // Expect that the log contains an event, but don't care about where 108 // Expect that the log contains an event, but don't care about where
109 // as long as the index where it is found is greater than min_index. 109 // as long as the first index where it is found is at least |min_index|.
110 // Returns the position where the event was found. 110 // Returns the position where the event was found.
111 inline size_t ExpectLogContainsSomewhere( 111 inline size_t ExpectLogContainsSomewhere(
112 const CapturingNetLog::EntryList& entries, 112 const CapturingNetLog::EntryList& entries,
113 size_t min_index, 113 size_t min_index,
114 NetLog::EventType expected_event, 114 NetLog::EventType expected_event,
115 NetLog::EventPhase expected_phase) { 115 NetLog::EventPhase expected_phase) {
116 size_t i = 0; 116 size_t i = 0;
117 for (; i < entries.size(); ++i) { 117 for (; i < entries.size(); ++i) {
118 const CapturingNetLog::Entry& entry = entries[i]; 118 const CapturingNetLog::Entry& entry = entries[i];
119 if (entry.type == expected_event && 119 if (entry.type == expected_event &&
120 entry.phase == expected_phase) 120 entry.phase == expected_phase)
121 break; 121 break;
122 } 122 }
123 EXPECT_LT(i, entries.size()); 123 EXPECT_LT(i, entries.size());
124 EXPECT_GE(i, min_index); 124 EXPECT_GE(i, min_index);
125 return i; 125 return i;
126 } 126 }
127 127
128 // Expect that the log contains an event, but don't care about where
129 // as long as one index where it is found is at least |min_index|.
130 // Returns the first such position where the event was found.
131 inline size_t ExpectLogContainsSomewhereAfter(
132 const CapturingNetLog::EntryList& entries,
133 size_t min_index,
134 NetLog::EventType expected_event,
135 NetLog::EventPhase expected_phase) {
136 size_t i = min_index;
137 for (; i < entries.size(); ++i) {
138 const CapturingNetLog::Entry& entry = entries[i];
139 if (entry.type == expected_event &&
140 entry.phase == expected_phase)
141 break;
142 }
143 EXPECT_LT(i, entries.size());
144 return i;
145 }
146
128 } // namespace net 147 } // namespace net
129 148
130 #endif // NET_BASE_NET_LOG_UNITTEST_H_ 149 #endif // NET_BASE_NET_LOG_UNITTEST_H_
OLDNEW
« no previous file with comments | « net/base/net_log_source_type_list.h ('k') | net/proxy/proxy_script_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698