OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/bookmarks/browser/bookmark_model.h" | 5 #include "components/bookmarks/browser/bookmark_model.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 EXPECT_EQ(index2_, index2); | 235 EXPECT_EQ(index2_, index2); |
236 } | 236 } |
237 | 237 |
238 private: | 238 private: |
239 const BookmarkNode* node1_; | 239 const BookmarkNode* node1_; |
240 const BookmarkNode* node2_; | 240 const BookmarkNode* node2_; |
241 int index1_; | 241 int index1_; |
242 int index2_; | 242 int index2_; |
243 }; | 243 }; |
244 | 244 |
245 BookmarkModelTest() : model_(client_.CreateModel()) { | 245 BookmarkModelTest() : model_(TestBookmarkClient::CreateModel()) { |
246 model_->AddObserver(this); | 246 model_->AddObserver(this); |
247 ClearCounts(); | 247 ClearCounts(); |
248 } | 248 } |
249 | 249 |
250 void BookmarkModelLoaded(BookmarkModel* model, bool ids_reassigned) override { | 250 void BookmarkModelLoaded(BookmarkModel* model, bool ids_reassigned) override { |
251 // We never load from the db, so that this should never get invoked. | 251 // We never load from the db, so that this should never get invoked. |
252 NOTREACHED(); | 252 NOTREACHED(); |
253 } | 253 } |
254 | 254 |
255 void BookmarkNodeMoved(BookmarkModel* model, | 255 void BookmarkNodeMoved(BookmarkModel* model, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 extensive_changes_beginning_count_); | 364 extensive_changes_beginning_count_); |
365 EXPECT_EQ(extensive_changes_ended_count, extensive_changes_ended_count_); | 365 EXPECT_EQ(extensive_changes_ended_count, extensive_changes_ended_count_); |
366 } | 366 } |
367 | 367 |
368 int AllNodesRemovedObserverCount() const { return all_bookmarks_removed_; } | 368 int AllNodesRemovedObserverCount() const { return all_bookmarks_removed_; } |
369 | 369 |
370 BookmarkPermanentNode* ReloadModelWithExtraNode() { | 370 BookmarkPermanentNode* ReloadModelWithExtraNode() { |
371 BookmarkPermanentNode* extra_node = new BookmarkPermanentNode(100); | 371 BookmarkPermanentNode* extra_node = new BookmarkPermanentNode(100); |
372 BookmarkPermanentNodeList extra_nodes; | 372 BookmarkPermanentNodeList extra_nodes; |
373 extra_nodes.push_back(extra_node); | 373 extra_nodes.push_back(extra_node); |
374 client_.SetExtraNodesToLoad(extra_nodes.Pass()); | |
375 | 374 |
376 model_->RemoveObserver(this); | 375 model_->RemoveObserver(this); |
377 model_ = client_.CreateModel(); | 376 model_ = |
| 377 TestBookmarkClient::CreateModel(extra_nodes.Pass(), nullptr, false); |
378 model_->AddObserver(this); | 378 model_->AddObserver(this); |
379 ClearCounts(); | 379 ClearCounts(); |
380 | 380 |
381 if (model_->root_node()->GetIndexOf(extra_node) == -1) | 381 if (model_->root_node()->GetIndexOf(extra_node) == -1) |
382 ADD_FAILURE(); | 382 ADD_FAILURE(); |
383 | 383 |
384 return extra_node; | 384 return extra_node; |
385 } | 385 } |
386 | 386 |
387 protected: | 387 protected: |
388 TestBookmarkClient client_; | |
389 scoped_ptr<BookmarkModel> model_; | 388 scoped_ptr<BookmarkModel> model_; |
390 ObserverDetails observer_details_; | 389 ObserverDetails observer_details_; |
391 | 390 |
392 private: | 391 private: |
393 int added_count_; | 392 int added_count_; |
394 int moved_count_; | 393 int moved_count_; |
395 int removed_count_; | 394 int removed_count_; |
396 int changed_count_; | 395 int changed_count_; |
397 int reordered_count_; | 396 int reordered_count_; |
398 int extensive_changes_beginning_count_; | 397 int extensive_changes_beginning_count_; |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 const std::string mobile_contents; | 1149 const std::string mobile_contents; |
1151 } data[] = { | 1150 } data[] = { |
1152 // See PopulateNodeFromString for a description of these strings. | 1151 // See PopulateNodeFromString for a description of these strings. |
1153 { "", "" }, | 1152 { "", "" }, |
1154 { "a", "b" }, | 1153 { "a", "b" }, |
1155 { "a [ b ]", "" }, | 1154 { "a [ b ]", "" }, |
1156 { "", "[ b ] a [ c [ d e [ f ] ] ]" }, | 1155 { "", "[ b ] a [ c [ d e [ f ] ] ]" }, |
1157 { "a [ b ]", "" }, | 1156 { "a [ b ]", "" }, |
1158 { "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"}, | 1157 { "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"}, |
1159 }; | 1158 }; |
1160 TestBookmarkClient client; | |
1161 scoped_ptr<BookmarkModel> model; | 1159 scoped_ptr<BookmarkModel> model; |
1162 for (size_t i = 0; i < arraysize(data); ++i) { | 1160 for (size_t i = 0; i < arraysize(data); ++i) { |
1163 model = client.CreateModel(); | 1161 model = TestBookmarkClient::CreateModel(); |
1164 | 1162 |
1165 TestNode bbn; | 1163 TestNode bbn; |
1166 PopulateNodeFromString(data[i].bbn_contents, &bbn); | 1164 PopulateNodeFromString(data[i].bbn_contents, &bbn); |
1167 PopulateBookmarkNode(&bbn, model.get(), model->bookmark_bar_node()); | 1165 PopulateBookmarkNode(&bbn, model.get(), model->bookmark_bar_node()); |
1168 | 1166 |
1169 TestNode other; | 1167 TestNode other; |
1170 PopulateNodeFromString(data[i].other_contents, &other); | 1168 PopulateNodeFromString(data[i].other_contents, &other); |
1171 PopulateBookmarkNode(&other, model.get(), model->other_node()); | 1169 PopulateBookmarkNode(&other, model.get(), model->other_node()); |
1172 | 1170 |
1173 TestNode mobile; | 1171 TestNode mobile; |
1174 PopulateNodeFromString(data[i].mobile_contents, &mobile); | 1172 PopulateNodeFromString(data[i].mobile_contents, &mobile); |
1175 PopulateBookmarkNode(&mobile, model.get(), model->mobile_node()); | 1173 PopulateBookmarkNode(&mobile, model.get(), model->mobile_node()); |
1176 | 1174 |
1177 VerifyModelMatchesNode(&bbn, model->bookmark_bar_node()); | 1175 VerifyModelMatchesNode(&bbn, model->bookmark_bar_node()); |
1178 VerifyModelMatchesNode(&other, model->other_node()); | 1176 VerifyModelMatchesNode(&other, model->other_node()); |
1179 VerifyModelMatchesNode(&mobile, model->mobile_node()); | 1177 VerifyModelMatchesNode(&mobile, model->mobile_node()); |
1180 VerifyNoDuplicateIDs(model.get()); | 1178 VerifyNoDuplicateIDs(model.get()); |
1181 } | 1179 } |
1182 } | 1180 } |
1183 | 1181 |
1184 } // namespace | 1182 } // namespace |
1185 } // namespace bookmarks | 1183 } // namespace bookmarks |
OLD | NEW |