Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: chrome/browser/bookmarks/bookmark_model_unittest.cc

Issue 19616004: Add asserts to TestingProfile::CreateHistoryService to ensure files are deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix release unit tests Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
922 // The profile. 913 // The profile.
923 scoped_ptr<TestingProfile> profile_; 914 scoped_ptr<TestingProfile> profile_;
924 BookmarkModel* bb_model_; 915 BookmarkModel* bb_model_;
925 916
926 private: 917 private:
927 content::TestBrowserThreadBundle thread_bundle_; 918 content::TestBrowserThreadBundle thread_bundle_;
928 }; 919 };
929 920
930 // Creates a set of nodes in the bookmark bar model, then recreates the 921 // Creates a set of nodes in the bookmark bar model, then recreates the
931 // bookmark bar model which triggers loading from the db and checks the loaded 922 // bookmark bar model which triggers loading from the db and checks the loaded
(...skipping 15 matching lines...) Expand all
947 { "a [ b ]", "" }, 938 { "a [ b ]", "" },
948 { "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"}, 939 { "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"},
949 }; 940 };
950 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { 941 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
951 // Recreate the profile. We need to reset with NULL first so that the last 942 // Recreate the profile. We need to reset with NULL first so that the last
952 // HistoryService releases the locks on the files it creates and we can 943 // HistoryService releases the locks on the files it creates and we can
953 // delete them. 944 // delete them.
954 profile_.reset(NULL); 945 profile_.reset(NULL);
955 profile_.reset(new TestingProfile()); 946 profile_.reset(new TestingProfile());
956 profile_->CreateBookmarkModel(true); 947 profile_->CreateBookmarkModel(true);
957 profile_->CreateHistoryService(true, false); 948 ASSERT_TRUE(profile_->CreateHistoryService(true, false));
958 BlockTillBookmarkModelLoaded(); 949 BlockTillBookmarkModelLoaded();
959 950
960 TestNode bbn; 951 TestNode bbn;
961 PopulateNodeFromString(data[i].bbn_contents, &bbn); 952 PopulateNodeFromString(data[i].bbn_contents, &bbn);
962 PopulateBookmarkNode(&bbn, bb_model_, bb_model_->bookmark_bar_node()); 953 PopulateBookmarkNode(&bbn, bb_model_, bb_model_->bookmark_bar_node());
963 954
964 TestNode other; 955 TestNode other;
965 PopulateNodeFromString(data[i].other_contents, &other); 956 PopulateNodeFromString(data[i].other_contents, &other);
966 PopulateBookmarkNode(&other, bb_model_, bb_model_->other_node()); 957 PopulateBookmarkNode(&other, bb_model_, bb_model_->other_node());
967 958
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 EXPECT_TRUE(node.DeleteMetaInfo("key2.subkey2.leaf")); 1117 EXPECT_TRUE(node.DeleteMetaInfo("key2.subkey2.leaf"));
1127 EXPECT_FALSE(node.DeleteMetaInfo("key3")); 1118 EXPECT_FALSE(node.DeleteMetaInfo("key3"));
1128 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value)); 1119 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value));
1129 EXPECT_FALSE(node.GetMetaInfo("key2.subkey1", &out_value)); 1120 EXPECT_FALSE(node.GetMetaInfo("key2.subkey1", &out_value));
1130 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2", &out_value)); 1121 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2", &out_value));
1131 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2.leaf", &out_value)); 1122 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2.leaf", &out_value));
1132 EXPECT_TRUE(node.meta_info_str().empty()); 1123 EXPECT_TRUE(node.meta_info_str().empty());
1133 } 1124 }
1134 1125
1135 } // namespace 1126 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_index_unittest.cc ('k') | chrome/browser/browsing_data/browsing_data_remover_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698