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

Side by Side Diff: net/log/trace_net_log_observer_unittest.cc

Issue 2554483002: netlog: Don't enable recording if the "netlog" tracing category is disabled. (Closed)
Patch Set: Created 4 years 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/log/trace_net_log_observer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 net_log()->AddGlobalEntry(NetLogEventType::URL_REQUEST_START_JOB); 340 net_log()->AddGlobalEntry(NetLogEventType::URL_REQUEST_START_JOB);
341 341
342 EndTraceAndFlush(); 342 EndTraceAndFlush();
343 343
344 TestNetLogEntry::List entries; 344 TestNetLogEntry::List entries;
345 net_log()->GetEntries(&entries); 345 net_log()->GetEntries(&entries);
346 EXPECT_EQ(3u, entries.size()); 346 EXPECT_EQ(3u, entries.size());
347 EXPECT_EQ(0u, trace_events()->GetSize()); 347 EXPECT_EQ(0u, trace_events()->GetSize());
348 } 348 }
349 349
350 TEST_F(TraceNetLogObserverTest, DisabledCategoryDoesntEnableNetLog) {
xunjieli 2016/12/05 14:55:01 Thanks for working on this. The change looks good.
351 set_trace_net_log_observer(new TraceNetLogObserver());
352 trace_net_log_observer()->WatchForTraceStart(net_log());
353
354 std::string disabled_netlog_category =
355 std::string("-") + kNetLogTracingCategory;
356 TraceLog::GetInstance()->SetEnabled(
357 base::trace_event::TraceConfig(disabled_netlog_category, ""),
358 TraceLog::RECORDING_MODE);
359
360 net_log()->AddGlobalEntry(NetLogEventType::REQUEST_ALIVE);
361
362 trace_net_log_observer()->StopWatchForTraceStart();
363
364 EndTraceAndFlush();
365 TestNetLogEntry::List entries;
366 net_log()->GetEntries(&entries);
367 EXPECT_EQ(1u, entries.size());
368 EXPECT_EQ(0u, trace_events()->GetSize());
369 }
370
350 TEST_F(TraceNetLogObserverTest, EventsWithAndWithoutParameters) { 371 TEST_F(TraceNetLogObserverTest, EventsWithAndWithoutParameters) {
351 trace_net_log_observer()->WatchForTraceStart(net_log()); 372 trace_net_log_observer()->WatchForTraceStart(net_log());
352 EnableTraceLog(); 373 EnableTraceLog();
353 NetLogParametersCallback net_log_callback; 374 NetLogParametersCallback net_log_callback;
354 std::string param = "bar"; 375 std::string param = "bar";
355 net_log_callback = NetLog::StringCallback("foo", &param); 376 net_log_callback = NetLog::StringCallback("foo", &param);
356 377
357 net_log()->AddGlobalEntry(NetLogEventType::CANCELLED, net_log_callback); 378 net_log()->AddGlobalEntry(NetLogEventType::CANCELLED, net_log_callback);
358 net_log()->AddGlobalEntry(NetLogEventType::REQUEST_ALIVE); 379 net_log()->AddGlobalEntry(NetLogEventType::REQUEST_ALIVE);
359 380
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params)); 415 EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params));
395 EXPECT_EQ("bar", item1_params); 416 EXPECT_EQ("bar", item1_params);
396 417
397 EXPECT_TRUE(item2->GetString("args.params", &item2_params)); 418 EXPECT_TRUE(item2->GetString("args.params", &item2_params));
398 EXPECT_TRUE(item2_params.empty()); 419 EXPECT_TRUE(item2_params.empty());
399 } 420 }
400 421
401 } // namespace 422 } // namespace
402 423
403 } // namespace net 424 } // namespace net
OLDNEW
« no previous file with comments | « net/log/trace_net_log_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698