| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/net/gaia/token_service.h" | 9 #include "chrome/browser/net/gaia/token_service.h" |
| 10 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" | 10 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 EXPECT_CALL(factory_, CreateBookmarkSyncComponents(_, _)).Times(0); | 148 EXPECT_CALL(factory_, CreateBookmarkSyncComponents(_, _)).Times(0); |
| 149 service_->RegisterDataTypeController( | 149 service_->RegisterDataTypeController( |
| 150 new BookmarkDataTypeController(&factory_, | 150 new BookmarkDataTypeController(&factory_, |
| 151 profile_.get(), | 151 profile_.get(), |
| 152 service_.get())); | 152 service_.get())); |
| 153 | 153 |
| 154 service_->Initialize(); | 154 service_->Initialize(); |
| 155 service_.reset(); | 155 service_.reset(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { |
| 159 service_.reset(new TestProfileSyncService(&factory_, |
| 160 profile_.get(), |
| 161 "test", true, NULL)); |
| 162 // Register the bookmark data type. |
| 163 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). |
| 164 WillRepeatedly(ReturnNewDataTypeManager()); |
| 165 |
| 166 profile_->GetTokenService()->IssueAuthTokenForTest( |
| 167 GaiaConstants::kSyncService, "token"); |
| 168 |
| 169 service_->Initialize(); |
| 170 EXPECT_TRUE(service_->sync_initialized()); |
| 171 EXPECT_TRUE(service_->GetBackendForTest() != NULL); |
| 172 EXPECT_FALSE(profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
| 173 |
| 174 service_->StopAndSuppress(); |
| 175 EXPECT_FALSE(service_->sync_initialized()); |
| 176 EXPECT_TRUE(profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
| 177 |
| 178 service_->UnsuppressAndStart(); |
| 179 EXPECT_TRUE(service_->sync_initialized()); |
| 180 EXPECT_FALSE(profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
| 181 } |
| 182 |
| 158 TEST_F(ProfileSyncServiceTest, JsControllerHandlersBasic) { | 183 TEST_F(ProfileSyncServiceTest, JsControllerHandlersBasic) { |
| 159 StartSyncService(); | 184 StartSyncService(); |
| 160 EXPECT_TRUE(service_->sync_initialized()); | 185 EXPECT_TRUE(service_->sync_initialized()); |
| 161 EXPECT_TRUE(service_->GetBackendForTest() != NULL); | 186 EXPECT_TRUE(service_->GetBackendForTest() != NULL); |
| 162 | 187 |
| 163 JsController* js_controller = service_->GetJsController(); | 188 JsController* js_controller = service_->GetJsController(); |
| 164 StrictMock<MockJsEventHandler> event_handler; | 189 StrictMock<MockJsEventHandler> event_handler; |
| 165 js_controller->AddJsEventHandler(&event_handler); | 190 js_controller->AddJsEventHandler(&event_handler); |
| 166 js_controller->RemoveJsEventHandler(&event_handler); | 191 js_controller->RemoveJsEventHandler(&event_handler); |
| 167 } | 192 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // This will still exist, but the text should have changed. | 297 // This will still exist, but the text should have changed. |
| 273 ASSERT_TRUE(file_util::PathExists(sync_file2)); | 298 ASSERT_TRUE(file_util::PathExists(sync_file2)); |
| 274 std::string file2text; | 299 std::string file2text; |
| 275 ASSERT_TRUE(file_util::ReadFileToString(sync_file2, &file2text)); | 300 ASSERT_TRUE(file_util::ReadFileToString(sync_file2, &file2text)); |
| 276 ASSERT_NE(file2text.compare(nonsense2), 0); | 301 ASSERT_NE(file2text.compare(nonsense2), 0); |
| 277 } | 302 } |
| 278 | 303 |
| 279 } // namespace | 304 } // namespace |
| 280 | 305 |
| 281 } // namespace browser_sync | 306 } // namespace browser_sync |
| OLD | NEW |