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

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

Issue 23643005: [chromedriver] Load the automation extension as a component extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 7 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/adb_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 9717c593ea2618fdca39a6db70d70337aad4e3cd..6b8eaa51fc3c2432acd403ec6470b6787d7bc8b2 100644
--- a/chrome/test/chromedriver/capabilities_unittest.cc
+++ b/chrome/test/chromedriver/capabilities_unittest.cc
@@ -9,6 +9,94 @@
#include "chrome/test/chromedriver/chrome/status.h"
#include "testing/gtest/include/gtest/gtest.h"
+TEST(Switches, Empty) {
+ Switches switches;
+ CommandLine cmd(CommandLine::NO_PROGRAM);
+ switches.AppendToCommandLine(&cmd);
+ ASSERT_EQ(0u, cmd.GetSwitches().size());
+ ASSERT_EQ("", switches.ToString());
+}
+
+TEST(Switches, NoValue) {
+ Switches switches;
+ switches.SetSwitch("hello");
+
+ ASSERT_TRUE(switches.HasSwitch("hello"));
+ ASSERT_EQ("", switches.GetSwitchValue("hello"));
+
+ CommandLine cmd(CommandLine::NO_PROGRAM);
+ switches.AppendToCommandLine(&cmd);
+ ASSERT_TRUE(cmd.HasSwitch("hello"));
+ ASSERT_EQ(FILE_PATH_LITERAL(""), cmd.GetSwitchValueNative("hello"));
+ ASSERT_EQ("--hello", switches.ToString());
+}
+
+TEST(Switches, Value) {
+ Switches switches;
+ switches.SetSwitch("hello", "there");
+
+ ASSERT_TRUE(switches.HasSwitch("hello"));
+ ASSERT_EQ("there", switches.GetSwitchValue("hello"));
+
+ CommandLine cmd(CommandLine::NO_PROGRAM);
+ switches.AppendToCommandLine(&cmd);
+ ASSERT_TRUE(cmd.HasSwitch("hello"));
+ ASSERT_EQ(FILE_PATH_LITERAL("there"), cmd.GetSwitchValueNative("hello"));
+ ASSERT_EQ("--hello=there", switches.ToString());
+}
+
+TEST(Switches, FromOther) {
+ Switches switches;
+ switches.SetSwitch("a", "1");
+ switches.SetSwitch("b", "1");
+
+ Switches switches2;
+ switches2.SetSwitch("b", "2");
+ switches2.SetSwitch("c", "2");
+
+ switches.SetFromSwitches(switches2);
+ ASSERT_EQ("--a=1 --b=2 --c=2", switches.ToString());
+}
+
+TEST(Switches, Remove) {
+ Switches switches;
+ switches.SetSwitch("a", "1");
+ switches.RemoveSwitch("a");
+ ASSERT_FALSE(switches.HasSwitch("a"));
+}
+
+TEST(Switches, Quoting) {
+ Switches switches;
+ switches.SetSwitch("hello", "a b");
+ switches.SetSwitch("hello2", " '\" ");
+
+ ASSERT_EQ("--hello=\"a b\" --hello2=\" '\\\" \"", switches.ToString());
+}
+
+TEST(Switches, Multiple) {
+ Switches switches;
+ switches.SetSwitch("switch");
+ switches.SetSwitch("hello", "there");
+
+ CommandLine cmd(CommandLine::NO_PROGRAM);
+ switches.AppendToCommandLine(&cmd);
+ ASSERT_TRUE(cmd.HasSwitch("switch"));
+ ASSERT_TRUE(cmd.HasSwitch("hello"));
+ ASSERT_EQ(FILE_PATH_LITERAL("there"), cmd.GetSwitchValueNative("hello"));
+ ASSERT_EQ("--hello=there --switch", switches.ToString());
+}
+
+TEST(Switches, Unparsed) {
+ Switches switches;
+ switches.SetUnparsedSwitch("a");
+ switches.SetUnparsedSwitch("--b");
+ switches.SetUnparsedSwitch("--c=1");
+ switches.SetUnparsedSwitch("d=1");
+ switches.SetUnparsedSwitch("-e=--1=1");
+
+ ASSERT_EQ("---e=--1=1 --a --b --c=1 --d=1", switches.ToString());
+}
+
TEST(ParseCapabilities, WithAndroidPackage) {
Capabilities capabilities;
base::DictionaryValue caps;
@@ -48,68 +136,23 @@ TEST(ParseCapabilities, LogPath) {
ASSERT_STREQ("path/to/logfile", capabilities.log_path.c_str());
}
-TEST(ParseCapabilities, NoArgs) {
- Capabilities capabilities;
- base::ListValue args;
- ASSERT_TRUE(args.empty());
- base::DictionaryValue caps;
- caps.Set("chromeOptions.args", args.DeepCopy());
- Logger log(Log::kError);
- Status status = capabilities.Parse(caps, &log);
- ASSERT_TRUE(status.IsOk());
- ASSERT_TRUE(capabilities.command.GetSwitches().empty());
-}
-
-TEST(ParseCapabilities, SingleArgWithoutValue) {
- Capabilities capabilities;
- base::ListValue args;
- args.AppendString("enable-nacl");
- ASSERT_EQ(1u, args.GetSize());
- base::DictionaryValue caps;
- caps.Set("chromeOptions.args", args.DeepCopy());
- Logger log(Log::kError);
- Status status = capabilities.Parse(caps, &log);
- ASSERT_TRUE(status.IsOk());
- ASSERT_EQ(1u, capabilities.command.GetSwitches().size());
- ASSERT_TRUE(capabilities.command.HasSwitch("enable-nacl"));
-}
-
-TEST(ParseCapabilities, SingleArgWithValue) {
- Capabilities capabilities;
- base::ListValue args;
- args.AppendString("load-extension=/test/extension");
- ASSERT_EQ(1u, args.GetSize());
- base::DictionaryValue caps;
- caps.Set("chromeOptions.args", args.DeepCopy());
- Logger log(Log::kError);
- Status status = capabilities.Parse(caps, &log);
- ASSERT_TRUE(status.IsOk());
- ASSERT_EQ(1u, capabilities.command.GetSwitches().size());
- ASSERT_TRUE(capabilities.command.HasSwitch("load-extension"));
- ASSERT_STREQ(
- "/test/extension",
- capabilities.command.GetSwitchValueASCII("load-extension").c_str());
-}
-
-TEST(ParseCapabilities, MultipleArgs) {
+TEST(ParseCapabilities, Args) {
Capabilities capabilities;
base::ListValue args;
args.AppendString("arg1");
args.AppendString("arg2=val");
- args.AppendString("arg3='a space'");
- ASSERT_EQ(3u, args.GetSize());
base::DictionaryValue caps;
caps.Set("chromeOptions.args", args.DeepCopy());
+
Logger log(Log::kError);
Status status = capabilities.Parse(caps, &log);
ASSERT_TRUE(status.IsOk());
- ASSERT_EQ(3u, capabilities.command.GetSwitches().size());
- ASSERT_TRUE(capabilities.command.HasSwitch("arg1"));
- ASSERT_TRUE(capabilities.command.HasSwitch("arg2"));
- ASSERT_STREQ("val", capabilities.command.GetSwitchValueASCII("arg2").c_str());
- ASSERT_TRUE(capabilities.command.HasSwitch("arg3"));
- ASSERT_STREQ("'a space'",
- capabilities.command.GetSwitchValueASCII("arg3").c_str());
+
+ ASSERT_EQ(2u, capabilities.switches.GetSize());
+ ASSERT_TRUE(capabilities.switches.HasSwitch("arg1"));
+ ASSERT_TRUE(capabilities.switches.HasSwitch("arg2"));
+ ASSERT_EQ("", capabilities.switches.GetSwitchValue("arg1"));
+ ASSERT_EQ("val", capabilities.switches.GetSwitchValue("arg2"));
}
TEST(ParseCapabilities, Prefs) {
@@ -184,8 +227,8 @@ TEST(ParseCapabilities, DirectProxy) {
Logger log(Log::kError);
Status status = capabilities.Parse(caps, &log);
ASSERT_TRUE(status.IsOk());
- ASSERT_EQ(1u, capabilities.command.GetSwitches().size());
- ASSERT_TRUE(capabilities.command.HasSwitch("no-proxy-server"));
+ ASSERT_EQ(1u, capabilities.switches.GetSize());
+ ASSERT_TRUE(capabilities.switches.HasSwitch("no-proxy-server"));
}
TEST(ParseCapabilities, SystemProxy) {
@@ -197,7 +240,7 @@ TEST(ParseCapabilities, SystemProxy) {
Logger log(Log::kError);
Status status = capabilities.Parse(caps, &log);
ASSERT_TRUE(status.IsOk());
- ASSERT_TRUE(capabilities.command.GetSwitches().empty());
+ ASSERT_EQ(0u, capabilities.switches.GetSize());
}
TEST(ParseCapabilities, PacProxy) {
@@ -210,10 +253,8 @@ TEST(ParseCapabilities, PacProxy) {
Logger log(Log::kError);
Status status = capabilities.Parse(caps, &log);
ASSERT_TRUE(status.IsOk());
- ASSERT_EQ(1u, capabilities.command.GetSwitches().size());
- ASSERT_STREQ(
- "test.wpad",
- capabilities.command.GetSwitchValueASCII("proxy-pac-url").c_str());
+ ASSERT_EQ(1u, capabilities.switches.GetSize());
+ ASSERT_EQ("test.wpad", capabilities.switches.GetSwitchValue("proxy-pac-url"));
}
TEST(ParseCapabilities, MissingProxyAutoconfigUrl) {
@@ -237,8 +278,8 @@ TEST(ParseCapabilities, AutodetectProxy) {
Logger log(Log::kError);
Status status = capabilities.Parse(caps, &log);
ASSERT_TRUE(status.IsOk());
- ASSERT_EQ(1u, capabilities.command.GetSwitches().size());
- ASSERT_TRUE(capabilities.command.HasSwitch("proxy-auto-detect"));
+ ASSERT_EQ(1u, capabilities.switches.GetSize());
+ ASSERT_TRUE(capabilities.switches.HasSwitch("proxy-auto-detect"));
}
TEST(ParseCapabilities, ManualProxy) {
@@ -254,13 +295,13 @@ TEST(ParseCapabilities, ManualProxy) {
Logger log(Log::kError);
Status status = capabilities.Parse(caps, &log);
ASSERT_TRUE(status.IsOk());
- ASSERT_EQ(2u, capabilities.command.GetSwitches().size());
- ASSERT_STREQ(
+ ASSERT_EQ(2u, capabilities.switches.GetSize());
+ ASSERT_EQ(
"ftp=localhost:9001;http=localhost:8001;https=localhost:10001",
- capabilities.command.GetSwitchValueASCII("proxy-server").c_str());
- ASSERT_STREQ(
+ capabilities.switches.GetSwitchValue("proxy-server"));
+ ASSERT_EQ(
"google.com, youtube.com",
- capabilities.command.GetSwitchValueASCII("proxy-bypass-list").c_str());
+ capabilities.switches.GetSwitchValue("proxy-bypass-list"));
}
TEST(ParseCapabilities, MissingSettingForManualProxy) {
@@ -286,11 +327,11 @@ TEST(ParseCapabilities, IgnoreNullValueForManualProxy) {
Logger log(Log::kError);
Status status = capabilities.Parse(caps, &log);
ASSERT_TRUE(status.IsOk());
- ASSERT_EQ(1u, capabilities.command.GetSwitches().size());
- ASSERT_TRUE(capabilities.command.HasSwitch("proxy-server"));
- ASSERT_STREQ(
+ ASSERT_EQ(1u, capabilities.switches.GetSize());
+ ASSERT_TRUE(capabilities.switches.HasSwitch("proxy-server"));
+ ASSERT_EQ(
"ftp=localhost:9001",
- capabilities.command.GetSwitchValueASCII("proxy-server").c_str());
+ capabilities.switches.GetSwitchValue("proxy-server"));
}
TEST(ParseCapabilities, LoggingPrefsOk) {
@@ -337,11 +378,11 @@ TEST(ParseCapabilities, ExcludeSwitches) {
TEST(ParseCapabilities, UseExistingBrowser) {
Capabilities capabilities;
base::DictionaryValue caps;
- caps.SetString("chromeOptions.useExistingBrowser", "abc:123");
+ caps.SetString("chromeOptions.debuggerAddress", "abc:123");
Logger log(Log::kError);
Status status = capabilities.Parse(caps, &log);
ASSERT_TRUE(status.IsOk());
ASSERT_TRUE(capabilities.IsExistingBrowser());
- ASSERT_EQ("abc", capabilities.use_existing_browser.host());
- ASSERT_EQ(123, capabilities.use_existing_browser.port());
+ ASSERT_EQ("abc", capabilities.debugger_address.host());
+ ASSERT_EQ(123, capabilities.debugger_address.port());
}
« no previous file with comments | « chrome/test/chromedriver/capabilities.cc ('k') | chrome/test/chromedriver/chrome/adb_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698