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
3 // found in the LICENSE file.
5 #ifndef NET_LOG_TEST_NET_LOG_UTIL_H_
6 #define NET_LOG_TEST_NET_LOG_UTIL_H_
8 #include "net/log/net_log.h"
9 #include "net/log/test_net_log_entry.h"
10 #include "testing/gtest/include/gtest/gtest.h"
14 // Checks that the element of |entries| at |offset| has the provided values.
15 // A negative |offset| indicates a position relative to the end of |entries|.
16 // Checks to make sure |offset| is within bounds, and fails gracefully if it
18 ::testing::AssertionResult
LogContainsEvent(
19 const TestNetLogEntry::List
& entries
,
21 NetLog::EventType expected_event
,
22 NetLog::EventPhase expected_phase
);
24 // Just like LogContainsEvent, but always checks for an EventPhase of
26 ::testing::AssertionResult
LogContainsBeginEvent(
27 const TestNetLogEntry::List
& entries
,
29 NetLog::EventType expected_event
);
31 // Just like LogContainsEvent, but always checks for an EventPhase of PHASE_END.
32 ::testing::AssertionResult
LogContainsEndEvent(
33 const TestNetLogEntry::List
& entries
,
35 NetLog::EventType expected_event
);
37 // Just like LogContainsEvent, but does not check phase.
38 ::testing::AssertionResult
LogContainsEntryWithType(
39 const TestNetLogEntry::List
& entries
,
41 NetLog::EventType type
);
43 // Check if the log contains an entry of the given type at |start_offset| or
44 // after. It is not a failure if there's an earlier matching entry. Negative
45 // offsets are relative to the end of the array.
46 ::testing::AssertionResult
LogContainsEntryWithTypeAfter(
47 const TestNetLogEntry::List
& entries
,
49 NetLog::EventType type
);
51 // Check if the first entry with the specified values is at |start_offset| or
52 // after. It is a failure if there's an earlier matching entry. Negative
53 // offsets are relative to the end of the array.
54 size_t ExpectLogContainsSomewhere(const TestNetLogEntry::List
& entries
,
56 NetLog::EventType expected_event
,
57 NetLog::EventPhase expected_phase
);
59 // Check if the log contains an entry with the given values at |start_offset|
60 // or after. It is not a failure if there's an earlier matching entry.
61 // Negative offsets are relative to the end of the array.
62 size_t ExpectLogContainsSomewhereAfter(const TestNetLogEntry::List
& entries
,
64 NetLog::EventType expected_event
,
65 NetLog::EventPhase expected_phase
);
69 #endif // NET_LOG_TEST_NET_LOG_UTIL_H_