| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 16 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 18 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 19 #include "chrome/browser/sync/test/integration/passwords_helper.h" | 19 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
| 20 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 20 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| 21 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 21 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
| 22 #include "chrome/browser/sync/test/integration/sync_test.h" | 22 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 23 #include "components/bookmarks/browser/bookmark_node.h" | 23 #include "components/bookmarks/browser/bookmark_node.h" |
| 24 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 24 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
| 25 #include "components/policy/core/common/policy_map.h" | 25 #include "components/policy/core/common/policy_map.h" |
| 26 #include "components/policy/core/common/policy_types.h" | 26 #include "components/policy/core/common/policy_types.h" |
| 27 #include "components/sync/sessions/sync_session_snapshot.h" | 27 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
| 28 #include "policy/policy_constants.h" | 28 #include "policy/policy_constants.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "ui/base/layout.h" | 30 #include "ui/base/layout.h" |
| 31 | 31 |
| 32 using bookmarks::BookmarkNode; | 32 using bookmarks::BookmarkNode; |
| 33 using bookmarks_helper::AddFolder; | 33 using bookmarks_helper::AddFolder; |
| 34 using bookmarks_helper::AddURL; | 34 using bookmarks_helper::AddURL; |
| 35 using bookmarks_helper::AllModelsMatch; | 35 using bookmarks_helper::AllModelsMatch; |
| 36 using bookmarks_helper::AllModelsMatchVerifier; | 36 using bookmarks_helper::AllModelsMatchVerifier; |
| 37 using bookmarks_helper::AwaitAllModelsMatch; | 37 using bookmarks_helper::AwaitAllModelsMatch; |
| (...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 ASSERT_TRUE(AddURL(0, 3, IndexedURLTitle(4), GURL(IndexedURL(4))) != NULL); | 2014 ASSERT_TRUE(AddURL(0, 3, IndexedURLTitle(4), GURL(IndexedURL(4))) != NULL); |
| 2015 EXPECT_FALSE(AllModelsMatchVerifier()); | 2015 EXPECT_FALSE(AllModelsMatchVerifier()); |
| 2016 EXPECT_FALSE(AllModelsMatch()); | 2016 EXPECT_FALSE(AllModelsMatch()); |
| 2017 | 2017 |
| 2018 // Set the passphrase. Everything should resolve. | 2018 // Set the passphrase. Everything should resolve. |
| 2019 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1)))); | 2019 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1)))); |
| 2020 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); | 2020 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); |
| 2021 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1)))); | 2021 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1)))); |
| 2022 ASSERT_TRUE(AwaitQuiescence()); | 2022 ASSERT_TRUE(AwaitQuiescence()); |
| 2023 EXPECT_TRUE(AllModelsMatch()); | 2023 EXPECT_TRUE(AllModelsMatch()); |
| 2024 ASSERT_EQ(0, | 2024 ASSERT_EQ(0, GetClient(1)->GetLastCycleSnapshot().num_encryption_conflicts()); |
| 2025 GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts()); | |
| 2026 | 2025 |
| 2027 // Ensure everything is syncing normally by appending a final bookmark. | 2026 // Ensure everything is syncing normally by appending a final bookmark. |
| 2028 ASSERT_TRUE(AddURL(1, 5, IndexedURLTitle(5), GURL(IndexedURL(5))) != NULL); | 2027 ASSERT_TRUE(AddURL(1, 5, IndexedURLTitle(5), GURL(IndexedURL(5))) != NULL); |
| 2029 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 2028 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
| 2030 EXPECT_TRUE(AllModelsMatch()); | 2029 EXPECT_TRUE(AllModelsMatch()); |
| 2031 ASSERT_EQ(0, | 2030 ASSERT_EQ(0, GetClient(1)->GetLastCycleSnapshot().num_encryption_conflicts()); |
| 2032 GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts()); | |
| 2033 } | 2031 } |
| 2034 | 2032 |
| 2035 // Deliberately racy rearranging of bookmarks to test that our conflict resolver | 2033 // Deliberately racy rearranging of bookmarks to test that our conflict resolver |
| 2036 // code results in a consistent view across machines (no matter what the final | 2034 // code results in a consistent view across machines (no matter what the final |
| 2037 // order is). | 2035 // order is). |
| 2038 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, RacyPositionChanges) { | 2036 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, RacyPositionChanges) { |
| 2039 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 2037 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 2040 ASSERT_TRUE(AllModelsMatchVerifier()); | 2038 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 2041 | 2039 |
| 2042 // Add initial bookmarks. | 2040 // Add initial bookmarks. |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2342 // second client. | 2340 // second client. |
| 2343 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::BOOKMARKS)); | 2341 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::BOOKMARKS)); |
| 2344 const std::string url_title_2 = "another happy little url"; | 2342 const std::string url_title_2 = "another happy little url"; |
| 2345 const GURL url_2("https://example.com/second"); | 2343 const GURL url_2("https://example.com/second"); |
| 2346 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, url_title_2, url_2) != NULL); | 2344 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, url_title_2, url_2) != NULL); |
| 2347 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::BOOKMARKS)); | 2345 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::BOOKMARKS)); |
| 2348 ASSERT_TRUE(AwaitAllModelsMatch()); | 2346 ASSERT_TRUE(AwaitAllModelsMatch()); |
| 2349 ASSERT_EQ(initial_count + 2, CountAllBookmarks(0)); | 2347 ASSERT_EQ(initial_count + 2, CountAllBookmarks(0)); |
| 2350 ASSERT_EQ(initial_count + 2, CountAllBookmarks(1)); | 2348 ASSERT_EQ(initial_count + 2, CountAllBookmarks(1)); |
| 2351 } | 2349 } |
| OLD | NEW |