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

Side by Side Diff: chrome/browser/metrics/variations/variations_service_unittest.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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 | Annotate | Revision Log
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 "base/base64.h" 5 #include "base/base64.h"
6 #include "base/string_split.h" 6 #include "base/string_split.h"
7 #include "chrome/browser/metrics/proto/study.pb.h" 7 #include "chrome/browser/metrics/proto/study.pb.h"
8 #include "chrome/browser/metrics/variations/resource_request_allowed_notifier_te st_util.h" 8 #include "chrome/browser/metrics/variations/resource_request_allowed_notifier_te st_util.h"
9 #include "chrome/browser/metrics/variations/variations_service.h" 9 #include "chrome/browser/metrics/variations/variations_service.h"
10 #include "chrome/common/chrome_version_info.h" 10 #include "chrome/common/chrome_version_info.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 331
332 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expiry_test_cases); ++i) { 332 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expiry_test_cases); ++i) {
333 study.set_expiry_date(TimeToProtoTime(expiry_test_cases[i].expiry_date)); 333 study.set_expiry_date(TimeToProtoTime(expiry_test_cases[i].expiry_date));
334 const bool result = VariationsService::IsStudyExpired(study, now); 334 const bool result = VariationsService::IsStudyExpired(study, now);
335 EXPECT_EQ(expiry_test_cases[i].expected_result, result) 335 EXPECT_EQ(expiry_test_cases[i].expected_result, result)
336 << "Case " << i << " failed!"; 336 << "Case " << i << " failed!";
337 } 337 }
338 } 338 }
339 339
340 TEST(VariationsServiceTest, LoadSeed) { 340 TEST(VariationsServiceTest, LoadSeed) {
341 TestingPrefService pref_service; 341 TestingPrefServiceSimple pref_service;
342 342
343 VariationsService::RegisterPrefs(&pref_service); 343 VariationsService::RegisterPrefs(&pref_service);
344 344
345 // Store good seed data to test if loading from prefs works. 345 // Store good seed data to test if loading from prefs works.
346 TrialsSeed seed = CreateTestSeed(); 346 TrialsSeed seed = CreateTestSeed();
347 347
348 std::string serialized_seed; 348 std::string serialized_seed;
349 seed.SerializeToString(&serialized_seed); 349 seed.SerializeToString(&serialized_seed);
350 std::string base64_serialized_seed; 350 std::string base64_serialized_seed;
351 ASSERT_TRUE(base::Base64Encode(serialized_seed, &base64_serialized_seed)); 351 ASSERT_TRUE(base::Base64Encode(serialized_seed, &base64_serialized_seed));
(...skipping 19 matching lines...) Expand all
371 pref_service.SetString(prefs::kVariationsSeed, "this should fail"); 371 pref_service.SetString(prefs::kVariationsSeed, "this should fail");
372 EXPECT_FALSE( 372 EXPECT_FALSE(
373 pref_service.FindPreference(prefs::kVariationsSeed)->IsDefaultValue()); 373 pref_service.FindPreference(prefs::kVariationsSeed)->IsDefaultValue());
374 EXPECT_FALSE( 374 EXPECT_FALSE(
375 variations_service.LoadTrialsSeedFromPref(&pref_service, &loaded_seed)); 375 variations_service.LoadTrialsSeedFromPref(&pref_service, &loaded_seed));
376 EXPECT_TRUE( 376 EXPECT_TRUE(
377 pref_service.FindPreference(prefs::kVariationsSeed)->IsDefaultValue()); 377 pref_service.FindPreference(prefs::kVariationsSeed)->IsDefaultValue());
378 } 378 }
379 379
380 TEST(VariationsServiceTest, StoreSeed) { 380 TEST(VariationsServiceTest, StoreSeed) {
381 TestingPrefService pref_service; 381 TestingPrefServiceSimple pref_service;
382 382
383 VariationsService::RegisterPrefs(&pref_service); 383 VariationsService::RegisterPrefs(&pref_service);
384 const base::Time now = base::Time::Now(); 384 const base::Time now = base::Time::Now();
385 385
386 TrialsSeed seed = CreateTestSeed(); 386 TrialsSeed seed = CreateTestSeed();
387 387
388 TestVariationsService variations_service(new TestRequestAllowedNotifier); 388 TestVariationsService variations_service(new TestRequestAllowedNotifier);
389 std::string serialized_seed; 389 std::string serialized_seed;
390 seed.SerializeToString(&serialized_seed); 390 seed.SerializeToString(&serialized_seed);
391 EXPECT_TRUE( 391 EXPECT_TRUE(
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // manipulate it for this test. 512 // manipulate it for this test.
513 TestRequestAllowedNotifier* test_notifier = new TestRequestAllowedNotifier; 513 TestRequestAllowedNotifier* test_notifier = new TestRequestAllowedNotifier;
514 TestVariationsService test_service(test_notifier); 514 TestVariationsService test_service(test_notifier);
515 515
516 test_notifier->SetRequestsAllowedOverride(true); 516 test_notifier->SetRequestsAllowedOverride(true);
517 test_service.StartRepeatedVariationsSeedFetch(); 517 test_service.StartRepeatedVariationsSeedFetch();
518 EXPECT_TRUE(test_service.fetch_attempted()); 518 EXPECT_TRUE(test_service.fetch_attempted());
519 } 519 }
520 520
521 } // namespace chrome_variations 521 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « chrome/browser/metrics/variations/variations_service.cc ('k') | chrome/browser/net/http_server_properties_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698