 Chromium Code Reviews
 Chromium Code Reviews Issue 1420033003:
  Background tracing: Tracing scenarios can now enable/disable Blink features, for A/B testing purpos…  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1420033003:
  Background tracing: Tracing scenarios can now enable/disable Blink features, for A/B testing purpos…  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind.h" | 5 #include "base/bind.h" | 
| 6 #include "base/command_line.h" | |
| 6 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" | 
| 7 #include "base/strings/pattern.h" | 8 #include "base/strings/pattern.h" | 
| 8 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" | 
| 9 #include "content/browser/tracing/background_tracing_manager_impl.h" | 10 #include "content/browser/tracing/background_tracing_manager_impl.h" | 
| 10 #include "content/browser/tracing/background_tracing_rule.h" | 11 #include "content/browser/tracing/background_tracing_rule.h" | 
| 12 #include "content/public/common/content_switches.h" | |
| 11 #include "content/public/test/content_browser_test.h" | 13 #include "content/public/test/content_browser_test.h" | 
| 12 #include "content/public/test/content_browser_test_utils.h" | 14 #include "content/public/test/content_browser_test_utils.h" | 
| 13 #include "content/public/test/test_utils.h" | 15 #include "content/public/test/test_utils.h" | 
| 14 #include "third_party/zlib/zlib.h" | 16 #include "third_party/zlib/zlib.h" | 
| 15 | 17 | 
| 16 namespace content { | 18 namespace content { | 
| 17 | 19 | 
| 18 class BackgroundTracingManagerBrowserTest : public ContentBrowserTest { | 20 class BackgroundTracingManagerBrowserTest : public ContentBrowserTest { | 
| 19 public: | 21 public: | 
| 20 BackgroundTracingManagerBrowserTest() {} | 22 BackgroundTracingManagerBrowserTest() {} | 
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( | 410 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( | 
| 409 handle2, | 411 handle2, | 
| 410 base::Bind(&StartedFinalizingCallback, base::Closure(), false)); | 412 base::Bind(&StartedFinalizingCallback, base::Closure(), false)); | 
| 411 | 413 | 
| 412 run_loop.Run(); | 414 run_loop.Run(); | 
| 413 | 415 | 
| 414 EXPECT_TRUE(upload_config_wrapper.get_receive_count() == 1); | 416 EXPECT_TRUE(upload_config_wrapper.get_receive_count() == 1); | 
| 415 } | 417 } | 
| 416 } | 418 } | 
| 417 | 419 | 
| 420 // This tests that toggling Blink scenarios in the config alters the | |
| 421 // command-line. | |
| 422 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | |
| 423 ToggleBlinkScenarios) { | |
| 424 { | |
| 425 SetupBackgroundTracingManager(); | |
| 426 | |
| 427 base::RunLoop run_loop; | |
| 428 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | |
| 429 run_loop.QuitClosure()); | |
| 430 | |
| 431 base::DictionaryValue dict; | |
| 432 dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); | |
| 433 dict.SetString("category", "BENCHMARK"); | |
| 434 | |
| 435 scoped_ptr<base::ListValue> rules_list(new base::ListValue()); | |
| 436 { | |
| 437 scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); | |
| 438 rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); | |
| 439 rules_dict->SetString("trigger_name", "test2"); | |
| 440 rules_list->Append(rules_dict.Pass()); | |
| 441 } | |
| 442 | |
| 443 dict.Set("configs", rules_list.Pass()); | |
| 444 dict.SetString("enable_blink_features", "FasterWeb1,FasterWeb2"); | |
| 445 dict.SetString("disable_blink_features", "SlowerWeb1,SlowerWeb2"); | |
| 446 scoped_ptr<BackgroundTracingConfig> config( | |
| 447 BackgroundTracingConfigImpl::FromDict(&dict)); | |
| 448 EXPECT_TRUE(config); | |
| 449 | |
| 450 bool scenario_activated = | |
| 451 BackgroundTracingManager::GetInstance()->SetActiveScenario( | |
| 452 config.Pass(), upload_config_wrapper.get_receive_callback(), | |
| 453 BackgroundTracingManager::NO_DATA_FILTERING); | |
| 454 | |
| 455 EXPECT_TRUE(scenario_activated); | |
| 
shatch
2015/10/26 15:24:45
Maybe set the command line first to exercise the p
 
oystein (OOO til 10th of July)
2015/10/26 18:28:39
Done; added second test.
 | |
| 456 | |
| 457 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 458 EXPECT_TRUE(command_line); | |
| 459 | |
| 460 EXPECT_EQ(command_line->GetSwitchValueASCII(switches::kEnableBlinkFeatures), | |
| 461 "FasterWeb1,FasterWeb2"); | |
| 462 EXPECT_EQ( | |
| 463 command_line->GetSwitchValueASCII(switches::kDisableBlinkFeatures), | |
| 464 "SlowerWeb1,SlowerWeb2"); | |
| 465 } | |
| 466 } | |
| 467 | |
| 418 // This tests that delayed histogram triggers triggers work as expected | 468 // This tests that delayed histogram triggers triggers work as expected | 
| 419 // with preemptive scenarios. | 469 // with preemptive scenarios. | 
| 420 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 470 IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, | 
| 421 CallPreemptiveTriggerWithDelay) { | 471 CallPreemptiveTriggerWithDelay) { | 
| 422 { | 472 { | 
| 423 SetupBackgroundTracingManager(); | 473 SetupBackgroundTracingManager(); | 
| 424 | 474 | 
| 425 base::RunLoop run_loop; | 475 base::RunLoop run_loop; | 
| 426 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 476 BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( | 
| 427 run_loop.QuitClosure()); | 477 run_loop.QuitClosure()); | 
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 908 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( | 958 BackgroundTracingManager::GetInstance()->TriggerNamedEvent( | 
| 909 handle, base::Bind(&StartedFinalizingCallback, base::Closure(), false)); | 959 handle, base::Bind(&StartedFinalizingCallback, base::Closure(), false)); | 
| 910 | 960 | 
| 911 run_loop.Run(); | 961 run_loop.Run(); | 
| 912 | 962 | 
| 913 EXPECT_TRUE(upload_config_wrapper.get_receive_count() == 1); | 963 EXPECT_TRUE(upload_config_wrapper.get_receive_count() == 1); | 
| 914 } | 964 } | 
| 915 } | 965 } | 
| 916 | 966 | 
| 917 } // namespace content | 967 } // namespace content | 
| OLD | NEW |