| OLD | NEW |
| 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 <stack> | 5 #include <stack> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" | 24 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" |
| 25 #include "chrome/browser/sync/glue/bookmark_model_associator.h" | 25 #include "chrome/browser/sync/glue/bookmark_model_associator.h" |
| 26 #include "chrome/browser/sync/glue/data_type_controller.h" | 26 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 27 #include "chrome/browser/sync/glue/model_associator.h" | 27 #include "chrome/browser/sync/glue/model_associator.h" |
| 28 #include "chrome/browser/sync/glue/sync_backend_host.h" | 28 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 29 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" | 29 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" |
| 30 #include "chrome/browser/sync/profile_sync_factory.h" | 30 #include "chrome/browser/sync/profile_sync_factory.h" |
| 31 #include "chrome/browser/sync/profile_sync_factory_mock.h" | 31 #include "chrome/browser/sync/profile_sync_factory_mock.h" |
| 32 #include "chrome/browser/sync/test_profile_sync_service.h" | 32 #include "chrome/browser/sync/test_profile_sync_service.h" |
| 33 #include "chrome/browser/sync/profile_sync_test_util.h" | 33 #include "chrome/browser/sync/profile_sync_test_util.h" |
| 34 #include "chrome/common/chrome_switches.h" | |
| 35 #include "chrome/common/net/gaia/gaia_constants.h" | 34 #include "chrome/common/net/gaia/gaia_constants.h" |
| 36 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 37 #include "chrome/test/testing_profile.h" | 36 #include "chrome/test/testing_profile.h" |
| 38 #include "chrome/test/testing_pref_service.h" | 37 #include "chrome/test/testing_pref_service.h" |
| 39 #include "testing/gmock/include/gmock/gmock.h" | 38 #include "testing/gmock/include/gmock/gmock.h" |
| 40 | 39 |
| 41 using std::vector; | 40 using std::vector; |
| 42 using browser_sync::AssociatorInterface; | 41 using browser_sync::AssociatorInterface; |
| 43 using browser_sync::BookmarkChangeProcessor; | 42 using browser_sync::BookmarkChangeProcessor; |
| 44 using browser_sync::BookmarkModelAssociator; | 43 using browser_sync::BookmarkModelAssociator; |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 | 639 |
| 641 sync_api::WriteTransaction trans(backend()->GetUserShareHandle()); | 640 sync_api::WriteTransaction trans(backend()->GetUserShareHandle()); |
| 642 | 641 |
| 643 // Stress the immediate children of other_node because that's where | 642 // Stress the immediate children of other_node because that's where |
| 644 // ApplyModelChanges puts a temporary foster parent node. | 643 // ApplyModelChanges puts a temporary foster parent node. |
| 645 std::string url("http://dev.chromium.org/"); | 644 std::string url("http://dev.chromium.org/"); |
| 646 FakeServerChange adds(&trans); | 645 FakeServerChange adds(&trans); |
| 647 int64 f0 = other_bookmarks_id(); // + other_node | 646 int64 f0 = other_bookmarks_id(); // + other_node |
| 648 int64 f1 = adds.AddFolder(L"f1", f0, 0); // + f1 | 647 int64 f1 = adds.AddFolder(L"f1", f0, 0); // + f1 |
| 649 int64 f2 = adds.AddFolder(L"f2", f1, 0); // + f2 | 648 int64 f2 = adds.AddFolder(L"f2", f1, 0); // + f2 |
| 650 int64 u3 = adds.AddURL( L"u3", url, f2, 0); // + u3 | 649 int64 u3 = adds.AddURL( L"u3", url, f2, 0); // + u3 NOLINT |
| 651 int64 u4 = adds.AddURL( L"u4", url, f2, u3); // + u4 | 650 int64 u4 = adds.AddURL( L"u4", url, f2, u3); // + u4 NOLINT |
| 652 int64 u5 = adds.AddURL( L"u5", url, f1, f2); // + u5 | 651 int64 u5 = adds.AddURL( L"u5", url, f1, f2); // + u5 NOLINT |
| 653 int64 f6 = adds.AddFolder(L"f6", f1, u5); // + f6 | 652 int64 f6 = adds.AddFolder(L"f6", f1, u5); // + f6 |
| 654 int64 u7 = adds.AddURL( L"u7", url, f0, f1); // + u7 | 653 int64 u7 = adds.AddURL( L"u7", url, f0, f1); // + u7 NOLINT |
| 655 | 654 |
| 656 vector<sync_api::SyncManager::ChangeRecord>::const_iterator it; | 655 vector<sync_api::SyncManager::ChangeRecord>::const_iterator it; |
| 657 // The bookmark model shouldn't yet have seen any of the nodes of |adds|. | 656 // The bookmark model shouldn't yet have seen any of the nodes of |adds|. |
| 658 for (it = adds.changes().begin(); it != adds.changes().end(); ++it) | 657 for (it = adds.changes().begin(); it != adds.changes().end(); ++it) |
| 659 ExpectBrowserNodeUnknown(it->id); | 658 ExpectBrowserNodeUnknown(it->id); |
| 660 | 659 |
| 661 adds.ApplyPendingChanges(change_processor()); | 660 adds.ApplyPendingChanges(change_processor()); |
| 662 | 661 |
| 663 // Make sure the bookmark model received all of the nodes in |adds|. | 662 // Make sure the bookmark model received all of the nodes in |adds|. |
| 664 for (it = adds.changes().begin(); it != adds.changes().end(); ++it) | 663 for (it = adds.changes().begin(); it != adds.changes().end(); ++it) |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 WillOnce(Return(ProfileSyncFactory::SyncComponents( | 1377 WillOnce(Return(ProfileSyncFactory::SyncComponents( |
| 1379 model_associator_, change_processor_))); | 1378 model_associator_, change_processor_))); |
| 1380 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). | 1379 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). |
| 1381 WillOnce(ReturnNewDataTypeManager()); | 1380 WillOnce(ReturnNewDataTypeManager()); |
| 1382 | 1381 |
| 1383 service_->RegisterDataTypeController( | 1382 service_->RegisterDataTypeController( |
| 1384 new browser_sync::BookmarkDataTypeController(&factory_, | 1383 new browser_sync::BookmarkDataTypeController(&factory_, |
| 1385 profile_.get(), | 1384 profile_.get(), |
| 1386 service_.get())); | 1385 service_.get())); |
| 1387 | 1386 |
| 1388 service_->Initialize(); // will call disableForUser because sync setup | 1387 service_->Initialize(); // will call disableForUser because sync setup |
| 1389 // hasn't been completed. | 1388 // hasn't been completed. |
| 1390 } | 1389 } |
| 1391 | 1390 |
| 1392 ASSERT_FALSE(service_->backend()); | 1391 ASSERT_FALSE(service_->backend()); |
| 1393 ASSERT_FALSE(service_->HasSyncSetupCompleted()); | 1392 ASSERT_FALSE(service_->HasSyncSetupCompleted()); |
| 1394 | 1393 |
| 1395 // Create some tokens in the token service; the service will startup when | 1394 // Create some tokens in the token service; the service will startup when |
| 1396 // it is notified that tokens are available. | 1395 // it is notified that tokens are available. |
| 1397 profile_->GetTokenService()->IssueAuthTokenForTest( | 1396 profile_->GetTokenService()->IssueAuthTokenForTest( |
| 1398 GaiaConstants::kSyncService, "sync_token"); | 1397 GaiaConstants::kSyncService, "sync_token"); |
| 1399 | 1398 |
| 1400 syncable::ModelTypeSet set; | 1399 syncable::ModelTypeSet set; |
| 1401 set.insert(syncable::BOOKMARKS); | 1400 set.insert(syncable::BOOKMARKS); |
| 1402 service_->OnUserChoseDatatypes(false, set); | 1401 service_->OnUserChoseDatatypes(false, set); |
| 1403 | 1402 |
| 1404 MessageLoop::current()->RunAllPending(); | 1403 MessageLoop::current()->RunAllPending(); |
| 1405 | 1404 |
| 1406 // Stop the service so we can read the new Sync Data files that were created. | 1405 // Stop the service so we can read the new Sync Data files that were created. |
| 1407 service_.reset(); | 1406 service_.reset(); |
| 1408 | 1407 |
| 1409 // This file should have been deleted when the whole directory was nuked. | 1408 // This file should have been deleted when the whole directory was nuked. |
| 1410 ASSERT_FALSE(file_util::PathExists(sync_file3)); | 1409 ASSERT_FALSE(file_util::PathExists(sync_file3)); |
| 1411 ASSERT_FALSE(file_util::PathExists(sync_file1)); | 1410 ASSERT_FALSE(file_util::PathExists(sync_file1)); |
| 1412 | 1411 |
| 1413 // This will still exist, but the text should have changed. | 1412 // This will still exist, but the text should have changed. |
| 1414 ASSERT_TRUE(file_util::PathExists(sync_file2)); | 1413 ASSERT_TRUE(file_util::PathExists(sync_file2)); |
| 1415 std::string file2text; | 1414 std::string file2text; |
| 1416 file_util::ReadFileToString(sync_file2, &file2text); | 1415 file_util::ReadFileToString(sync_file2, &file2text); |
| 1417 ASSERT_FALSE(file2text.compare(nonsense2) == 0); | 1416 ASSERT_FALSE(file2text.compare(nonsense2) == 0); |
| 1418 } | 1417 } |
| OLD | NEW |