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 14 matching lines...) Expand all Loading... |
25 #include "components/bookmarks/test/test_bookmark_client.h" | 25 #include "components/bookmarks/test/test_bookmark_client.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 #include "ui/base/models/tree_node_iterator.h" | 27 #include "ui/base/models/tree_node_iterator.h" |
28 #include "ui/base/models/tree_node_model.h" | 28 #include "ui/base/models/tree_node_model.h" |
29 #include "url/gurl.h" | 29 #include "url/gurl.h" |
30 | 30 |
31 using base::ASCIIToUTF16; | 31 using base::ASCIIToUTF16; |
32 using base::Time; | 32 using base::Time; |
33 using base::TimeDelta; | 33 using base::TimeDelta; |
34 | 34 |
| 35 namespace bookmarks { |
35 namespace { | 36 namespace { |
36 | 37 |
37 // Test cases used to test the removal of extra whitespace when adding | 38 // Test cases used to test the removal of extra whitespace when adding |
38 // a new folder/bookmark or updating a title of a folder/bookmark. | 39 // a new folder/bookmark or updating a title of a folder/bookmark. |
39 static struct { | 40 static struct { |
40 const std::string input_title; | 41 const std::string input_title; |
41 const std::string expected_title; | 42 const std::string expected_title; |
42 } url_whitespace_test_cases[] = { | 43 } url_whitespace_test_cases[] = { |
43 {"foobar", "foobar"}, | 44 {"foobar", "foobar"}, |
44 // Newlines. | 45 // Newlines. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 model_->AddObserver(this); | 287 model_->AddObserver(this); |
287 ClearCounts(); | 288 ClearCounts(); |
288 | 289 |
289 if (model_->root_node()->GetIndexOf(extra_node) == -1) | 290 if (model_->root_node()->GetIndexOf(extra_node) == -1) |
290 ADD_FAILURE(); | 291 ADD_FAILURE(); |
291 | 292 |
292 return extra_node; | 293 return extra_node; |
293 } | 294 } |
294 | 295 |
295 protected: | 296 protected: |
296 test::TestBookmarkClient client_; | 297 TestBookmarkClient client_; |
297 scoped_ptr<BookmarkModel> model_; | 298 scoped_ptr<BookmarkModel> model_; |
298 ObserverDetails observer_details_; | 299 ObserverDetails observer_details_; |
299 | 300 |
300 private: | 301 private: |
301 int will_add_count_; | 302 int will_add_count_; |
302 int added_count_; | 303 int added_count_; |
303 int moved_count_; | 304 int moved_count_; |
304 int removed_count_; | 305 int removed_count_; |
305 int changed_count_; | 306 int changed_count_; |
306 int reordered_count_; | 307 int reordered_count_; |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 } | 947 } |
947 } | 948 } |
948 | 949 |
949 void VerifyNoDuplicateIDs(BookmarkModel* model) { | 950 void VerifyNoDuplicateIDs(BookmarkModel* model) { |
950 ui::TreeNodeIterator<const BookmarkNode> it(model->root_node()); | 951 ui::TreeNodeIterator<const BookmarkNode> it(model->root_node()); |
951 base::hash_set<int64> ids; | 952 base::hash_set<int64> ids; |
952 while (it.has_next()) | 953 while (it.has_next()) |
953 ASSERT_TRUE(ids.insert(it.Next()->id()).second); | 954 ASSERT_TRUE(ids.insert(it.Next()->id()).second); |
954 } | 955 } |
955 | 956 |
956 test::TestBookmarkClient client_; | 957 TestBookmarkClient client_; |
957 scoped_ptr<BookmarkModel> model_; | 958 scoped_ptr<BookmarkModel> model_; |
958 }; | 959 }; |
959 | 960 |
960 // Creates a set of nodes in the bookmark bar model, then recreates the | 961 // Creates a set of nodes in the bookmark bar model, then recreates the |
961 // bookmark bar model which triggers loading from the db and checks the loaded | 962 // bookmark bar model which triggers loading from the db and checks the loaded |
962 // structure to make sure it is what we first created. | 963 // structure to make sure it is what we first created. |
963 TEST_F(BookmarkModelTestWithProfile, CreateAndRestore) { | 964 TEST_F(BookmarkModelTestWithProfile, CreateAndRestore) { |
964 struct TestData { | 965 struct TestData { |
965 // Structure of the children of the bookmark bar model node. | 966 // Structure of the children of the bookmark bar model node. |
966 const std::string bbn_contents; | 967 const std::string bbn_contents; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 EXPECT_TRUE(node.DeleteMetaInfo("key2.subkey2.leaf")); | 1204 EXPECT_TRUE(node.DeleteMetaInfo("key2.subkey2.leaf")); |
1204 EXPECT_FALSE(node.DeleteMetaInfo("key3")); | 1205 EXPECT_FALSE(node.DeleteMetaInfo("key3")); |
1205 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value)); | 1206 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value)); |
1206 EXPECT_FALSE(node.GetMetaInfo("key2.subkey1", &out_value)); | 1207 EXPECT_FALSE(node.GetMetaInfo("key2.subkey1", &out_value)); |
1207 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2", &out_value)); | 1208 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2", &out_value)); |
1208 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2.leaf", &out_value)); | 1209 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2.leaf", &out_value)); |
1209 EXPECT_FALSE(node.GetMetaInfoMap()); | 1210 EXPECT_FALSE(node.GetMetaInfoMap()); |
1210 } | 1211 } |
1211 | 1212 |
1212 } // namespace | 1213 } // namespace |
| 1214 } // namespace bookmarks |
OLD | NEW |