OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "net/log/trace_net_log_observer.h" | 5 #include "net/log/trace_net_log_observer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 EXPECT_EQ(0u, trace_events()->GetSize()); | 160 EXPECT_EQ(0u, trace_events()->GetSize()); |
161 } | 161 } |
162 | 162 |
163 TEST_F(TraceNetLogObserverTest, TraceEventCaptured) { | 163 TEST_F(TraceNetLogObserverTest, TraceEventCaptured) { |
164 TestNetLogEntry::List entries; | 164 TestNetLogEntry::List entries; |
165 net_log()->GetEntries(&entries); | 165 net_log()->GetEntries(&entries); |
166 EXPECT_TRUE(entries.empty()); | 166 EXPECT_TRUE(entries.empty()); |
167 | 167 |
168 trace_net_log_observer()->WatchForTraceStart(net_log()); | 168 trace_net_log_observer()->WatchForTraceStart(net_log()); |
169 EnableTraceLog(); | 169 EnableTraceLog(); |
170 BoundNetLog bound_net_log = | 170 NetLogWithSource net_log_with_source = |
171 BoundNetLog::Make(net_log(), net::NetLogSourceType::NONE); | 171 NetLogWithSource::Make(net_log(), net::NetLogSourceType::NONE); |
172 net_log()->AddGlobalEntry(NetLogEventType::CANCELLED); | 172 net_log()->AddGlobalEntry(NetLogEventType::CANCELLED); |
173 bound_net_log.BeginEvent(NetLogEventType::URL_REQUEST_START_JOB); | 173 net_log_with_source.BeginEvent(NetLogEventType::URL_REQUEST_START_JOB); |
174 bound_net_log.EndEvent(NetLogEventType::REQUEST_ALIVE); | 174 net_log_with_source.EndEvent(NetLogEventType::REQUEST_ALIVE); |
175 | 175 |
176 net_log()->GetEntries(&entries); | 176 net_log()->GetEntries(&entries); |
177 EXPECT_EQ(3u, entries.size()); | 177 EXPECT_EQ(3u, entries.size()); |
178 EndTraceAndFlush(); | 178 EndTraceAndFlush(); |
179 trace_net_log_observer()->StopWatchForTraceStart(); | 179 trace_net_log_observer()->StopWatchForTraceStart(); |
180 EXPECT_EQ(3u, trace_events()->GetSize()); | 180 EXPECT_EQ(3u, trace_events()->GetSize()); |
181 const base::DictionaryValue* item1 = NULL; | 181 const base::DictionaryValue* item1 = NULL; |
182 ASSERT_TRUE(trace_events()->GetDictionary(0, &item1)); | 182 ASSERT_TRUE(trace_events()->GetDictionary(0, &item1)); |
183 const base::DictionaryValue* item2 = NULL; | 183 const base::DictionaryValue* item2 = NULL; |
184 ASSERT_TRUE(trace_events()->GetDictionary(1, &item2)); | 184 ASSERT_TRUE(trace_events()->GetDictionary(1, &item2)); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params)); | 368 EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params)); |
369 EXPECT_EQ("bar", item1_params); | 369 EXPECT_EQ("bar", item1_params); |
370 | 370 |
371 EXPECT_TRUE(item2->GetString("args.params", &item2_params)); | 371 EXPECT_TRUE(item2->GetString("args.params", &item2_params)); |
372 EXPECT_TRUE(item2_params.empty()); | 372 EXPECT_TRUE(item2_params.empty()); |
373 } | 373 } |
374 | 374 |
375 } // namespace | 375 } // namespace |
376 | 376 |
377 } // namespace net | 377 } // namespace net |
OLD | NEW |