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

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

Issue 7453014: [Sync] Refactor sync datatype error handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and fix final unit test <3 c++ Created 9 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 | Annotate | Revision Log
OLDNEW
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 // TODO(akalin): This file is basically just a unit test for 5 // TODO(akalin): This file is basically just a unit test for
6 // BookmarkChangeProcessor. Write unit tests for 6 // BookmarkChangeProcessor. Write unit tests for
7 // BookmarkModelAssociator separately. 7 // BookmarkModelAssociator separately.
8 8
9 #include <stack> 9 #include <stack>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop.h" 16 #include "base/message_loop.h"
17 #include "base/string16.h" 17 #include "base/string16.h"
18 #include "base/string_number_conversions.h" 18 #include "base/string_number_conversions.h"
19 #include "base/string_util.h" 19 #include "base/string_util.h"
20 #include "base/tracked.h" 20 #include "base/tracked.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "chrome/browser/bookmarks/bookmark_model.h" 22 #include "chrome/browser/bookmarks/bookmark_model.h"
23 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" 23 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
24 #include "chrome/browser/sync/api/sync_error.h"
24 #include "chrome/browser/sync/engine/syncapi.h" 25 #include "chrome/browser/sync/engine/syncapi.h"
25 #include "chrome/browser/sync/glue/bookmark_change_processor.h" 26 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
26 #include "chrome/browser/sync/glue/bookmark_model_associator.h" 27 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
27 #include "chrome/browser/sync/syncable/directory_manager.h" 28 #include "chrome/browser/sync/syncable/directory_manager.h"
28 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
29 #include "chrome/test/sync/engine/test_id_factory.h" 30 #include "chrome/test/sync/engine/test_id_factory.h"
30 #include "chrome/test/sync/engine/test_user_share.h" 31 #include "chrome/test/sync/engine/test_user_share.h"
31 #include "chrome/test/testing_profile.h" 32 #include "chrome/test/testing_profile.h"
32 #include "content/browser/browser_thread.h" 33 #include "content/browser/browser_thread.h"
33 #include "testing/gmock/include/gmock/gmock.h" 34 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 model_->ClearStore(); 319 model_->ClearStore();
319 message_loop_.RunAllPending(); 320 message_loop_.RunAllPending();
320 } 321 }
321 322
322 void StartSync() { 323 void StartSync() {
323 // Set up model associator. 324 // Set up model associator.
324 model_associator_.reset(new TestBookmarkModelAssociator( 325 model_associator_.reset(new TestBookmarkModelAssociator(
325 profile_.GetBookmarkModel(), 326 profile_.GetBookmarkModel(),
326 test_user_share_.user_share(), 327 test_user_share_.user_share(),
327 &mock_unrecoverable_error_handler_)); 328 &mock_unrecoverable_error_handler_));
328 EXPECT_TRUE(model_associator_->AssociateModels()); 329 SyncError error;
330 EXPECT_TRUE(model_associator_->AssociateModels(&error));
329 MessageLoop::current()->RunAllPending(); 331 MessageLoop::current()->RunAllPending();
330 332
331 // Set up change processor. 333 // Set up change processor.
332 change_processor_.reset( 334 change_processor_.reset(
333 new BookmarkChangeProcessor(model_associator_.get(), 335 new BookmarkChangeProcessor(model_associator_.get(),
334 &mock_unrecoverable_error_handler_)); 336 &mock_unrecoverable_error_handler_));
335 change_processor_->Start(&profile_, test_user_share_.user_share()); 337 change_processor_->Start(&profile_, test_user_share_.user_share());
336 } 338 }
337 339
338 void StopSync() { 340 void StopSync() {
339 change_processor_->Stop(); 341 change_processor_->Stop();
340 change_processor_.reset(); 342 change_processor_.reset();
341 343 SyncError error;
342 EXPECT_TRUE(model_associator_->DisassociateModels()); 344 EXPECT_TRUE(model_associator_->DisassociateModels(&error));
343 model_associator_.reset(); 345 model_associator_.reset();
344 346
345 message_loop_.RunAllPending(); 347 message_loop_.RunAllPending();
346 348
347 // TODO(akalin): Actually close the database and flush it to disk 349 // TODO(akalin): Actually close the database and flush it to disk
348 // (and make StartSync reload from disk). This would require 350 // (and make StartSync reload from disk). This would require
349 // refactoring TestUserShare. 351 // refactoring TestUserShare.
350 } 352 }
351 353
352 void UnloadBookmarkModel() { 354 void UnloadBookmarkModel() {
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 // Make sure we're back in sync. In real life, the user would need 1431 // Make sure we're back in sync. In real life, the user would need
1430 // to reauthenticate before this happens, but in the test, authentication 1432 // to reauthenticate before this happens, but in the test, authentication
1431 // is sidestepped. 1433 // is sidestepped.
1432 ExpectBookmarkModelMatchesTestData(); 1434 ExpectBookmarkModelMatchesTestData();
1433 ExpectModelMatch(); 1435 ExpectModelMatch();
1434 } 1436 }
1435 1437
1436 } // namespace 1438 } // namespace
1437 1439
1438 } // namespace browser_sync 1440 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/sync/profile_sync_service_startup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698