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

Unified Diff: net/base/net_log_unittest.h

Issue 848006: Generalize the net module's LoadLog facility from a passive container, to an event stream (NetLog). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Split up RequestTracker into ConnectJobTracker+RequestTracker+RequestTrackerBase, address comments Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/net_log_event_type_list.h ('k') | net/base/net_log_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_log_unittest.h
===================================================================
--- net/base/net_log_unittest.h (revision 40318)
+++ net/base/net_log_unittest.h (working copy)
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_BASE_LOAD_LOG_UNITTEST_H_
-#define NET_BASE_LOAD_LOG_UNITTEST_H_
+#ifndef NET_BASE_NET_LOG_UNITTEST_H_
+#define NET_BASE_NET_LOG_UNITTEST_H_
#include <cstddef>
-#include "net/base/load_log.h"
+#include <vector>
+#include "net/base/net_log.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
@@ -19,23 +20,23 @@
}
inline ::testing::AssertionResult LogContainsEventHelper(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& entries,
int i, // Negative indices are reverse indices.
const base::TimeTicks& expected_time,
bool check_time,
- LoadLog::EventType expected_event,
- LoadLog::EventPhase expected_phase) {
+ NetLog::EventType expected_event,
+ NetLog::EventPhase expected_phase) {
// Negative indices are reverse indices.
- size_t j = (i < 0) ? log.entries().size() + i : i;
- if (j >= log.entries().size())
+ size_t j = (i < 0) ? entries.size() + i : i;
+ if (j >= entries.size())
return ::testing::AssertionFailure() << j << " is out of bounds.";
- const LoadLog::Entry& entry = log.entries()[j];
- if (entry.type != LoadLog::Entry::TYPE_EVENT)
+ const NetLog::Entry& entry = entries[j];
+ if (entry.type != NetLog::Entry::TYPE_EVENT)
return ::testing::AssertionFailure() << "Not a TYPE_EVENT entry";
if (expected_event != entry.event.type) {
return ::testing::AssertionFailure()
- << "Actual event: " << LoadLog::EventTypeToString(entry.event.type)
- << ". Expected event: " << LoadLog::EventTypeToString(expected_event)
+ << "Actual event: " << NetLog::EventTypeToString(entry.event.type)
+ << ". Expected event: " << NetLog::EventTypeToString(expected_event)
<< ".";
}
if (expected_phase != entry.event.phase) {
@@ -55,50 +56,50 @@
}
inline ::testing::AssertionResult LogContainsEventAtTime(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& log,
int i, // Negative indices are reverse indices.
const base::TimeTicks& expected_time,
- LoadLog::EventType expected_event,
- LoadLog::EventPhase expected_phase) {
+ NetLog::EventType expected_event,
+ NetLog::EventPhase expected_phase) {
return LogContainsEventHelper(log, i, expected_time, true,
expected_event, expected_phase);
}
// Version without timestamp.
inline ::testing::AssertionResult LogContainsEvent(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& log,
int i, // Negative indices are reverse indices.
- LoadLog::EventType expected_event,
- LoadLog::EventPhase expected_phase) {
+ NetLog::EventType expected_event,
+ NetLog::EventPhase expected_phase) {
return LogContainsEventHelper(log, i, base::TimeTicks(), false,
expected_event, expected_phase);
}
// Version for PHASE_BEGIN (and no timestamp).
inline ::testing::AssertionResult LogContainsBeginEvent(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& log,
int i, // Negative indices are reverse indices.
- LoadLog::EventType expected_event) {
- return LogContainsEvent(log, i, expected_event, LoadLog::PHASE_BEGIN);
+ NetLog::EventType expected_event) {
+ return LogContainsEvent(log, i, expected_event, NetLog::PHASE_BEGIN);
}
// Version for PHASE_END (and no timestamp).
inline ::testing::AssertionResult LogContainsEndEvent(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& log,
int i, // Negative indices are reverse indices.
- LoadLog::EventType expected_event) {
- return LogContainsEvent(log, i, expected_event, LoadLog::PHASE_END);
+ NetLog::EventType expected_event) {
+ return LogContainsEvent(log, i, expected_event, NetLog::PHASE_END);
}
inline ::testing::AssertionResult LogContainsEntryWithType(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& entries,
int i, // Negative indices are reverse indices.
- LoadLog::Entry::Type type) {
+ NetLog::Entry::Type type) {
// Negative indices are reverse indices.
- size_t j = (i < 0) ? log.entries().size() + i : i;
- if (j >= log.entries().size())
+ size_t j = (i < 0) ? entries.size() + i : i;
+ if (j >= entries.size())
return ::testing::AssertionFailure() << j << " is out of bounds.";
- const LoadLog::Entry& entry = log.entries()[j];
+ const NetLog::Entry& entry = entries[j];
if (entry.type != type)
return ::testing::AssertionFailure() << "Type does not match.";
return ::testing::AssertionSuccess();
@@ -108,23 +109,24 @@
// Expect that the log contains an event, but don't care about where
// as long as the index where it is found is greater than min_index.
// Returns the position where the event was found.
-inline size_t ExpectLogContainsSomewhere(const LoadLog* log,
- size_t min_index,
- LoadLog::EventType expected_event,
- LoadLog::EventPhase expected_phase) {
+inline size_t ExpectLogContainsSomewhere(
+ const CapturingNetLog::EntryList& entries,
+ size_t min_index,
+ NetLog::EventType expected_event,
+ NetLog::EventPhase expected_phase) {
size_t i = 0;
- for (; i < log->entries().size(); ++i) {
- const LoadLog::Entry& entry = log->entries()[i];
- if (entry.type == LoadLog::Entry::TYPE_EVENT &&
+ for (; i < entries.size(); ++i) {
+ const NetLog::Entry& entry = entries[i];
+ if (entry.type == NetLog::Entry::TYPE_EVENT &&
entry.event.type == expected_event &&
entry.event.phase == expected_phase)
break;
}
- EXPECT_LT(i, log->entries().size());
+ EXPECT_LT(i, entries.size());
EXPECT_GE(i, min_index);
return i;
}
} // namespace net
-#endif // NET_BASE_LOAD_LOG_UNITTEST_H_
+#endif // NET_BASE_NET_LOG_UNITTEST_H_
« no previous file with comments | « net/base/net_log_event_type_list.h ('k') | net/base/net_log_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698