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

Side by Side Diff: chrome/test/chromedriver/capabilities_unittest.cc

Issue 454133003: [ChromeDriver] Implementing tracing support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing nits Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/test/chromedriver/capabilities.h" 5 #include "chrome/test/chromedriver/capabilities.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/test/chromedriver/chrome/log.h" 8 #include "chrome/test/chromedriver/chrome/log.h"
9 #include "chrome/test/chromedriver/chrome/status.h" 9 #include "chrome/test/chromedriver/chrome/status.h"
10 #include "chrome/test/chromedriver/logging.h" 10 #include "chrome/test/chromedriver/logging.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 Status status = capabilities.Parse(desired_caps); 358 Status status = capabilities.Parse(desired_caps);
359 ASSERT_TRUE(status.IsOk()); 359 ASSERT_TRUE(status.IsOk());
360 ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kExplicitlyEnabled, 360 ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kExplicitlyEnabled,
361 capabilities.perf_logging_prefs.network); 361 capabilities.perf_logging_prefs.network);
362 ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kExplicitlyDisabled, 362 ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kExplicitlyDisabled,
363 capabilities.perf_logging_prefs.page); 363 capabilities.perf_logging_prefs.page);
364 ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kDefaultEnabled, 364 ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kDefaultEnabled,
365 capabilities.perf_logging_prefs.timeline); 365 capabilities.perf_logging_prefs.timeline);
366 } 366 }
367 367
368 TEST(ParseCapabilities, PerfLoggingPrefsTraceCategories) { 368 TEST(ParseCapabilities, PerfLoggingPrefsTracing) {
369 Capabilities capabilities; 369 Capabilities capabilities;
370 // Perf log must be enabled if performance log preferences are specified. 370 // Perf log must be enabled if performance log preferences are specified.
371 base::DictionaryValue logging_prefs; 371 base::DictionaryValue logging_prefs;
372 logging_prefs.SetString(WebDriverLog::kPerformanceType, "INFO"); 372 logging_prefs.SetString(WebDriverLog::kPerformanceType, "INFO");
373 base::DictionaryValue desired_caps; 373 base::DictionaryValue desired_caps;
374 desired_caps.Set("loggingPrefs", logging_prefs.DeepCopy()); 374 desired_caps.Set("loggingPrefs", logging_prefs.DeepCopy());
375 ASSERT_EQ("", capabilities.perf_logging_prefs.trace_categories); 375 ASSERT_EQ("", capabilities.perf_logging_prefs.trace_categories);
376 base::DictionaryValue perf_logging_prefs; 376 base::DictionaryValue perf_logging_prefs;
377 perf_logging_prefs.SetString("traceCategories", "benchmark,webkit.console"); 377 perf_logging_prefs.SetString("traceCategories", "benchmark,blink.console");
378 perf_logging_prefs.SetInteger("bufferUsageReportingInterval", 1234);
378 desired_caps.Set("chromeOptions.perfLoggingPrefs", 379 desired_caps.Set("chromeOptions.perfLoggingPrefs",
379 perf_logging_prefs.DeepCopy()); 380 perf_logging_prefs.DeepCopy());
380 Status status = capabilities.Parse(desired_caps); 381 Status status = capabilities.Parse(desired_caps);
381 ASSERT_TRUE(status.IsOk()); 382 ASSERT_TRUE(status.IsOk());
382 ASSERT_EQ("benchmark,webkit.console", 383 ASSERT_EQ("benchmark,blink.console",
383 capabilities.perf_logging_prefs.trace_categories); 384 capabilities.perf_logging_prefs.trace_categories);
385 ASSERT_EQ(1234,
386 capabilities.perf_logging_prefs.buffer_usage_reporting_interval);
387 }
388
389 TEST(ParseCapabilities, PerfLoggingPrefsInvalidInterval) {
390 Capabilities capabilities;
391 // Perf log must be enabled if performance log preferences are specified.
392 base::DictionaryValue logging_prefs;
393 logging_prefs.SetString(WebDriverLog::kPerformanceType, "INFO");
394 base::DictionaryValue desired_caps;
395 desired_caps.Set("loggingPrefs", logging_prefs.DeepCopy());
396 base::DictionaryValue perf_logging_prefs;
397 // A bufferUsageReportingInterval interval <= 0 will cause DevTools errors.
398 perf_logging_prefs.SetInteger("bufferUsageReportingInterval", 0);
399 desired_caps.Set("chromeOptions.perfLoggingPrefs",
400 perf_logging_prefs.DeepCopy());
401 Status status = capabilities.Parse(desired_caps);
402 ASSERT_FALSE(status.IsOk());
384 } 403 }
385 404
386 TEST(ParseCapabilities, PerfLoggingPrefsNotDict) { 405 TEST(ParseCapabilities, PerfLoggingPrefsNotDict) {
387 Capabilities capabilities; 406 Capabilities capabilities;
388 // Perf log must be enabled if performance log preferences are specified. 407 // Perf log must be enabled if performance log preferences are specified.
389 base::DictionaryValue logging_prefs; 408 base::DictionaryValue logging_prefs;
390 logging_prefs.SetString(WebDriverLog::kPerformanceType, "INFO"); 409 logging_prefs.SetString(WebDriverLog::kPerformanceType, "INFO");
391 base::DictionaryValue desired_caps; 410 base::DictionaryValue desired_caps;
392 desired_caps.Set("loggingPrefs", logging_prefs.DeepCopy()); 411 desired_caps.Set("loggingPrefs", logging_prefs.DeepCopy());
393 desired_caps.SetString("chromeOptions.perfLoggingPrefs", "traceCategories"); 412 desired_caps.SetString("chromeOptions.perfLoggingPrefs", "traceCategories");
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 base::DictionaryValue mobile_emulation; 555 base::DictionaryValue mobile_emulation;
537 mobile_emulation.SetString("deviceName", "Google Nexus 5"); 556 mobile_emulation.SetString("deviceName", "Google Nexus 5");
538 mobile_emulation.SetInteger("deviceMetrics.width", 360); 557 mobile_emulation.SetInteger("deviceMetrics.width", 360);
539 mobile_emulation.SetInteger("deviceMetrics.height", 640); 558 mobile_emulation.SetInteger("deviceMetrics.height", 640);
540 mobile_emulation.SetDouble("deviceMetrics.pixelRatio", 3.0); 559 mobile_emulation.SetDouble("deviceMetrics.pixelRatio", 3.0);
541 base::DictionaryValue caps; 560 base::DictionaryValue caps;
542 caps.Set("chromeOptions.mobileEmulation", mobile_emulation.DeepCopy()); 561 caps.Set("chromeOptions.mobileEmulation", mobile_emulation.DeepCopy());
543 Status status = capabilities.Parse(caps); 562 Status status = capabilities.Parse(caps);
544 ASSERT_FALSE(status.IsOk()); 563 ASSERT_FALSE(status.IsOk());
545 } 564 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/capabilities.cc ('k') | chrome/test/chromedriver/client/chromedriver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698