Index: chrome/browser/component_updater/test/chrome_component_updater_configurator_unittest.cc |
diff --git a/chrome/browser/component_updater/test/chrome_component_updater_configurator_unittest.cc b/chrome/browser/component_updater/test/chrome_component_updater_configurator_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ccca9f348fa790e76e1458d371b304e61c5849aa |
--- /dev/null |
+++ b/chrome/browser/component_updater/test/chrome_component_updater_configurator_unittest.cc |
@@ -0,0 +1,67 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/command_line.h" |
+#include "chrome/browser/component_updater/chrome_component_updater_configurator.h" |
+#include "components/component_updater/component_updater_switches.h" |
+#include "components/update_client/configurator.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+#include "url/gurl.h" |
+ |
+namespace component_updater { |
+ |
+ |
Sorin Jianu
2015/03/23 23:32:01
Extra empty line not needed/
|
+TEST(ChromeComponentUpdaterConfiguratorTest, TestDisablePings) { |
+ base::CommandLine * cmdline = base::CommandLine::ForCurrentProcess(); |
Sorin Jianu
2015/03/23 23:32:01
* goes next to the type.
Are you using the "git c
|
+ cmdline->AppendSwitchASCII(switches::kComponentUpdater, kSwitchDisablePings); |
Sorin Jianu
2015/03/23 23:32:01
There are two ways to write these data driven unit
|
+ |
+ update_client::Configurator* config = |
Sorin Jianu
2015/03/23 23:32:01
Some of these variables can be declared const.
|
+ MakeChromeComponentUpdaterConfigurator(cmdline, NULL); |
+ |
+ std::vector<GURL> pingUrls = config->PingUrl(); |
+ EXPECT_TRUE(pingUrls.empty()); |
+} |
+ |
+TEST(ChromeComponentUpdaterConfiguratorTest, TestFastUpdate) { |
+ base::CommandLine * cmdline = base::CommandLine::ForCurrentProcess(); |
+ // Set command line flag |
Sorin Jianu
2015/03/23 23:32:01
Comment not needed.
|
+ cmdline->AppendSwitchASCII(switches::kComponentUpdater, kSwitchFastUpdate); |
+ |
+ update_client::Configurator* config = |
+ MakeChromeComponentUpdaterConfigurator(cmdline, NULL); |
+ |
+ EXPECT_EQ(config->InitialDelay(), 1); |
+ |
+} |
+ |
+TEST(ChromeComponentUpdaterConfiguratorTest, TestOverrideUrl) { |
+ char overrideUrl[] = "http://0.0.0.0/"; |
+ |
+ base::CommandLine * cmdline = base::CommandLine::ForCurrentProcess(); |
+ std::string val = kSwitchUrlSource; |
+ val.append("="); |
+ val.append(overrideUrl); |
+ cmdline->AppendSwitchASCII(switches::kComponentUpdater, val.c_str()); |
+ |
+ update_client::Configurator* config = |
+ MakeChromeComponentUpdaterConfigurator(cmdline, NULL); |
+ |
+ std::vector<GURL> urls = config->UpdateUrl(); |
+ |
+ // should only be one element |
Sorin Jianu
2015/03/23 23:32:01
Comment not needed.
|
+ EXPECT_EQ(urls.size(), 1U); |
Sorin Jianu
2015/03/23 23:32:01
The syntaxt for the EXPECT assertion is ASSERT_EQ(
|
+ EXPECT_EQ(urls.at(0).possibly_invalid_spec(), overrideUrl); |
+} |
+ |
+TEST(ChromeComponentUpdaterConfiguratorTest, TestSwitchRequestParam) { |
+ base::CommandLine * cmdline = base::CommandLine::ForCurrentProcess(); |
+ cmdline->AppendSwitchASCII(switches::kComponentUpdater, kSwitchRequestParam); |
+ |
+ update_client::Configurator* config = |
+ MakeChromeComponentUpdaterConfigurator(cmdline, NULL); |
+ |
+ EXPECT_FALSE(config->ExtraRequestParams().empty()); |
+} |
+ |
+} // namespace component_updater |
Sorin Jianu
2015/03/23 23:32:01
Needs a space before //.
|