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

Unified Diff: chrome/browser/component_updater/test/chrome_component_updater_configurator_unittest.cc

Issue 1013003003: Add tests for Component Updater command line arguments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
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 //.
« no previous file with comments | « chrome/browser/component_updater/chrome_component_updater_configurator.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698