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

Unified 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 comments (better tests) 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/log/trace_net_log_observer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/log/trace_net_log_observer_unittest.cc
diff --git a/net/log/trace_net_log_observer_unittest.cc b/net/log/trace_net_log_observer_unittest.cc
index 2cd4f01a867d41f072a501b9604576fdc5013c28..476db7fba4fe5248bb7c7e446439adb1d3fe006d 100644
--- a/net/log/trace_net_log_observer_unittest.cc
+++ b/net/log/trace_net_log_observer_unittest.cc
@@ -347,6 +347,48 @@ TEST_F(TraceNetLogObserverTest,
EXPECT_EQ(0u, trace_events()->GetSize());
}
+TEST_F(TraceNetLogObserverTest, DisabledCategoryDoesntEnableNetLog) {
+ // Note: This test and the next one don't use the NetLog instance from the
+ // test fixture as it always has an observer, thus making the return value of
+ // NetLog::IsCapturing() not useful. This is still TEST_F(), as mixing TEST()
+ // and TEST_F() is not allowed.
xunjieli 2016/12/05 15:57:04 This is okay. But alternatively you can use TEST i
xunjieli 2016/12/05 16:00:00 And move these two tests either to the top or afte
Benoit L 2016/12/05 16:44:25 Done.
Benoit L 2016/12/05 16:44:25 Done.
+ TraceNetLogObserver observer;
+ NetLog net_log;
+ observer.WatchForTraceStart(&net_log);
+
+ EXPECT_FALSE(net_log.IsCapturing());
+
+ std::string disabled_netlog_category =
+ std::string("-") + kNetLogTracingCategory;
+ TraceLog::GetInstance()->SetEnabled(
+ base::trace_event::TraceConfig(disabled_netlog_category, ""),
+ TraceLog::RECORDING_MODE);
+
+ EXPECT_FALSE(net_log.IsCapturing());
+ observer.StopWatchForTraceStart();
+ EXPECT_FALSE(net_log.IsCapturing());
+
+ TraceLog::GetInstance()->SetDisabled();
+}
+
+TEST_F(TraceNetLogObserverTest, CanEnableNetLog) {
+ TraceNetLogObserver observer;
+ NetLog net_log;
+ observer.WatchForTraceStart(&net_log);
+
+ EXPECT_FALSE(net_log.IsCapturing());
+
+ TraceLog::GetInstance()->SetEnabled(
+ base::trace_event::TraceConfig(kNetLogTracingCategory, ""),
+ TraceLog::RECORDING_MODE);
+
+ EXPECT_TRUE(net_log.IsCapturing());
+ observer.StopWatchForTraceStart();
+ EXPECT_FALSE(net_log.IsCapturing());
+
+ TraceLog::GetInstance()->SetDisabled();
+}
+
TEST_F(TraceNetLogObserverTest, EventsWithAndWithoutParameters) {
trace_net_log_observer()->WatchForTraceStart(net_log());
EnableTraceLog();
« 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