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 // 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 <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
11 #include <stack> | 11 #include <stack> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
19 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
26 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 26 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
| 27 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" |
27 #include "chrome/browser/sync/glue/bookmark_change_processor.h" | 28 #include "chrome/browser/sync/glue/bookmark_change_processor.h" |
28 #include "chrome/browser/sync/glue/bookmark_model_associator.h" | 29 #include "chrome/browser/sync/glue/bookmark_model_associator.h" |
29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/test/base/testing_profile.h" | 31 #include "chrome/test/base/testing_profile.h" |
31 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 32 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
32 #include "components/bookmarks/browser/bookmark_model.h" | 33 #include "components/bookmarks/browser/bookmark_model.h" |
33 #include "components/bookmarks/test/bookmark_test_helpers.h" | 34 #include "components/bookmarks/test/bookmark_test_helpers.h" |
34 #include "components/sync_driver/data_type_error_handler.h" | 35 #include "components/sync_driver/data_type_error_handler.h" |
35 #include "components/sync_driver/data_type_error_handler_mock.h" | 36 #include "components/sync_driver/data_type_error_handler_mock.h" |
36 #include "content/public/test/test_browser_thread.h" | 37 #include "content/public/test/test_browser_thread.h" |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 } | 631 } |
631 | 632 |
632 void ExpectBrowserNodeMatching(syncer::BaseTransaction* trans, | 633 void ExpectBrowserNodeMatching(syncer::BaseTransaction* trans, |
633 int64 sync_id) { | 634 int64 sync_id) { |
634 EXPECT_TRUE(sync_id); | 635 EXPECT_TRUE(sync_id); |
635 const BookmarkNode* bnode = | 636 const BookmarkNode* bnode = |
636 model_associator_->GetChromeNodeFromSyncId(sync_id); | 637 model_associator_->GetChromeNodeFromSyncId(sync_id); |
637 ASSERT_TRUE(bnode); | 638 ASSERT_TRUE(bnode); |
638 | 639 |
639 ChromeBookmarkClient* client = | 640 ChromeBookmarkClient* client = |
640 BookmarkModelFactory::GetChromeBookmarkClientForProfile(&profile_); | 641 ChromeBookmarkClientFactory::GetForProfile(&profile_); |
641 ASSERT_TRUE(client); | 642 ASSERT_TRUE(client); |
642 ASSERT_FALSE(client->IsDescendantOfManagedNode(bnode)); | 643 ASSERT_FALSE(client->IsDescendantOfManagedNode(bnode)); |
643 | 644 |
644 int64 id = model_associator_->GetSyncIdFromChromeId(bnode->id()); | 645 int64 id = model_associator_->GetSyncIdFromChromeId(bnode->id()); |
645 EXPECT_EQ(id, sync_id); | 646 EXPECT_EQ(id, sync_id); |
646 ExpectSyncerNodeMatching(trans, bnode); | 647 ExpectSyncerNodeMatching(trans, bnode); |
647 } | 648 } |
648 | 649 |
649 void ExpectBrowserNodeUnknown(int64 sync_id) { | 650 void ExpectBrowserNodeUnknown(int64 sync_id) { |
650 EXPECT_FALSE(model_associator_->GetChromeNodeFromSyncId(sync_id)); | 651 EXPECT_FALSE(model_associator_->GetChromeNodeFromSyncId(sync_id)); |
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2011 model_->SetNodeMetaInfo(node, "node", "changednodevalue"); | 2012 model_->SetNodeMetaInfo(node, "node", "changednodevalue"); |
2012 model_->DeleteNodeMetaInfo(node, "other"); | 2013 model_->DeleteNodeMetaInfo(node, "other"); |
2013 model_->SetNodeMetaInfo(node, "newkey", "newkeyvalue"); | 2014 model_->SetNodeMetaInfo(node, "newkey", "newkeyvalue"); |
2014 ExpectModelMatch(); | 2015 ExpectModelMatch(); |
2015 } | 2016 } |
2016 | 2017 |
2017 void ProfileSyncServiceBookmarkTestWithData::GetTransactionVersions( | 2018 void ProfileSyncServiceBookmarkTestWithData::GetTransactionVersions( |
2018 const BookmarkNode* root, | 2019 const BookmarkNode* root, |
2019 BookmarkNodeVersionMap* node_versions) { | 2020 BookmarkNodeVersionMap* node_versions) { |
2020 ChromeBookmarkClient* client = | 2021 ChromeBookmarkClient* client = |
2021 BookmarkModelFactory::GetChromeBookmarkClientForProfile(&profile_); | 2022 ChromeBookmarkClientFactory::GetForProfile(&profile_); |
2022 ASSERT_TRUE(client); | 2023 ASSERT_TRUE(client); |
2023 | 2024 |
2024 node_versions->clear(); | 2025 node_versions->clear(); |
2025 std::queue<const BookmarkNode*> nodes; | 2026 std::queue<const BookmarkNode*> nodes; |
2026 nodes.push(root); | 2027 nodes.push(root); |
2027 while (!nodes.empty()) { | 2028 while (!nodes.empty()) { |
2028 const BookmarkNode* n = nodes.front(); | 2029 const BookmarkNode* n = nodes.front(); |
2029 nodes.pop(); | 2030 nodes.pop(); |
2030 | 2031 |
2031 int64 version = n->sync_transaction_version(); | 2032 int64 version = n->sync_transaction_version(); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2182 ExpectModelMatch(); | 2183 ExpectModelMatch(); |
2183 | 2184 |
2184 // Then simulate the add call arriving late. | 2185 // Then simulate the add call arriving late. |
2185 change_processor_->BookmarkNodeAdded(model_, model_->bookmark_bar_node(), 0); | 2186 change_processor_->BookmarkNodeAdded(model_, model_->bookmark_bar_node(), 0); |
2186 ExpectModelMatch(); | 2187 ExpectModelMatch(); |
2187 } | 2188 } |
2188 | 2189 |
2189 } // namespace | 2190 } // namespace |
2190 | 2191 |
2191 } // namespace browser_sync | 2192 } // namespace browser_sync |
OLD | NEW |