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

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

Issue 1789673002: [bulk-reports] - Add BENCHMARK_BLINK_GC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 "\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\",\"trigger_name\":" 262 "\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\",\"trigger_name\":"
263 "\"foo1\"}],\"disable_blink_features\":\"SlowerWeb1,SlowerWeb2\"," 263 "\"foo1\"}],\"disable_blink_features\":\"SlowerWeb1,SlowerWeb2\","
264 "\"enable_blink_features\":\"FasterWeb1,FasterWeb2\"," 264 "\"enable_blink_features\":\"FasterWeb1,FasterWeb2\","
265 "\"mode\":\"PREEMPTIVE_TRACING_MODE\"," 265 "\"mode\":\"PREEMPTIVE_TRACING_MODE\","
266 "\"scenario_name\":\"my_awesome_experiment\"}"); 266 "\"scenario_name\":\"my_awesome_experiment\"}");
267 EXPECT_EQ(config->enable_blink_features(), "FasterWeb1,FasterWeb2"); 267 EXPECT_EQ(config->enable_blink_features(), "FasterWeb1,FasterWeb2");
268 EXPECT_EQ(config->disable_blink_features(), "SlowerWeb1,SlowerWeb2"); 268 EXPECT_EQ(config->disable_blink_features(), "SlowerWeb1,SlowerWeb2");
269 EXPECT_EQ(config->scenario_name(), "my_awesome_experiment"); 269 EXPECT_EQ(config->scenario_name(), "my_awesome_experiment");
270 } 270 }
271 271
272 TEST_F(BackgroundTracingConfigTest, ValidPreemptiveCategoryToString) {
273 scoped_ptr<BackgroundTracingConfigImpl> config = ReadFromJSONString(
274 "{\"mode\":\"PREEMPTIVE_TRACING_MODE\", \"category\": "
275 "\"BENCHMARK\",\"configs\": [{\"rule\": "
276 "\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\", \"trigger_name\":\"foo\"}]}");
277
278 BackgroundTracingConfigImpl::CategoryPreset categories[] = {
279 BackgroundTracingConfigImpl::BENCHMARK,
280 BackgroundTracingConfigImpl::BENCHMARK_DEEP,
281 BackgroundTracingConfigImpl::BENCHMARK_GPU,
282 BackgroundTracingConfigImpl::BENCHMARK_IPC,
283 BackgroundTracingConfigImpl::BENCHMARK_STARTUP,
284 BackgroundTracingConfigImpl::BENCHMARK_BLINK_GC,
285 BackgroundTracingConfigImpl::BLINK_STYLE,
286 };
287
288 const char* category_strings[] = {"BENCHMARK", "BENCHMARK_DEEP",
289 "BENCHMARK_GPU", "BENCHMARK_IPC",
290 "BENCHMARK_STARTUP", "BENCHMARK_BLINK_GC",
291 "BLINK_STYLE"};
292 for (size_t i = 0;
293 i <
294 sizeof(categories) / sizeof(BackgroundTracingConfigImpl::CategoryPreset);
295 i++) {
296 config->set_category_preset(categories[i]);
297 std::string expected =
298 std::string("{\"category\":\"") + category_strings[i] +
299 std::string(
300 "\",\"configs\":[{\"rule\":"
301 "\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\",\"trigger_name\":"
302 "\"foo\"}],\"mode\":\"PREEMPTIVE_TRACING_MODE\"}");
303 EXPECT_EQ(ConfigToString(config.get()), expected.c_str());
304 scoped_ptr<BackgroundTracingConfigImpl> config2 =
305 ReadFromJSONString(expected);
306 EXPECT_EQ(config->category_preset(), config2->category_preset());
307 }
308 }
309
272 TEST_F(BackgroundTracingConfigTest, ReactiveConfigFromValidString) { 310 TEST_F(BackgroundTracingConfigTest, ReactiveConfigFromValidString) {
273 scoped_ptr<BackgroundTracingConfigImpl> config; 311 scoped_ptr<BackgroundTracingConfigImpl> config;
274 312
275 config = ReadFromJSONString( 313 config = ReadFromJSONString(
276 "{\"mode\":\"REACTIVE_TRACING_MODE\",\"configs\": [{\"rule\": " 314 "{\"mode\":\"REACTIVE_TRACING_MODE\",\"configs\": [{\"rule\": "
277 "\"TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\", " 315 "\"TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\", "
278 "\"category\": \"BENCHMARK\", \"trigger_name\": \"foo\"}]}"); 316 "\"category\": \"BENCHMARK\", \"trigger_name\": \"foo\"}]}");
279 EXPECT_TRUE(config); 317 EXPECT_TRUE(config);
280 EXPECT_EQ(config->tracing_mode(), BackgroundTracingConfig::REACTIVE); 318 EXPECT_EQ(config->tracing_mode(), BackgroundTracingConfig::REACTIVE);
281 EXPECT_EQ(config->rules().size(), 1u); 319 EXPECT_EQ(config->rules().size(), 1u);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 ConfigToString(config.get()), 602 ConfigToString(config.get()),
565 "{\"configs\":[{\"category\":\"BENCHMARK_DEEP\",\"rule\":\"TRACE_" 603 "{\"configs\":[{\"category\":\"BENCHMARK_DEEP\",\"rule\":\"TRACE_"
566 "ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\",\"trigger_name\":\"foo1\"},{" 604 "ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\",\"trigger_name\":\"foo1\"},{"
567 "\"category\":\"BENCHMARK_DEEP\",\"rule\":" 605 "\"category\":\"BENCHMARK_DEEP\",\"rule\":"
568 "\"TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\",\"trigger_name\":" 606 "\"TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL\",\"trigger_name\":"
569 "\"foo2\"}],\"mode\":\"REACTIVE_TRACING_MODE\"}"); 607 "\"foo2\"}],\"mode\":\"REACTIVE_TRACING_MODE\"}");
570 } 608 }
571 } 609 }
572 610
573 } // namspace content 611 } // namspace content
OLDNEW
« no previous file with comments | « content/browser/tracing/background_tracing_config_impl.cc ('k') | content/browser/tracing/background_tracing_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698