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/scoped_ptr.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 scoped_ptr<update_client::Configurator> config( |
| 20 MakeChromeComponentUpdaterConfigurator(cmdline, NULL)); |
| 21 |
| 22 const std::vector<GURL> pingUrls = config->PingUrl(); |
| 23 EXPECT_TRUE(pingUrls.empty()); |
| 24 } |
| 25 |
| 26 TEST(ChromeComponentUpdaterConfiguratorTest, TestFastUpdate) { |
| 27 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 28 cmdline->AppendSwitchASCII(switches::kComponentUpdater, "fast-update"); |
| 29 |
| 30 scoped_ptr<update_client::Configurator> config( |
| 31 MakeChromeComponentUpdaterConfigurator(cmdline, NULL)); |
| 32 |
| 33 ASSERT_EQ(1, config->InitialDelay()); |
| 34 } |
| 35 |
| 36 TEST(ChromeComponentUpdaterConfiguratorTest, TestOverrideUrl) { |
| 37 const char overrideUrl[] = "http://0.0.0.0/"; |
| 38 |
| 39 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 40 std::string val = "url-source"; |
| 41 val.append("="); |
| 42 val.append(overrideUrl); |
| 43 cmdline->AppendSwitchASCII(switches::kComponentUpdater, val.c_str()); |
| 44 |
| 45 scoped_ptr<update_client::Configurator> config( |
| 46 MakeChromeComponentUpdaterConfigurator(cmdline, NULL)); |
| 47 |
| 48 const std::vector<GURL> urls = config->UpdateUrl(); |
| 49 |
| 50 ASSERT_EQ(1U, urls.size()); |
| 51 ASSERT_EQ(overrideUrl, urls.at(0).possibly_invalid_spec()); |
| 52 } |
| 53 |
| 54 TEST(ChromeComponentUpdaterConfiguratorTest, TestSwitchRequestParam) { |
| 55 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 56 cmdline->AppendSwitchASCII(switches::kComponentUpdater, "test-request"); |
| 57 |
| 58 scoped_ptr<update_client::Configurator> config( |
| 59 MakeChromeComponentUpdaterConfigurator(cmdline, NULL)); |
| 60 |
| 61 EXPECT_FALSE(config->ExtraRequestParams().empty()); |
| 62 } |
| 63 |
| 64 } // namespace component_updater |
OLD | NEW |