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/sync/profile_sync_service_preference_unittest.cc

Issue 183803026: Clean up InvalidationService test infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 9 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 | 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/json/json_string_value_serializer.h" 12 #include "base/json/json_string_value_serializer.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/prefs/scoped_user_pref_update.h" 15 #include "base/prefs/scoped_user_pref_update.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/string_piece.h" 17 #include "base/strings/string_piece.h"
18 #include "chrome/browser/invalidation/fake_invalidation_service.h"
18 #include "chrome/browser/invalidation/invalidation_service_factory.h" 19 #include "chrome/browser/invalidation/invalidation_service_factory.h"
19 #include "chrome/browser/prefs/pref_model_associator.h" 20 #include "chrome/browser/prefs/pref_model_associator.h"
20 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" 21 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
21 #include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" 22 #include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h"
22 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 23 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
23 #include "chrome/browser/signin/signin_manager.h" 24 #include "chrome/browser/signin/signin_manager.h"
24 #include "chrome/browser/signin/signin_manager_factory.h" 25 #include "chrome/browser/signin/signin_manager_factory.h"
25 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" 26 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
26 #include "chrome/browser/sync/glue/generic_change_processor.h" 27 #include "chrome/browser/sync/glue/generic_change_processor.h"
27 #include "chrome/browser/sync/glue/sync_backend_host.h" 28 #include "chrome/browser/sync/glue/sync_backend_host.h"
(...skipping 16 matching lines...) Expand all
44 #include "sync/internal_api/public/write_transaction.h" 45 #include "sync/internal_api/public/write_transaction.h"
45 #include "sync/protocol/preference_specifics.pb.h" 46 #include "sync/protocol/preference_specifics.pb.h"
46 #include "testing/gmock/include/gmock/gmock.h" 47 #include "testing/gmock/include/gmock/gmock.h"
47 #include "testing/gtest/include/gtest/gtest.h" 48 #include "testing/gtest/include/gtest/gtest.h"
48 49
49 using base::JSONReader; 50 using base::JSONReader;
50 using browser_sync::GenericChangeProcessor; 51 using browser_sync::GenericChangeProcessor;
51 using browser_sync::SharedChangeProcessor; 52 using browser_sync::SharedChangeProcessor;
52 using browser_sync::UIDataTypeController; 53 using browser_sync::UIDataTypeController;
53 using syncer::ChangeRecord; 54 using syncer::ChangeRecord;
54 using testing::_;
55 using testing::Invoke; 55 using testing::Invoke;
56 using testing::Return; 56 using testing::Return;
57 using testing::_;
57 58
58 typedef std::map<const std::string, const base::Value*> PreferenceValues; 59 typedef std::map<const std::string, const base::Value*> PreferenceValues;
59 60
60 ACTION_P(CreateAndSaveChangeProcessor, change_processor) { 61 ACTION_P(CreateAndSaveChangeProcessor, change_processor) {
61 syncer::UserShare* user_share = arg0->GetUserShare(); 62 syncer::UserShare* user_share = arg0->GetUserShare();
62 *change_processor = new GenericChangeProcessor(arg1, 63 *change_processor = new GenericChangeProcessor(arg1,
63 arg2, 64 arg2,
64 arg3, 65 arg3,
65 user_share); 66 user_share);
66 return *change_processor; 67 return *change_processor;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 not_synced_preference_default_value_("default"), 124 not_synced_preference_default_value_("default"),
124 non_default_charset_value_("foo") {} 125 non_default_charset_value_("foo") {}
125 126
126 virtual void SetUp() { 127 virtual void SetUp() {
127 AbstractProfileSyncServiceTest::SetUp(); 128 AbstractProfileSyncServiceTest::SetUp();
128 TestingProfile::Builder builder; 129 TestingProfile::Builder builder;
129 builder.AddTestingFactory( 130 builder.AddTestingFactory(
130 ProfileOAuth2TokenServiceFactory::GetInstance(), 131 ProfileOAuth2TokenServiceFactory::GetInstance(),
131 FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService); 132 FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService);
132 profile_ = builder.Build().Pass(); 133 profile_ = builder.Build().Pass();
133 invalidation::InvalidationServiceFactory::GetInstance()-> 134 invalidation::InvalidationServiceFactory::GetInstance()->SetTestingFactory(
134 SetBuildOnlyFakeInvalidatorsForTest(true); 135 profile_.get(), invalidation::FakeInvalidationService::Build);
135 prefs_ = profile_->GetTestingPrefService(); 136 prefs_ = profile_->GetTestingPrefService();
136 137
137 prefs_->registry()->RegisterStringPref( 138 prefs_->registry()->RegisterStringPref(
138 not_synced_preference_name_.c_str(), 139 not_synced_preference_name_.c_str(),
139 not_synced_preference_default_value_, 140 not_synced_preference_default_value_,
140 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 141 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
141 } 142 }
142 143
143 virtual void TearDown() { 144 virtual void TearDown() {
144 profile_.reset(); 145 profile_.reset();
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 EXPECT_FALSE(pref->IsDefaultValue()); 898 EXPECT_FALSE(pref->IsDefaultValue());
898 // There should be no synced value. 899 // There should be no synced value.
899 EXPECT_TRUE(GetSyncedValue(prefs::kHomePage) == NULL); 900 EXPECT_TRUE(GetSyncedValue(prefs::kHomePage) == NULL);
900 // Switch kHomePage back to unmanaged. 901 // Switch kHomePage back to unmanaged.
901 profile_->GetTestingPrefService()->RemoveManagedPref(prefs::kHomePage); 902 profile_->GetTestingPrefService()->RemoveManagedPref(prefs::kHomePage);
902 // The original value should be picked up. 903 // The original value should be picked up.
903 EXPECT_TRUE(pref->IsDefaultValue()); 904 EXPECT_TRUE(pref->IsDefaultValue());
904 // There should still be no synced value. 905 // There should still be no synced value.
905 EXPECT_TRUE(GetSyncedValue(prefs::kHomePage) == NULL); 906 EXPECT_TRUE(GetSyncedValue(prefs::kHomePage) == NULL);
906 } 907 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698