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

Side by Side Diff: components/variations/service/variations_service_unittest.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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) 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 "components/variations/service/variations_service.h" 5 #include "components/variations/service/variations_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/base64.h" 11 #include "base/base64.h"
12 #include "base/feature_list.h" 12 #include "base/feature_list.h"
13 #include "base/json/json_string_value_serializer.h" 13 #include "base/json/json_string_value_serializer.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/prefs/testing_pref_service.h" 16 #include "base/prefs/testing_pref_service.h"
17 #include "base/sha1.h" 17 #include "base/sha1.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 DISALLOW_COPY_AND_ASSIGN(TestVariationsServiceClient); 73 DISALLOW_COPY_AND_ASSIGN(TestVariationsServiceClient);
74 }; 74 };
75 75
76 // A test class used to validate expected functionality in VariationsService. 76 // A test class used to validate expected functionality in VariationsService.
77 class TestVariationsService : public VariationsService { 77 class TestVariationsService : public VariationsService {
78 public: 78 public:
79 TestVariationsService( 79 TestVariationsService(
80 scoped_ptr<web_resource::TestRequestAllowedNotifier> test_notifier, 80 scoped_ptr<web_resource::TestRequestAllowedNotifier> test_notifier,
81 PrefService* local_state) 81 PrefService* local_state)
82 : VariationsService(make_scoped_ptr(new TestVariationsServiceClient()), 82 : VariationsService(make_scoped_ptr(new TestVariationsServiceClient()),
83 test_notifier.Pass(), 83 std::move(test_notifier),
84 local_state, 84 local_state,
85 NULL, 85 NULL,
86 UIStringOverrider()), 86 UIStringOverrider()),
87 intercepts_fetch_(true), 87 intercepts_fetch_(true),
88 fetch_attempted_(false), 88 fetch_attempted_(false),
89 seed_stored_(false), 89 seed_stored_(false),
90 delta_compressed_seed_(false), 90 delta_compressed_seed_(false),
91 gzip_compressed_seed_(false) { 91 gzip_compressed_seed_(false) {
92 // Set this so StartRepeatedVariationsSeedFetch can be called in tests. 92 // Set this so StartRepeatedVariationsSeedFetch can be called in tests.
93 SetCreateTrialsFromSeedCalledForTesting(true); 93 SetCreateTrialsFromSeedCalledForTesting(true);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 TestingPrefServiceSimple prefs; 353 TestingPrefServiceSimple prefs;
354 VariationsService::RegisterPrefs(prefs.registry()); 354 VariationsService::RegisterPrefs(prefs.registry());
355 const std::string default_variations_url = 355 const std::string default_variations_url =
356 VariationsService::GetDefaultVariationsServerURLForTesting(); 356 VariationsService::GetDefaultVariationsServerURLForTesting();
357 357
358 std::string value; 358 std::string value;
359 scoped_ptr<TestVariationsServiceClient> client = 359 scoped_ptr<TestVariationsServiceClient> client =
360 make_scoped_ptr(new TestVariationsServiceClient()); 360 make_scoped_ptr(new TestVariationsServiceClient());
361 TestVariationsServiceClient* raw_client = client.get(); 361 TestVariationsServiceClient* raw_client = client.get();
362 VariationsService service( 362 VariationsService service(
363 client.Pass(), 363 std::move(client),
364 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs)), 364 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs)),
365 &prefs, NULL, UIStringOverrider()); 365 &prefs, NULL, UIStringOverrider());
366 GURL url = service.GetVariationsServerURL(&prefs, std::string()); 366 GURL url = service.GetVariationsServerURL(&prefs, std::string());
367 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, 367 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url,
368 base::CompareCase::SENSITIVE)); 368 base::CompareCase::SENSITIVE));
369 EXPECT_FALSE(net::GetValueForKeyInQuery(url, "restrict", &value)); 369 EXPECT_FALSE(net::GetValueForKeyInQuery(url, "restrict", &value));
370 370
371 prefs.SetString(prefs::kVariationsRestrictParameter, "restricted"); 371 prefs.SetString(prefs::kVariationsRestrictParameter, "restricted");
372 url = service.GetVariationsServerURL(&prefs, std::string()); 372 url = service.GetVariationsServerURL(&prefs, std::string());
373 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, 373 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 407
408 TEST_F(VariationsServiceTest, RequestsInitiallyNotAllowed) { 408 TEST_F(VariationsServiceTest, RequestsInitiallyNotAllowed) {
409 TestingPrefServiceSimple prefs; 409 TestingPrefServiceSimple prefs;
410 VariationsService::RegisterPrefs(prefs.registry()); 410 VariationsService::RegisterPrefs(prefs.registry());
411 411
412 // Pass ownership to TestVariationsService, but keep a weak pointer to 412 // Pass ownership to TestVariationsService, but keep a weak pointer to
413 // manipulate it for this test. 413 // manipulate it for this test.
414 scoped_ptr<web_resource::TestRequestAllowedNotifier> test_notifier = 414 scoped_ptr<web_resource::TestRequestAllowedNotifier> test_notifier =
415 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs)); 415 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs));
416 web_resource::TestRequestAllowedNotifier* raw_notifier = test_notifier.get(); 416 web_resource::TestRequestAllowedNotifier* raw_notifier = test_notifier.get();
417 TestVariationsService test_service(test_notifier.Pass(), &prefs); 417 TestVariationsService test_service(std::move(test_notifier), &prefs);
418 418
419 // Force the notifier to initially disallow requests. 419 // Force the notifier to initially disallow requests.
420 raw_notifier->SetRequestsAllowedOverride(false); 420 raw_notifier->SetRequestsAllowedOverride(false);
421 test_service.StartRepeatedVariationsSeedFetch(); 421 test_service.StartRepeatedVariationsSeedFetch();
422 EXPECT_FALSE(test_service.fetch_attempted()); 422 EXPECT_FALSE(test_service.fetch_attempted());
423 423
424 raw_notifier->NotifyObserver(); 424 raw_notifier->NotifyObserver();
425 EXPECT_TRUE(test_service.fetch_attempted()); 425 EXPECT_TRUE(test_service.fetch_attempted());
426 } 426 }
427 427
428 TEST_F(VariationsServiceTest, RequestsInitiallyAllowed) { 428 TEST_F(VariationsServiceTest, RequestsInitiallyAllowed) {
429 TestingPrefServiceSimple prefs; 429 TestingPrefServiceSimple prefs;
430 VariationsService::RegisterPrefs(prefs.registry()); 430 VariationsService::RegisterPrefs(prefs.registry());
431 431
432 // Pass ownership to TestVariationsService, but keep a weak pointer to 432 // Pass ownership to TestVariationsService, but keep a weak pointer to
433 // manipulate it for this test. 433 // manipulate it for this test.
434 scoped_ptr<web_resource::TestRequestAllowedNotifier> test_notifier = 434 scoped_ptr<web_resource::TestRequestAllowedNotifier> test_notifier =
435 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs)); 435 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs));
436 web_resource::TestRequestAllowedNotifier* raw_notifier = test_notifier.get(); 436 web_resource::TestRequestAllowedNotifier* raw_notifier = test_notifier.get();
437 TestVariationsService test_service(test_notifier.Pass(), &prefs); 437 TestVariationsService test_service(std::move(test_notifier), &prefs);
438 438
439 raw_notifier->SetRequestsAllowedOverride(true); 439 raw_notifier->SetRequestsAllowedOverride(true);
440 test_service.StartRepeatedVariationsSeedFetch(); 440 test_service.StartRepeatedVariationsSeedFetch();
441 EXPECT_TRUE(test_service.fetch_attempted()); 441 EXPECT_TRUE(test_service.fetch_attempted());
442 } 442 }
443 443
444 TEST_F(VariationsServiceTest, SeedStoredWhenOKStatus) { 444 TEST_F(VariationsServiceTest, SeedStoredWhenOKStatus) {
445 TestingPrefServiceSimple prefs; 445 TestingPrefServiceSimple prefs;
446 VariationsService::RegisterPrefs(prefs.registry()); 446 VariationsService::RegisterPrefs(prefs.registry());
447 447
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 << test.pref_value_before << ", " << test.version << ", " 719 << test.pref_value_before << ", " << test.version << ", "
720 << test.latest_country_code; 720 << test.latest_country_code;
721 721
722 histogram_tester.ExpectUniqueSample( 722 histogram_tester.ExpectUniqueSample(
723 "Variations.LoadPermanentConsistencyCountryResult", 723 "Variations.LoadPermanentConsistencyCountryResult",
724 test.expected_result, 1); 724 test.expected_result, 1);
725 } 725 }
726 } 726 }
727 727
728 } // namespace variations 728 } // namespace variations
OLDNEW
« no previous file with comments | « components/variations/service/variations_service.cc ('k') | components/variations/variations_seed_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698