Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: chrome/browser/chromeos/policy/variations_service_policy_browsertest.cc

Issue 1313213005: Turn VariationsService::GetVariationsServerURL into instance method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use locally-constructed VariationsService in browsertests Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/string_util.h" 5 #include "base/strings/string_util.h"
6 #include "chrome/browser/chromeos/policy/device_policy_builder.h" 6 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
7 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.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" 8 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
9 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h"
9 #include "chrome/browser/metrics/variations/variations_service.h" 10 #include "chrome/browser/metrics/variations/variations_service.h"
10 #include "chrome/test/base/testing_browser_process.h" 11 #include "chrome/test/base/testing_browser_process.h"
12 #include "components/web_resource/resource_request_allowed_notifier.h"
11 #include "net/base/url_util.h" 13 #include "net/base/url_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 15
14 namespace policy { 16 namespace policy {
15 17
16 class VariationsServiceDevicePolicyTest : public DevicePolicyCrosBrowserTest { 18 class VariationsServiceDevicePolicyTest : public DevicePolicyCrosBrowserTest {
17 protected: 19 protected:
18 VariationsServiceDevicePolicyTest() {} 20 VariationsServiceDevicePolicyTest() {}
19 21
20 void SetUpInProcessBrowserTestFixture() override { 22 void SetUpInProcessBrowserTestFixture() override {
(...skipping 13 matching lines...) Expand all
34 36
35 private: 37 private:
36 DISALLOW_COPY_AND_ASSIGN(VariationsServiceDevicePolicyTest); 38 DISALLOW_COPY_AND_ASSIGN(VariationsServiceDevicePolicyTest);
37 }; 39 };
38 40
39 IN_PROC_BROWSER_TEST_F(VariationsServiceDevicePolicyTest, VariationsURLValid) { 41 IN_PROC_BROWSER_TEST_F(VariationsServiceDevicePolicyTest, VariationsURLValid) {
40 const std::string default_variations_url = 42 const std::string default_variations_url =
41 chrome_variations::VariationsService:: 43 chrome_variations::VariationsService::
42 GetDefaultVariationsServerURLForTesting(); 44 GetDefaultVariationsServerURLForTesting();
43 45
46 // g_browser_process->variations_service() is null by default in Chromium
47 // builds, so construct a VariationsService locally instead.
48 chrome_variations::VariationsService service(
49 make_scoped_ptr(new ChromeVariationsServiceClient()),
50 new web_resource::ResourceRequestAllowedNotifier(
51 g_browser_process->local_state(), nullptr),
Alexei Svitkine (slow) 2015/08/31 15:03:02 It's pretty weird that with the change to pass in
blundell 2015/09/01 10:03:06 Done.
52 g_browser_process->local_state(), NULL);
Alexei Svitkine (slow) 2015/08/31 15:03:02 nullptr
blundell 2015/09/01 10:03:06 Done.
53
44 // Device policy has updated the cros settings. 54 // Device policy has updated the cros settings.
45 const GURL url = chrome_variations::VariationsService::GetVariationsServerURL( 55 const GURL url = service.GetVariationsServerURL(
46 g_browser_process->local_state(), std::string()); 56 g_browser_process->local_state(), std::string());
47 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, 57 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url,
48 base::CompareCase::SENSITIVE)); 58 base::CompareCase::SENSITIVE));
49 std::string value; 59 std::string value;
50 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); 60 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value));
51 EXPECT_EQ("restricted", value); 61 EXPECT_EQ("restricted", value);
52 } 62 }
53 63
54 } // namespace policy 64 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698