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

Side by Side Diff: content/browser/tracing/background_tracing_config_unittest.cc

Issue 1417503006: Revert of 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
Patch Set: Created 5 years, 1 month 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
OLDNEW
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/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/json/json_writer.h" 6 #include "base/json/json_writer.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "content/browser/tracing/background_tracing_config_impl.h" 9 #include "content/browser/tracing/background_tracing_config_impl.h"
10 #include "content/browser/tracing/background_tracing_rule.h" 10 #include "content/browser/tracing/background_tracing_rule.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 EXPECT_TRUE(config); 249 EXPECT_TRUE(config);
250 EXPECT_EQ(config->tracing_mode(), BackgroundTracingConfig::PREEMPTIVE); 250 EXPECT_EQ(config->tracing_mode(), BackgroundTracingConfig::PREEMPTIVE);
251 EXPECT_EQ(config->category_preset(), BackgroundTracingConfigImpl::BENCHMARK); 251 EXPECT_EQ(config->category_preset(), BackgroundTracingConfigImpl::BENCHMARK);
252 EXPECT_EQ(config->rules().size(), 2u); 252 EXPECT_EQ(config->rules().size(), 2u);
253 EXPECT_EQ(RuleToString(config->rules()[0]), 253 EXPECT_EQ(RuleToString(config->rules()[0]),
254 "{\"rule\":\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\"," 254 "{\"rule\":\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\","
255 "\"trigger_name\":\"foo1\"}"); 255 "\"trigger_name\":\"foo1\"}");
256 EXPECT_EQ(RuleToString(config->rules()[1]), 256 EXPECT_EQ(RuleToString(config->rules()[1]),
257 "{\"rule\":\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\"," 257 "{\"rule\":\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\","
258 "\"trigger_name\":\"foo2\"}"); 258 "\"trigger_name\":\"foo2\"}");
259
260 config = ReadFromJSONString(
261 "{\"category\":\"BENCHMARK_DEEP\",\"configs\":[{\"rule\":"
262 "\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\",\"trigger_name\":"
263 "\"foo1\"}],\"disable_blink_features\":\"SlowerWeb1,SlowerWeb2\","
264 "\"enable_blink_features\":\"FasterWeb1,FasterWeb2\","
265 "\"mode\":\"PREEMPTIVE_TRACING_MODE\","
266 "\"scenario_name\":\"my_awesome_experiment\"}");
267 EXPECT_EQ(config->enable_blink_features(), "FasterWeb1,FasterWeb2");
268 EXPECT_EQ(config->disable_blink_features(), "SlowerWeb1,SlowerWeb2");
269 EXPECT_EQ(config->scenario_name(), "my_awesome_experiment");
270 } 259 }
271 260
272 TEST_F(BackgroundTracingConfigTest, ReactiveConfigFromValidString) { 261 TEST_F(BackgroundTracingConfigTest, ReactiveConfigFromValidString) {
273 scoped_ptr<BackgroundTracingConfigImpl> config; 262 scoped_ptr<BackgroundTracingConfigImpl> config;
274 263
275 config = ReadFromJSONString( 264 config = ReadFromJSONString(
276 "{\"mode\":\"REACTIVE_TRACING_MODE\",\"configs\": [{\"rule\": " 265 "{\"mode\":\"REACTIVE_TRACING_MODE\",\"configs\": [{\"rule\": "
277 "\"TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\", " 266 "\"TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\", "
278 "\"category\": \"BENCHMARK\", \"trigger_name\": \"foo\"}]}"); 267 "\"category\": \"BENCHMARK\", \"trigger_name\": \"foo\"}]}");
279 EXPECT_TRUE(config); 268 EXPECT_TRUE(config);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 second_dict->SetInteger("trigger_delay", 10); 399 second_dict->SetInteger("trigger_delay", 10);
411 config->AddPreemptiveRule(second_dict.get()); 400 config->AddPreemptiveRule(second_dict.get());
412 401
413 EXPECT_EQ(ConfigToString(config.get()), 402 EXPECT_EQ(ConfigToString(config.get()),
414 "{\"category\":\"BENCHMARK\",\"configs\":[{\"histogram_lower_" 403 "{\"category\":\"BENCHMARK\",\"configs\":[{\"histogram_lower_"
415 "value\":1,\"histogram_name\":\"foo\",\"histogram_repeat\":true," 404 "value\":1,\"histogram_name\":\"foo\",\"histogram_repeat\":true,"
416 "\"histogram_upper_value\":2,\"rule\":\"MONITOR_AND_DUMP_WHEN_" 405 "\"histogram_upper_value\":2,\"rule\":\"MONITOR_AND_DUMP_WHEN_"
417 "SPECIFIC_HISTOGRAM_AND_VALUE\",\"trigger_delay\":10}],\"mode\":" 406 "SPECIFIC_HISTOGRAM_AND_VALUE\",\"trigger_delay\":10}],\"mode\":"
418 "\"PREEMPTIVE_TRACING_MODE\"}"); 407 "\"PREEMPTIVE_TRACING_MODE\"}");
419 } 408 }
420
421 {
422 config.reset(
423 new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE));
424 config->set_category_preset(BackgroundTracingConfigImpl::BENCHMARK_DEEP);
425
426 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
427 dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED");
428 dict->SetString("trigger_name", "foo1");
429 config->AddPreemptiveRule(dict.get());
430
431 config->scenario_name_ = "my_awesome_experiment";
432 config->enable_blink_features_ = "FasterWeb1,FasterWeb2";
433 config->disable_blink_features_ = "SlowerWeb1,SlowerWeb2";
434
435 EXPECT_EQ(ConfigToString(config.get()),
436 "{\"category\":\"BENCHMARK_DEEP\",\"configs\":[{\"rule\":"
437 "\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\",\"trigger_name\":"
438 "\"foo1\"}],\"disable_blink_features\":\"SlowerWeb1,SlowerWeb2\","
439 "\"enable_blink_features\":\"FasterWeb1,FasterWeb2\","
440 "\"mode\":\"PREEMPTIVE_TRACING_MODE\","
441 "\"scenario_name\":\"my_awesome_experiment\"}");
442 }
443 } 409 }
444 410
445 TEST_F(BackgroundTracingConfigTest, InvalidPreemptiveConfigToString) { 411 TEST_F(BackgroundTracingConfigTest, InvalidPreemptiveConfigToString) {
446 scoped_ptr<BackgroundTracingConfigImpl> config; 412 scoped_ptr<BackgroundTracingConfigImpl> config;
447 413
448 { 414 {
449 config.reset( 415 config.reset(
450 new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); 416 new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE));
451 417
452 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 418 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 ConfigToString(config.get()), 498 ConfigToString(config.get()),
533 "{\"configs\":[{\"category\":\"BENCHMARK_DEEP\",\"rule\":\"TRACE_" 499 "{\"configs\":[{\"category\":\"BENCHMARK_DEEP\",\"rule\":\"TRACE_"
534 "ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\",\"trigger_name\":\"foo1\"},{" 500 "ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\",\"trigger_name\":\"foo1\"},{"
535 "\"category\":\"BENCHMARK_DEEP\",\"rule\":" 501 "\"category\":\"BENCHMARK_DEEP\",\"rule\":"
536 "\"TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\",\"trigger_name\":" 502 "\"TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\",\"trigger_name\":"
537 "\"foo2\"}],\"mode\":\"REACTIVE_TRACING_MODE\"}"); 503 "\"foo2\"}],\"mode\":\"REACTIVE_TRACING_MODE\"}");
538 } 504 }
539 } 505 }
540 506
541 } // namspace content 507 } // namspace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698