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

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

Issue 344026: Add LoadLog to ClientSocket::Connect(). (Closed)
Patch Set: Minor build fixups and fixed mac bug. Created 11 years, 1 month 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
« no previous file with comments | « net/base/load_log_event_type_list.h ('k') | net/flip/flip_session.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_LOAD_LOG_UNITTEST_H_ 5 #ifndef NET_BASE_LOAD_LOG_UNITTEST_H_
6 #define NET_BASE_LOAD_LOG_UNITTEST_H_ 6 #define NET_BASE_LOAD_LOG_UNITTEST_H_
7 7
8 #include <cstddef>
8 #include "net/base/load_log.h" 9 #include "net/base/load_log.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace net { 12 namespace net {
12 13
13 // Create a timestamp with internal value of |t| milliseconds from the epoch. 14 // Create a timestamp with internal value of |t| milliseconds from the epoch.
14 inline base::TimeTicks MakeTime(int t) { 15 inline base::TimeTicks MakeTime(int t) {
15 base::TimeTicks ticks; // initialized to 0. 16 base::TimeTicks ticks; // initialized to 0.
16 ticks += base::TimeDelta::FromMilliseconds(t); 17 ticks += base::TimeDelta::FromMilliseconds(t);
17 return ticks; 18 return ticks;
(...skipping 15 matching lines...) Expand all
33 // Same as above, but without an expectation for the timestamp. 34 // Same as above, but without an expectation for the timestamp.
34 inline void ExpectLogContains(const LoadLog* log, 35 inline void ExpectLogContains(const LoadLog* log,
35 size_t i, 36 size_t i,
36 LoadLog::EventType expected_event, 37 LoadLog::EventType expected_event,
37 LoadLog::EventPhase expected_phase) { 38 LoadLog::EventPhase expected_phase) {
38 ASSERT_LT(i, log->events().size()); 39 ASSERT_LT(i, log->events().size());
39 EXPECT_EQ(expected_event, log->events()[i].type); 40 EXPECT_EQ(expected_event, log->events()[i].type);
40 EXPECT_EQ(expected_phase, log->events()[i].phase); 41 EXPECT_EQ(expected_phase, log->events()[i].phase);
41 } 42 }
42 43
44 inline ::testing::AssertionResult LogContains(
45 const LoadLog& log,
46 int i, // Negative indices are reverse indices.
47 LoadLog::EventType expected_event,
48 LoadLog::EventPhase expected_phase) {
49 // Negative indices are reverse indices.
50 size_t j = (i < 0) ? log.events().size() + i : i;
51 if (j >= log.events().size())
52 return ::testing::AssertionFailure() << j << " is out of bounds.";
53 if (expected_event != log.events()[j].type) {
54 return ::testing::AssertionFailure()
55 << "Actual event: " << LoadLog::EventTypeToString(log.events()[j].type)
56 << ". Expected event: " << LoadLog::EventTypeToString(expected_event)
57 << ".";
58 }
59 if (expected_phase != log.events()[j].phase) {
60 return ::testing::AssertionFailure()
61 << "Actual phase: " << log.events()[j].phase
62 << ". Expected phase: " << expected_phase << ".";
63 }
64 return ::testing::AssertionSuccess();
65 }
66
43 } // namespace net 67 } // namespace net
44 68
45 #endif // NET_BASE_LOAD_LOG_UNITTEST_H_ 69 #endif // NET_BASE_LOAD_LOG_UNITTEST_H_
OLDNEW
« no previous file with comments | « net/base/load_log_event_type_list.h ('k') | net/flip/flip_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698