| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/scoped_ptr.h" | |
| 6 #include "base/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
| 7 #include "chrome/browser/browser_process.h" | |
| 8 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 6 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
| 9 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 7 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 10 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 8 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 11 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h" | |
| 12 #include "chrome/browser/metrics/variations/variations_service.h" | 9 #include "chrome/browser/metrics/variations/variations_service.h" |
| 13 #include "chrome/test/base/testing_browser_process.h" | 10 #include "chrome/test/base/testing_browser_process.h" |
| 14 #include "net/base/url_util.h" | 11 #include "net/base/url_util.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 13 |
| 17 namespace policy { | 14 namespace policy { |
| 18 | 15 |
| 19 class VariationsServiceDevicePolicyTest : public DevicePolicyCrosBrowserTest { | 16 class VariationsServiceDevicePolicyTest : public DevicePolicyCrosBrowserTest { |
| 20 protected: | 17 protected: |
| 21 VariationsServiceDevicePolicyTest() {} | 18 VariationsServiceDevicePolicyTest() {} |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 | 34 |
| 38 private: | 35 private: |
| 39 DISALLOW_COPY_AND_ASSIGN(VariationsServiceDevicePolicyTest); | 36 DISALLOW_COPY_AND_ASSIGN(VariationsServiceDevicePolicyTest); |
| 40 }; | 37 }; |
| 41 | 38 |
| 42 IN_PROC_BROWSER_TEST_F(VariationsServiceDevicePolicyTest, VariationsURLValid) { | 39 IN_PROC_BROWSER_TEST_F(VariationsServiceDevicePolicyTest, VariationsURLValid) { |
| 43 const std::string default_variations_url = | 40 const std::string default_variations_url = |
| 44 chrome_variations::VariationsService:: | 41 chrome_variations::VariationsService:: |
| 45 GetDefaultVariationsServerURLForTesting(); | 42 GetDefaultVariationsServerURLForTesting(); |
| 46 | 43 |
| 47 // g_browser_process->variations_service() is null by default in Chromium | |
| 48 // builds, so construct a VariationsService locally instead. | |
| 49 scoped_ptr<chrome_variations::VariationsService> service = | |
| 50 chrome_variations::VariationsService::CreateForTesting( | |
| 51 make_scoped_ptr(new ChromeVariationsServiceClient()), | |
| 52 g_browser_process->local_state()); | |
| 53 | |
| 54 // Device policy has updated the cros settings. | 44 // Device policy has updated the cros settings. |
| 55 const GURL url = service->GetVariationsServerURL( | 45 const GURL url = chrome_variations::VariationsService::GetVariationsServerURL( |
| 56 g_browser_process->local_state(), std::string()); | 46 g_browser_process->local_state(), std::string()); |
| 57 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, | 47 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, |
| 58 base::CompareCase::SENSITIVE)); | 48 base::CompareCase::SENSITIVE)); |
| 59 std::string value; | 49 std::string value; |
| 60 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 50 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
| 61 EXPECT_EQ("restricted", value); | 51 EXPECT_EQ("restricted", value); |
| 62 } | 52 } |
| 63 | 53 |
| 64 } // namespace policy | 54 } // namespace policy |
| OLD | NEW |