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

Unified Diff: net/base/load_log_unittest.h

Issue 551135: Cleanup the unittest helpers in load_log_unittest.h.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Sync and merge conflicts Created 10 years, 11 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/host_resolver_impl_unittest.cc ('k') | net/base/load_log_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/load_log_unittest.h
===================================================================
--- net/base/load_log_unittest.h (revision 37380)
+++ net/base/load_log_unittest.h (working copy)
@@ -18,36 +18,11 @@
return ticks;
}
-// Call gtest's EXPECT_* to verify that |log| contains the specified entry
-// at index |i|.
-inline void ExpectLogContains(const LoadLog* log,
- size_t i,
- base::TimeTicks expected_time,
- LoadLog::EventType expected_event,
- LoadLog::EventPhase expected_phase) {
- ASSERT_LT(i, log->entries().size());
- const LoadLog::Entry& entry = log->entries()[i];
- EXPECT_EQ(LoadLog::Entry::TYPE_EVENT, entry.type);
- EXPECT_TRUE(expected_time == entry.time);
- EXPECT_EQ(expected_event, entry.event.type);
- EXPECT_EQ(expected_phase, entry.event.phase);
-}
-
-// Same as above, but without an expectation for the timestamp.
-inline void ExpectLogContains(const LoadLog* log,
- size_t i,
- LoadLog::EventType expected_event,
- LoadLog::EventPhase expected_phase) {
- ASSERT_LT(i, log->entries().size());
- const LoadLog::Entry& entry = log->entries()[i];
- EXPECT_EQ(LoadLog::Entry::TYPE_EVENT, entry.type);
- EXPECT_EQ(expected_event, entry.event.type);
- EXPECT_EQ(expected_phase, entry.event.phase);
-}
-
-inline ::testing::AssertionResult LogContains(
+inline ::testing::AssertionResult LogContainsEventHelper(
const LoadLog& log,
int i, // Negative indices are reverse indices.
+ const base::TimeTicks& expected_time,
+ bool check_time,
LoadLog::EventType expected_event,
LoadLog::EventPhase expected_phase) {
// Negative indices are reverse indices.
@@ -69,9 +44,53 @@
<< "Actual phase: " << entry.event.phase
<< ". Expected phase: " << expected_phase << ".";
}
+ if (check_time) {
+ if (expected_time != entry.time) {
+ return ::testing::AssertionFailure()
+ << "Actual time: " << entry.time.ToInternalValue()
+ << ". Expected time: " << expected_time.ToInternalValue()
+ << ".";
+ }
+ }
return ::testing::AssertionSuccess();
}
+inline ::testing::AssertionResult LogContainsEventAtTime(
+ const LoadLog& log,
+ int i, // Negative indices are reverse indices.
+ const base::TimeTicks& expected_time,
+ LoadLog::EventType expected_event,
+ LoadLog::EventPhase expected_phase) {
+ return LogContainsEventHelper(log, i, expected_time, true,
+ expected_event, expected_phase);
+}
+
+// Version without timestamp.
+inline ::testing::AssertionResult LogContainsEvent(
+ const LoadLog& log,
+ int i, // Negative indices are reverse indices.
+ LoadLog::EventType expected_event,
+ LoadLog::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,
+ int i, // Negative indices are reverse indices.
+ LoadLog::EventType expected_event) {
+ return LogContainsEvent(log, i, expected_event, LoadLog::PHASE_BEGIN);
+}
+
+// Version for PHASE_END (and no timestamp).
+inline ::testing::AssertionResult LogContainsEndEvent(
+ const LoadLog& log,
+ int i, // Negative indices are reverse indices.
+ LoadLog::EventType expected_event) {
+ return LogContainsEvent(log, i, expected_event, LoadLog::PHASE_END);
+}
+
// 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.
« no previous file with comments | « net/base/host_resolver_impl_unittest.cc ('k') | net/base/load_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698