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

Unified Diff: content/browser/tracing/background_tracing_manager_browsertest.cc

Issue 2294093002: Reland of Background tracing: Added config option for repeated trigger behavior (patchset #1 id:1 o… (Closed)
Patch Set: Created 4 years, 4 months 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
Index: content/browser/tracing/background_tracing_manager_browsertest.cc
diff --git a/content/browser/tracing/background_tracing_manager_browsertest.cc b/content/browser/tracing/background_tracing_manager_browsertest.cc
index 5dad1c822515bbbdf30f169a8f79ff5c2a32021d..085e76b7716c00dd55a8460f8c5536b2f1c6be54 100644
--- a/content/browser/tracing/background_tracing_manager_browsertest.cc
+++ b/content/browser/tracing/background_tracing_manager_browsertest.cc
@@ -131,6 +131,7 @@ std::unique_ptr<BackgroundTracingConfig> CreateReactiveConfig() {
new base::DictionaryValue());
rules_dict->SetString("rule", "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL");
rules_dict->SetString("trigger_name", "reactive_test");
+ rules_dict->SetBoolean("stop_tracing_on_repeated_reactive", true);
rules_dict->SetString("category", "BENCHMARK");
rules_list->Append(std::move(rules_dict));
}
@@ -1108,6 +1109,8 @@ IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest,
rules_dict->SetString("rule",
"TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL");
rules_dict->SetString("trigger_name", "reactive_test1");
+ rules_dict->SetBoolean("stop_tracing_on_repeated_reactive", true);
+ rules_dict->SetInteger("trigger_delay", 10);
rules_dict->SetString("category", "BENCHMARK");
rules_list->Append(std::move(rules_dict));
}
@@ -1117,6 +1120,8 @@ IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest,
rules_dict->SetString("rule",
"TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL");
rules_dict->SetString("trigger_name", "reactive_test2");
+ rules_dict->SetBoolean("stop_tracing_on_repeated_reactive", true);
+ rules_dict->SetInteger("trigger_delay", 10);
rules_dict->SetString("category", "BENCHMARK");
rules_list->Append(std::move(rules_dict));
}
@@ -1195,4 +1200,79 @@ IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest,
}
}
+// This tests that reactive mode only terminates with a repeated trigger
+// if the config specifies that it should.
+IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest,
+ ReactiveSecondTriggerIgnored) {
+ {
+ SetupBackgroundTracingManager();
+
+ base::RunLoop run_loop;
+ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper(
+ run_loop.QuitClosure());
+
+ base::DictionaryValue dict;
+ dict.SetString("mode", "REACTIVE_TRACING_MODE");
+
+ std::unique_ptr<base::ListValue> rules_list(new base::ListValue());
+ {
+ std::unique_ptr<base::DictionaryValue> rules_dict(
+ new base::DictionaryValue());
+ rules_dict->SetString("rule",
+ "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL");
+ rules_dict->SetString("trigger_name", "reactive_test");
+ rules_dict->SetBoolean("stop_tracing_on_repeated_reactive", false);
+ rules_dict->SetInteger("trigger_delay", 10);
+ rules_dict->SetString("category", "BENCHMARK");
+ rules_list->Append(std::move(rules_dict));
+ }
+ dict.Set("configs", std::move(rules_list));
+
+ std::unique_ptr<BackgroundTracingConfig> config(
+ BackgroundTracingConfigImpl::FromDict(&dict));
+
+ BackgroundTracingManager::TriggerHandle trigger_handle =
+ BackgroundTracingManager::GetInstance()->RegisterTriggerType(
+ "reactive_test");
+
+ EXPECT_TRUE(BackgroundTracingManager::GetInstance()->SetActiveScenario(
+ std::move(config), upload_config_wrapper.get_receive_callback(),
+ BackgroundTracingManager::NO_DATA_FILTERING));
+
+ BackgroundTracingManager::GetInstance()->WhenIdle(
+ base::Bind(&DisableScenarioWhenIdle));
+
+ base::RunLoop wait_for_tracing_enabled;
+ static_cast<BackgroundTracingManagerImpl*>(
+ BackgroundTracingManager::GetInstance())
+ ->SetTracingEnabledCallbackForTesting(
+ wait_for_tracing_enabled.QuitClosure());
+
+ BackgroundTracingManager::GetInstance()->TriggerNamedEvent(
+ trigger_handle,
+ base::Bind(&StartedFinalizingCallback, base::Closure(), true));
+
+ wait_for_tracing_enabled.Run();
+
+ // This is expected to fail since we already triggered.
+ BackgroundTracingManager::GetInstance()->TriggerNamedEvent(
+ trigger_handle,
+ base::Bind(&StartedFinalizingCallback, base::Closure(), false));
+
+ // Since we specified a delay in the scenario, we should still be tracing
+ // at this point.
+ EXPECT_TRUE(
+ BackgroundTracingManagerImpl::GetInstance()->IsTracingForTesting());
+
+ BackgroundTracingManager::GetInstance()->FireTimerForTesting();
+
+ EXPECT_FALSE(
+ BackgroundTracingManagerImpl::GetInstance()->IsTracingForTesting());
+
+ run_loop.Run();
+
+ EXPECT_TRUE(upload_config_wrapper.get_receive_count() == 1);
+ }
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698