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

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: Address comment. 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 std::string item1_params; 392 std::string item1_params;
393 std::string item2_params; 393 std::string item2_params;
394 EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params)); 394 EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params));
395 EXPECT_EQ("bar", item1_params); 395 EXPECT_EQ("bar", item1_params);
396 396
397 EXPECT_TRUE(item2->GetString("args.params", &item2_params)); 397 EXPECT_TRUE(item2->GetString("args.params", &item2_params));
398 EXPECT_TRUE(item2_params.empty()); 398 EXPECT_TRUE(item2_params.empty());
399 } 399 }
400 400
401 TEST(TraceNetLogObserverCategoryTest, DisabledCategory) {
402 TraceNetLogObserver observer;
403 NetLog net_log;
404 observer.WatchForTraceStart(&net_log);
405
406 EXPECT_FALSE(net_log.IsCapturing());
407
408 std::string disabled_netlog_category =
409 std::string("-") + kNetLogTracingCategory;
410 TraceLog::GetInstance()->SetEnabled(
411 base::trace_event::TraceConfig(disabled_netlog_category, ""),
412 TraceLog::RECORDING_MODE);
413
414 EXPECT_FALSE(net_log.IsCapturing());
415 observer.StopWatchForTraceStart();
416 EXPECT_FALSE(net_log.IsCapturing());
417
418 TraceLog::GetInstance()->SetDisabled();
419 }
420
421 TEST(TraceNetLogObserverCategoryTest, EnabledCategory) {
422 TraceNetLogObserver observer;
423 NetLog net_log;
424 observer.WatchForTraceStart(&net_log);
425
426 EXPECT_FALSE(net_log.IsCapturing());
427
428 TraceLog::GetInstance()->SetEnabled(
429 base::trace_event::TraceConfig(kNetLogTracingCategory, ""),
430 TraceLog::RECORDING_MODE);
431
432 EXPECT_TRUE(net_log.IsCapturing());
433 observer.StopWatchForTraceStart();
434 EXPECT_FALSE(net_log.IsCapturing());
435
436 TraceLog::GetInstance()->SetDisabled();
437 }
438
401 } // namespace 439 } // namespace
402 440
403 } // namespace net 441 } // 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