Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / component_updater / chrome_component_updater_configurator_unittest.cc
blobebc99d8941d90bfbb8dc90b2f548ee712bcd00b1
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <string>
6 #include <vector>
8 #include "base/command_line.h"
9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/component_updater/chrome_component_updater_configurator.h"
11 #include "components/component_updater/component_updater_switches.h"
12 #include "components/update_client/configurator.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "url/gurl.h"
16 namespace component_updater {
18 TEST(ChromeComponentUpdaterConfiguratorTest, TestDisablePings) {
19 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
20 cmdline->AppendSwitchASCII(switches::kComponentUpdater, "disable-pings");
22 const auto config(MakeChromeComponentUpdaterConfigurator(cmdline, NULL));
24 const std::vector<GURL> pingUrls = config->PingUrl();
25 EXPECT_TRUE(pingUrls.empty());
28 TEST(ChromeComponentUpdaterConfiguratorTest, TestFastUpdate) {
29 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
30 cmdline->AppendSwitchASCII(switches::kComponentUpdater, "fast-update");
32 const auto config(MakeChromeComponentUpdaterConfigurator(cmdline, NULL));
34 ASSERT_EQ(10, config->InitialDelay());
37 TEST(ChromeComponentUpdaterConfiguratorTest, TestOverrideUrl) {
38 const char overrideUrl[] = "http://0.0.0.0/";
40 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
41 std::string val = "url-source";
42 val.append("=");
43 val.append(overrideUrl);
44 cmdline->AppendSwitchASCII(switches::kComponentUpdater, val.c_str());
46 const auto config(MakeChromeComponentUpdaterConfigurator(cmdline, NULL));
48 const std::vector<GURL> urls = config->UpdateUrl();
50 ASSERT_EQ(1U, urls.size());
51 ASSERT_EQ(overrideUrl, urls.at(0).possibly_invalid_spec());
54 TEST(ChromeComponentUpdaterConfiguratorTest, TestSwitchRequestParam) {
55 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
56 cmdline->AppendSwitchASCII(switches::kComponentUpdater, "test-request");
58 const auto config(MakeChromeComponentUpdaterConfigurator(cmdline, NULL));
60 EXPECT_FALSE(config->ExtraRequestParams().empty());
63 } // namespace component_updater