Chromium Code Reviews| 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(); |