OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "base/command_line.h" | |
6 #include "base/memory/ref_counted.h" | |
7 #include "chrome/browser/component_updater/chrome_component_updater_configurator
.h" | |
8 #include "components/component_updater/component_updater_switches.h" | |
9 #include "components/update_client/configurator.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 #include "url/gurl.h" | |
12 | |
13 namespace component_updater { | |
14 | |
15 TEST(ChromeComponentUpdaterConfiguratorTest, TestDisablePings) { | |
16 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | |
17 cmdline->AppendSwitchASCII(switches::kComponentUpdater, "disable-pings"); | |
18 | |
19 const auto config(MakeChromeComponentUpdaterConfigurator(cmdline, NULL)); | |
20 | |
21 const std::vector<GURL> pingUrls = config->PingUrl(); | |
22 EXPECT_TRUE(pingUrls.empty()); | |
23 } | |
24 | |
25 TEST(ChromeComponentUpdaterConfiguratorTest, TestFastUpdate) { | |
26 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | |
27 cmdline->AppendSwitchASCII(switches::kComponentUpdater, "fast-update"); | |
28 | |
29 const auto config(MakeChromeComponentUpdaterConfigurator(cmdline, NULL)); | |
30 | |
31 ASSERT_EQ(1, config->InitialDelay()); | |
32 } | |
33 | |
34 TEST(ChromeComponentUpdaterConfiguratorTest, TestOverrideUrl) { | |
35 const char overrideUrl[] = "http://0.0.0.0/"; | |
36 | |
37 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | |
38 std::string val = "url-source"; | |
39 val.append("="); | |
40 val.append(overrideUrl); | |
41 cmdline->AppendSwitchASCII(switches::kComponentUpdater, val.c_str()); | |
42 | |
43 const auto config(MakeChromeComponentUpdaterConfigurator(cmdline, NULL)); | |
44 | |
45 const std::vector<GURL> urls = config->UpdateUrl(); | |
46 | |
47 ASSERT_EQ(1U, urls.size()); | |
48 ASSERT_EQ(overrideUrl, urls.at(0).possibly_invalid_spec()); | |
49 } | |
50 | |
51 TEST(ChromeComponentUpdaterConfiguratorTest, TestSwitchRequestParam) { | |
52 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | |
53 cmdline->AppendSwitchASCII(switches::kComponentUpdater, "test-request"); | |
54 | |
55 const auto config(MakeChromeComponentUpdaterConfigurator(cmdline, NULL)); | |
56 | |
57 EXPECT_FALSE(config->ExtraRequestParams().empty()); | |
58 } | |
59 | |
60 } // namespace component_updater | |
OLD | NEW |