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

Unified Diff: chrome/test/chromedriver/capabilities_unittest.cc

Issue 429693003: [ChromeDriver] Implementing PerfLoggingPrefs for perf log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing memory leak 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/chromedriver/capabilities.cc ('k') | chrome/test/chromedriver/chrome/devtools_client_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/capabilities_unittest.cc
diff --git a/chrome/test/chromedriver/capabilities_unittest.cc b/chrome/test/chromedriver/capabilities_unittest.cc
index 7f77fb10bce53dc85c40cbdf984c29222ddb8825..e687802626a0e86d8e8aa7553e2a4bc6c159288a 100644
--- a/chrome/test/chromedriver/capabilities_unittest.cc
+++ b/chrome/test/chromedriver/capabilities_unittest.cc
@@ -7,6 +7,7 @@
#include "base/values.h"
#include "chrome/test/chromedriver/chrome/log.h"
#include "chrome/test/chromedriver/chrome/status.h"
+#include "chrome/test/chromedriver/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(Switches, Empty) {
@@ -336,6 +337,92 @@ TEST(ParseCapabilities, LoggingPrefsNotDict) {
ASSERT_FALSE(status.IsOk());
}
+TEST(ParseCapabilities, PerfLoggingPrefsInspectorDomainStatus) {
+ Capabilities capabilities;
+ // Perf log must be enabled if performance log preferences are specified.
+ base::DictionaryValue logging_prefs;
+ logging_prefs.SetString(WebDriverLog::kPerformanceType, "INFO");
+ base::DictionaryValue desired_caps;
+ desired_caps.Set("loggingPrefs", logging_prefs.DeepCopy());
+ ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kDefaultEnabled,
+ capabilities.perf_logging_prefs.network);
+ ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kDefaultEnabled,
+ capabilities.perf_logging_prefs.page);
+ ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kDefaultEnabled,
+ capabilities.perf_logging_prefs.timeline);
+ base::DictionaryValue perf_logging_prefs;
+ perf_logging_prefs.SetBoolean("enableNetwork", true);
+ perf_logging_prefs.SetBoolean("enablePage", false);
+ desired_caps.Set("chromeOptions.perfLoggingPrefs",
+ perf_logging_prefs.DeepCopy());
+ Status status = capabilities.Parse(desired_caps);
+ ASSERT_TRUE(status.IsOk());
+ ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kExplicitlyEnabled,
+ capabilities.perf_logging_prefs.network);
+ ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kExplicitlyDisabled,
+ capabilities.perf_logging_prefs.page);
+ ASSERT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kDefaultEnabled,
+ capabilities.perf_logging_prefs.timeline);
+}
+
+TEST(ParseCapabilities, PerfLoggingPrefsTraceCategories) {
+ Capabilities capabilities;
+ // Perf log must be enabled if performance log preferences are specified.
+ base::DictionaryValue logging_prefs;
+ logging_prefs.SetString(WebDriverLog::kPerformanceType, "INFO");
+ base::DictionaryValue desired_caps;
+ desired_caps.Set("loggingPrefs", logging_prefs.DeepCopy());
+ ASSERT_EQ("", capabilities.perf_logging_prefs.trace_categories);
+ base::DictionaryValue perf_logging_prefs;
+ perf_logging_prefs.SetString("traceCategories", "benchmark,webkit.console");
+ desired_caps.Set("chromeOptions.perfLoggingPrefs",
+ perf_logging_prefs.DeepCopy());
+ Status status = capabilities.Parse(desired_caps);
+ ASSERT_TRUE(status.IsOk());
+ ASSERT_EQ("benchmark,webkit.console",
+ capabilities.perf_logging_prefs.trace_categories);
+}
+
+TEST(ParseCapabilities, PerfLoggingPrefsNotDict) {
+ Capabilities capabilities;
+ // Perf log must be enabled if performance log preferences are specified.
+ base::DictionaryValue logging_prefs;
+ logging_prefs.SetString(WebDriverLog::kPerformanceType, "INFO");
+ base::DictionaryValue desired_caps;
+ desired_caps.Set("loggingPrefs", logging_prefs.DeepCopy());
+ desired_caps.SetString("chromeOptions.perfLoggingPrefs", "traceCategories");
+ Status status = capabilities.Parse(desired_caps);
+ ASSERT_FALSE(status.IsOk());
+}
+
+TEST(ParseCapabilities, PerfLoggingPrefsNoPerfLogLevel) {
+ Capabilities capabilities;
+ base::DictionaryValue desired_caps;
+ base::DictionaryValue perf_logging_prefs;
+ perf_logging_prefs.SetBoolean("enableNetwork", true);
+ desired_caps.Set("chromeOptions.perfLoggingPrefs",
+ perf_logging_prefs.DeepCopy());
+ // Should fail because perf log must be enabled if perf log prefs specified.
+ Status status = capabilities.Parse(desired_caps);
+ ASSERT_FALSE(status.IsOk());
+}
+
+TEST(ParseCapabilities, PerfLoggingPrefsPerfLogOff) {
+ Capabilities capabilities;
+ base::DictionaryValue logging_prefs;
+ // Disable performance log by setting logging level to OFF.
+ logging_prefs.SetString(WebDriverLog::kPerformanceType, "OFF");
+ base::DictionaryValue desired_caps;
+ desired_caps.Set("loggingPrefs", logging_prefs.DeepCopy());
+ base::DictionaryValue perf_logging_prefs;
+ perf_logging_prefs.SetBoolean("enableNetwork", true);
+ desired_caps.Set("chromeOptions.perfLoggingPrefs",
+ perf_logging_prefs.DeepCopy());
+ // Should fail because perf log must be enabled if perf log prefs specified.
+ Status status = capabilities.Parse(desired_caps);
+ ASSERT_FALSE(status.IsOk());
+}
+
TEST(ParseCapabilities, ExcludeSwitches) {
Capabilities capabilities;
base::ListValue exclude_switches;
« no previous file with comments | « chrome/test/chromedriver/capabilities.cc ('k') | chrome/test/chromedriver/chrome/devtools_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698