summaryrefslogtreecommitdiffstats
path: root/net/base/load_log_unittest.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/load_log_unittest.h')
-rw-r--r--net/base/load_log_unittest.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/net/base/load_log_unittest.h b/net/base/load_log_unittest.h
index da892a0..f67c8bc 100644
--- a/net/base/load_log_unittest.h
+++ b/net/base/load_log_unittest.h
@@ -5,6 +5,7 @@
#ifndef NET_BASE_LOAD_LOG_UNITTEST_H_
#define NET_BASE_LOAD_LOG_UNITTEST_H_
+#include <cstddef>
#include "net/base/load_log.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -40,6 +41,29 @@ inline void ExpectLogContains(const LoadLog* log,
EXPECT_EQ(expected_phase, log->events()[i].phase);
}
+inline ::testing::AssertionResult LogContains(
+ const LoadLog& log,
+ int i, // Negative indices are reverse indices.
+ LoadLog::EventType expected_event,
+ LoadLog::EventPhase expected_phase) {
+ // Negative indices are reverse indices.
+ size_t j = (i < 0) ? log.events().size() + i : i;
+ if (j >= log.events().size())
+ return ::testing::AssertionFailure() << j << " is out of bounds.";
+ if (expected_event != log.events()[j].type) {
+ return ::testing::AssertionFailure()
+ << "Actual event: " << LoadLog::EventTypeToString(log.events()[j].type)
+ << ". Expected event: " << LoadLog::EventTypeToString(expected_event)
+ << ".";
+ }
+ if (expected_phase != log.events()[j].phase) {
+ return ::testing::AssertionFailure()
+ << "Actual phase: " << log.events()[j].phase
+ << ". Expected phase: " << expected_phase << ".";
+ }
+ return ::testing::AssertionSuccess();
+}
+
} // namespace net
#endif // NET_BASE_LOAD_LOG_UNITTEST_H_