Turn VariationsService::GetVariationsServerURL into instance method
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / variations_service_policy_browsertest.cc
blob603a98106544da74d71c2adbcb414eca63fd644a
1 // Copyright (c) 2013 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 "base/strings/string_util.h"
6 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
7 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
8 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
9 #include "chrome/browser/metrics/variations/variations_service.h"
10 #include "chrome/test/base/testing_browser_process.h"
11 #include "net/base/url_util.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace policy {
16 class VariationsServiceDevicePolicyTest : public DevicePolicyCrosBrowserTest {
17 protected:
18 VariationsServiceDevicePolicyTest() {}
20 void SetUpInProcessBrowserTestFixture() override {
21 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture();
23 InstallOwnerKey();
24 SetSpecificDevicePolicies();
25 RefreshDevicePolicy();
28 void SetSpecificDevicePolicies() {
29 // Setup the device policy DeviceVariationsRestrictParameter.
30 enterprise_management::ChromeDeviceSettingsProto& proto(
31 device_policy()->payload());
32 proto.mutable_variations_parameter()->set_parameter("restricted");
35 private:
36 DISALLOW_COPY_AND_ASSIGN(VariationsServiceDevicePolicyTest);
39 IN_PROC_BROWSER_TEST_F(VariationsServiceDevicePolicyTest, VariationsURLValid) {
40 const std::string default_variations_url =
41 chrome_variations::VariationsService::
42 GetDefaultVariationsServerURLForTesting();
44 // Device policy has updated the cros settings.
45 const GURL url =
46 g_browser_process->variations_service()->GetVariationsServerURL(
47 g_browser_process->local_state(), std::string());
48 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url,
49 base::CompareCase::SENSITIVE));
50 std::string value;
51 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value));
52 EXPECT_EQ("restricted", value);
55 } // namespace policy