OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/metrics/variations/variations_service.h" | 5 #include "chrome/browser/metrics/variations/variations_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/prefs/testing_pref_service.h" | 10 #include "base/prefs/testing_pref_service.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 }; | 236 }; |
237 | 237 |
238 TEST_F(VariationsServiceTest, GetVariationsServerURL) { | 238 TEST_F(VariationsServiceTest, GetVariationsServerURL) { |
239 TestVariationsPrefsStore prefs_store; | 239 TestVariationsPrefsStore prefs_store; |
240 PrefService* prefs = prefs_store.prefs(); | 240 PrefService* prefs = prefs_store.prefs(); |
241 const std::string default_variations_url = | 241 const std::string default_variations_url = |
242 VariationsService::GetDefaultVariationsServerURLForTesting(); | 242 VariationsService::GetDefaultVariationsServerURLForTesting(); |
243 | 243 |
244 std::string value; | 244 std::string value; |
245 GURL url = VariationsService::GetVariationsServerURL(prefs, std::string()); | 245 GURL url = VariationsService::GetVariationsServerURL(prefs, std::string()); |
246 EXPECT_TRUE(base::StartsWithASCII(url.spec(), default_variations_url, true)); | 246 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, |
| 247 base::CompareCase::SENSITIVE)); |
247 EXPECT_FALSE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 248 EXPECT_FALSE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
248 | 249 |
249 prefs_store.SetVariationsRestrictParameterPolicyValue("restricted"); | 250 prefs_store.SetVariationsRestrictParameterPolicyValue("restricted"); |
250 url = VariationsService::GetVariationsServerURL(prefs, std::string()); | 251 url = VariationsService::GetVariationsServerURL(prefs, std::string()); |
251 EXPECT_TRUE(base::StartsWithASCII(url.spec(), default_variations_url, true)); | 252 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, |
| 253 base::CompareCase::SENSITIVE)); |
252 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 254 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
253 EXPECT_EQ("restricted", value); | 255 EXPECT_EQ("restricted", value); |
254 | 256 |
255 // The override value should take precedence over what's in prefs. | 257 // The override value should take precedence over what's in prefs. |
256 url = VariationsService::GetVariationsServerURL(prefs, "override"); | 258 url = VariationsService::GetVariationsServerURL(prefs, "override"); |
257 EXPECT_TRUE(base::StartsWithASCII(url.spec(), default_variations_url, true)); | 259 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, |
| 260 base::CompareCase::SENSITIVE)); |
258 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 261 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
259 EXPECT_EQ("override", value); | 262 EXPECT_EQ("override", value); |
260 } | 263 } |
261 | 264 |
262 TEST_F(VariationsServiceTest, VariationsURLHasOSNameParam) { | 265 TEST_F(VariationsServiceTest, VariationsURLHasOSNameParam) { |
263 TestingPrefServiceSimple prefs; | 266 TestingPrefServiceSimple prefs; |
264 VariationsService::RegisterPrefs(prefs.registry()); | 267 VariationsService::RegisterPrefs(prefs.registry()); |
265 const GURL url = | 268 const GURL url = |
266 VariationsService::GetVariationsServerURL(&prefs, std::string()); | 269 VariationsService::GetVariationsServerURL(&prefs, std::string()); |
267 | 270 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 EXPECT_TRUE(expected_list_value.Equals( | 507 EXPECT_TRUE(expected_list_value.Equals( |
505 prefs.GetList(prefs::kVariationsPermanentConsistencyCountry))); | 508 prefs.GetList(prefs::kVariationsPermanentConsistencyCountry))); |
506 | 509 |
507 histogram_tester.ExpectUniqueSample( | 510 histogram_tester.ExpectUniqueSample( |
508 "Variations.LoadPermanentConsistencyCountryResult", | 511 "Variations.LoadPermanentConsistencyCountryResult", |
509 test.expected_result, 1); | 512 test.expected_result, 1); |
510 } | 513 } |
511 } | 514 } |
512 | 515 |
513 } // namespace chrome_variations | 516 } // namespace chrome_variations |
OLD | NEW |