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

Side by Side Diff: chrome/browser/sync/profile_sync_service_startup_unittest.cc

Issue 2905003: Implement support for disabling sync through configuration management. (Closed)
Patch Set: Fix PrefsControllerTest on MAC. Created 10 years, 5 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "chrome/browser/chrome_thread.h" 9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/sync/glue/data_type_manager.h" 10 #include "chrome/browser/sync/glue/data_type_manager.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 EXPECT_CALL(*data_type_manager, Configure(_)).Times(1); 112 EXPECT_CALL(*data_type_manager, Configure(_)).Times(1);
113 EXPECT_CALL(*data_type_manager, state()). 113 EXPECT_CALL(*data_type_manager, state()).
114 WillOnce(Return(DataTypeManager::CONFIGURED)); 114 WillOnce(Return(DataTypeManager::CONFIGURED));
115 EXPECT_CALL(*data_type_manager, Stop()).Times(1); 115 EXPECT_CALL(*data_type_manager, Stop()).Times(1);
116 116
117 EXPECT_CALL(observer_, OnStateChanged()).Times(3); 117 EXPECT_CALL(observer_, OnStateChanged()).Times(3);
118 118
119 service_->Initialize(); 119 service_->Initialize();
120 } 120 }
121 121
122 TEST_F(ProfileSyncServiceStartupTest, SKIP_MACOSX(ManagedStartup)) {
123 // Disable sync through policy.
124 profile_.GetPrefs()->SetBoolean(prefs::kSyncManaged, true);
125
126 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)).Times(0);
127 EXPECT_CALL(observer_, OnStateChanged()).Times(1);
128
129 // Service should not be started by Initialize() since it's managed.
130 service_->Initialize();
131 }
132
133 TEST_F(ProfileSyncServiceStartupTest, SKIP_MACOSX(SwitchManaged)) {
134 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
135 EXPECT_CALL(*data_type_manager, Configure(_)).Times(1);
136 EXPECT_CALL(observer_, OnStateChanged()).Times(3);
137
138 service_->Initialize();
139
140 // The service should stop when switching to managed mode.
141 Mock::VerifyAndClearExpectations(data_type_manager);
142 EXPECT_CALL(*data_type_manager, state()).
143 WillOnce(Return(DataTypeManager::CONFIGURED));
144 EXPECT_CALL(*data_type_manager, Stop()).Times(1);
145 EXPECT_CALL(observer_, OnStateChanged()).Times(2);
146 profile_.GetPrefs()->SetBoolean(prefs::kSyncManaged, true);
147
148 // When switching back to unmanaged, the state should change, but the service
149 // should not start up automatically (kSyncSetupCompleted will be false).
150 Mock::VerifyAndClearExpectations(data_type_manager);
151 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)).Times(0);
152 EXPECT_CALL(observer_, OnStateChanged()).Times(1);
153 profile_.GetPrefs()->ClearPref(prefs::kSyncManaged);
154 }
155
122 TEST_F(ProfileSyncServiceStartupTest, SKIP_MACOSX(StartFailure)) { 156 TEST_F(ProfileSyncServiceStartupTest, SKIP_MACOSX(StartFailure)) {
123 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); 157 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
124 DataTypeManager::ConfigureResult result = 158 DataTypeManager::ConfigureResult result =
125 DataTypeManager::ASSOCIATION_FAILED; 159 DataTypeManager::ASSOCIATION_FAILED;
126 EXPECT_CALL(*data_type_manager, Configure(_)). 160 EXPECT_CALL(*data_type_manager, Configure(_)).
127 WillOnce(DoAll(Notify(NotificationType::SYNC_CONFIGURE_START), 161 WillOnce(DoAll(Notify(NotificationType::SYNC_CONFIGURE_START),
128 NotifyWithResult(NotificationType::SYNC_CONFIGURE_DONE, 162 NotifyWithResult(NotificationType::SYNC_CONFIGURE_DONE,
129 &result))); 163 &result)));
130 EXPECT_CALL(*data_type_manager, Stop()).Times(1); 164 EXPECT_CALL(*data_type_manager, Stop()).Times(1);
131 EXPECT_CALL(*data_type_manager, state()). 165 EXPECT_CALL(*data_type_manager, state()).
(...skipping 27 matching lines...) Expand all
159 EXPECT_CALL(*data_type_manager, state()). 193 EXPECT_CALL(*data_type_manager, state()).
160 WillOnce(Return(DataTypeManager::CONFIGURED)); 194 WillOnce(Return(DataTypeManager::CONFIGURED));
161 EXPECT_CALL(*data_type_manager, Stop()).Times(1); 195 EXPECT_CALL(*data_type_manager, Stop()).Times(1);
162 EXPECT_CALL(observer_, OnStateChanged()).Times(4); 196 EXPECT_CALL(observer_, OnStateChanged()).Times(4);
163 197
164 profile_.GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); 198 profile_.GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
165 // Will start sync even though setup hasn't been completed (since 199 // Will start sync even though setup hasn't been completed (since
166 // setup is bypassed when bootstrapping is enabled). 200 // setup is bypassed when bootstrapping is enabled).
167 service_->Initialize(); 201 service_->Initialize();
168 } 202 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_observer.h ('k') | chrome/browser/sync/sync_ui_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698