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 <stack> | 9 #include <stack> |
10 #include <vector> | 10 #include <vector> |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "chrome/test/base/testing_profile.h" | 31 #include "chrome/test/base/testing_profile.h" |
32 #include "content/public/test/test_browser_thread.h" | 32 #include "content/public/test/test_browser_thread.h" |
33 #include "sync/api/sync_error.h" | 33 #include "sync/api/sync_error.h" |
34 #include "sync/internal_api/public/change_record.h" | 34 #include "sync/internal_api/public/change_record.h" |
35 #include "sync/internal_api/public/read_node.h" | 35 #include "sync/internal_api/public/read_node.h" |
36 #include "sync/internal_api/public/read_transaction.h" | 36 #include "sync/internal_api/public/read_transaction.h" |
37 #include "sync/internal_api/public/test/test_user_share.h" | 37 #include "sync/internal_api/public/test/test_user_share.h" |
38 #include "sync/internal_api/public/write_node.h" | 38 #include "sync/internal_api/public/write_node.h" |
39 #include "sync/internal_api/public/write_transaction.h" | 39 #include "sync/internal_api/public/write_transaction.h" |
40 #include "sync/syncable/mutable_entry.h" // TODO(tim): Remove. Bug 131130. | 40 #include "sync/syncable/mutable_entry.h" // TODO(tim): Remove. Bug 131130. |
41 #include "sync/test/engine/test_id_factory.h" | |
42 #include "testing/gmock/include/gmock/gmock.h" | 41 #include "testing/gmock/include/gmock/gmock.h" |
43 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
44 | 43 |
45 namespace browser_sync { | 44 namespace browser_sync { |
46 | 45 |
47 using content::BrowserThread; | 46 using content::BrowserThread; |
48 using syncer::BaseNode; | 47 using syncer::BaseNode; |
49 using testing::_; | 48 using testing::_; |
50 using testing::InvokeWithoutArgs; | 49 using testing::InvokeWithoutArgs; |
51 using testing::Mock; | 50 using testing::Mock; |
(...skipping 28 matching lines...) Expand all Loading... |
80 syncer::ReadNode uber_root(&trans); | 79 syncer::ReadNode uber_root(&trans); |
81 uber_root.InitByRootLookup(); | 80 uber_root.InitByRootLookup(); |
82 | 81 |
83 syncer::ReadNode root(&trans); | 82 syncer::ReadNode root(&trans); |
84 root_exists = root.InitByTagLookup( | 83 root_exists = root.InitByTagLookup( |
85 ProfileSyncServiceTestHelper::GetTagForType(type)) == | 84 ProfileSyncServiceTestHelper::GetTagForType(type)) == |
86 BaseNode::INIT_OK; | 85 BaseNode::INIT_OK; |
87 } | 86 } |
88 | 87 |
89 if (!root_exists) { | 88 if (!root_exists) { |
90 bool created = ProfileSyncServiceTestHelper::CreateRoot( | 89 if (!ProfileSyncServiceTestHelper::CreateRoot(type, user_share_)) |
91 type, | |
92 user_share_, | |
93 &id_factory_); | |
94 if (!created) | |
95 return false; | 90 return false; |
96 } | 91 } |
97 | 92 |
98 syncer::WriteTransaction trans(FROM_HERE, user_share_); | 93 syncer::WriteTransaction trans(FROM_HERE, user_share_); |
99 syncer::ReadNode root(&trans); | 94 syncer::ReadNode root(&trans); |
100 EXPECT_EQ(BaseNode::INIT_OK, root.InitByTagLookup( | 95 EXPECT_EQ(BaseNode::INIT_OK, root.InitByTagLookup( |
101 ProfileSyncServiceTestHelper::GetTagForType(type))); | 96 ProfileSyncServiceTestHelper::GetTagForType(type))); |
102 | 97 |
103 // First, try to find a node with the title among the root's children. | 98 // First, try to find a node with the title among the root's children. |
104 // This will be the case if we are testing model persistence, and | 99 // This will be the case if we are testing model persistence, and |
(...skipping 24 matching lines...) Expand all Loading... |
129 node.GetMutableEntryForTest()->Put( | 124 node.GetMutableEntryForTest()->Put( |
130 syncer::syncable::UNIQUE_SERVER_TAG, tag); | 125 syncer::syncable::UNIQUE_SERVER_TAG, tag); |
131 node.SetTitle(UTF8ToWide(tag_str)); | 126 node.SetTitle(UTF8ToWide(tag_str)); |
132 node.SetExternalId(0); | 127 node.SetExternalId(0); |
133 *sync_id = node.GetId(); | 128 *sync_id = node.GetId(); |
134 return true; | 129 return true; |
135 } | 130 } |
136 | 131 |
137 private: | 132 private: |
138 syncer::UserShare* user_share_; | 133 syncer::UserShare* user_share_; |
139 syncer::TestIdFactory id_factory_; | |
140 }; | 134 }; |
141 | 135 |
142 namespace { | 136 namespace { |
143 | 137 |
144 // FakeServerChange constructs a list of syncer::ChangeRecords while modifying | 138 // FakeServerChange constructs a list of syncer::ChangeRecords while modifying |
145 // the sync model, and can pass the ChangeRecord list to a | 139 // the sync model, and can pass the ChangeRecord list to a |
146 // syncer::SyncObserver (i.e., the ProfileSyncService) to test the client | 140 // syncer::SyncObserver (i.e., the ProfileSyncService) to test the client |
147 // change-application behavior. | 141 // change-application behavior. |
148 // Tests using FakeServerChange should be careful to avoid back-references, | 142 // Tests using FakeServerChange should be careful to avoid back-references, |
149 // since FakeServerChange will send the edits in the order specified. | 143 // since FakeServerChange will send the edits in the order specified. |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 EXPECT_EQ(1, observer.get_started()); | 1492 EXPECT_EQ(1, observer.get_started()); |
1499 EXPECT_EQ(0, observer.get_completed_count_at_started()); | 1493 EXPECT_EQ(0, observer.get_completed_count_at_started()); |
1500 EXPECT_EQ(1, observer.get_completed()); | 1494 EXPECT_EQ(1, observer.get_completed()); |
1501 | 1495 |
1502 model_->RemoveObserver(&observer); | 1496 model_->RemoveObserver(&observer); |
1503 } | 1497 } |
1504 | 1498 |
1505 } // namespace | 1499 } // namespace |
1506 | 1500 |
1507 } // namespace browser_sync | 1501 } // namespace browser_sync |
OLD | NEW |