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 "chrome/browser/bookmarks/bookmark_model.h" | 5 #include "chrome/browser/bookmarks/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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 base::hash_set<int64> ids; | 903 base::hash_set<int64> ids; |
904 while (it.has_next()) | 904 while (it.has_next()) |
905 ASSERT_TRUE(ids.insert(it.Next()->id()).second); | 905 ASSERT_TRUE(ids.insert(it.Next()->id()).second); |
906 } | 906 } |
907 | 907 |
908 void BlockTillBookmarkModelLoaded() { | 908 void BlockTillBookmarkModelLoaded() { |
909 bb_model_ = BookmarkModelFactory::GetForProfile(profile_.get()); | 909 bb_model_ = BookmarkModelFactory::GetForProfile(profile_.get()); |
910 ui_test_utils::WaitForBookmarkModelToLoad(bb_model_); | 910 ui_test_utils::WaitForBookmarkModelToLoad(bb_model_); |
911 } | 911 } |
912 | 912 |
| 913 // Destroys the current profile, creates a new one and creates the history |
| 914 // service. |
| 915 void RecreateProfile() { |
| 916 // Need to shutdown the old one before creating a new one. |
| 917 profile_.reset(NULL); |
| 918 profile_.reset(new TestingProfile()); |
| 919 profile_->CreateHistoryService(true, false); |
| 920 } |
| 921 |
913 // The profile. | 922 // The profile. |
914 scoped_ptr<TestingProfile> profile_; | 923 scoped_ptr<TestingProfile> profile_; |
915 BookmarkModel* bb_model_; | 924 BookmarkModel* bb_model_; |
916 | 925 |
917 private: | 926 private: |
918 content::TestBrowserThreadBundle thread_bundle_; | 927 content::TestBrowserThreadBundle thread_bundle_; |
919 }; | 928 }; |
920 | 929 |
921 // Creates a set of nodes in the bookmark bar model, then recreates the | 930 // Creates a set of nodes in the bookmark bar model, then recreates the |
922 // bookmark bar model which triggers loading from the db and checks the loaded | 931 // bookmark bar model which triggers loading from the db and checks the loaded |
(...skipping 15 matching lines...) Expand all Loading... |
938 { "a [ b ]", "" }, | 947 { "a [ b ]", "" }, |
939 { "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"}, | 948 { "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"}, |
940 }; | 949 }; |
941 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | 950 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
942 // Recreate the profile. We need to reset with NULL first so that the last | 951 // Recreate the profile. We need to reset with NULL first so that the last |
943 // HistoryService releases the locks on the files it creates and we can | 952 // HistoryService releases the locks on the files it creates and we can |
944 // delete them. | 953 // delete them. |
945 profile_.reset(NULL); | 954 profile_.reset(NULL); |
946 profile_.reset(new TestingProfile()); | 955 profile_.reset(new TestingProfile()); |
947 profile_->CreateBookmarkModel(true); | 956 profile_->CreateBookmarkModel(true); |
948 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); | 957 profile_->CreateHistoryService(true, false); |
949 BlockTillBookmarkModelLoaded(); | 958 BlockTillBookmarkModelLoaded(); |
950 | 959 |
951 TestNode bbn; | 960 TestNode bbn; |
952 PopulateNodeFromString(data[i].bbn_contents, &bbn); | 961 PopulateNodeFromString(data[i].bbn_contents, &bbn); |
953 PopulateBookmarkNode(&bbn, bb_model_, bb_model_->bookmark_bar_node()); | 962 PopulateBookmarkNode(&bbn, bb_model_, bb_model_->bookmark_bar_node()); |
954 | 963 |
955 TestNode other; | 964 TestNode other; |
956 PopulateNodeFromString(data[i].other_contents, &other); | 965 PopulateNodeFromString(data[i].other_contents, &other); |
957 PopulateBookmarkNode(&other, bb_model_, bb_model_->other_node()); | 966 PopulateBookmarkNode(&other, bb_model_, bb_model_->other_node()); |
958 | 967 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 EXPECT_TRUE(node.DeleteMetaInfo("key2.subkey2.leaf")); | 1126 EXPECT_TRUE(node.DeleteMetaInfo("key2.subkey2.leaf")); |
1118 EXPECT_FALSE(node.DeleteMetaInfo("key3")); | 1127 EXPECT_FALSE(node.DeleteMetaInfo("key3")); |
1119 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value)); | 1128 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value)); |
1120 EXPECT_FALSE(node.GetMetaInfo("key2.subkey1", &out_value)); | 1129 EXPECT_FALSE(node.GetMetaInfo("key2.subkey1", &out_value)); |
1121 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2", &out_value)); | 1130 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2", &out_value)); |
1122 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2.leaf", &out_value)); | 1131 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2.leaf", &out_value)); |
1123 EXPECT_TRUE(node.meta_info_str().empty()); | 1132 EXPECT_TRUE(node.meta_info_str().empty()); |
1124 } | 1133 } |
1125 | 1134 |
1126 } // namespace | 1135 } // namespace |
OLD | NEW |