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

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

Issue 15275004: bookmarks: Get rid of the dependency on history_notifications.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add files back Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.cc ('k') | chrome/browser/favicon/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/hash_tables.h" 14 #include "base/hash_tables.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
20 #include "base/time.h" 20 #include "base/time.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 22 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
23 #include "chrome/browser/bookmarks/bookmark_model_observer.h" 23 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
24 #include "chrome/browser/bookmarks/bookmark_utils.h" 24 #include "chrome/browser/bookmarks/bookmark_utils.h"
25 #include "chrome/browser/history/history_notifications.h"
26 #include "chrome/browser/history/history_service.h"
27 #include "chrome/browser/history/history_service_factory.h"
28 #include "chrome/test/base/model_test_utils.h" 25 #include "chrome/test/base/model_test_utils.h"
29 #include "chrome/test/base/testing_profile.h" 26 #include "chrome/test/base/testing_profile.h"
30 #include "chrome/test/base/ui_test_utils.h" 27 #include "chrome/test/base/ui_test_utils.h"
31 #include "content/public/test/test_browser_thread.h" 28 #include "content/public/test/test_browser_thread.h"
32 #include "googleurl/src/gurl.h" 29 #include "googleurl/src/gurl.h"
33 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
34 #include "ui/base/models/tree_node_iterator.h" 31 #include "ui/base/models/tree_node_iterator.h"
35 #include "ui/base/models/tree_node_model.h" 32 #include "ui/base/models/tree_node_model.h"
36 33
37 using base::Time; 34 using base::Time;
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 profile_->CreateBookmarkModel(false); 940 profile_->CreateBookmarkModel(false);
944 BlockTillBookmarkModelLoaded(); 941 BlockTillBookmarkModelLoaded();
945 942
946 VerifyModelMatchesNode(&bbn, bb_model_->bookmark_bar_node()); 943 VerifyModelMatchesNode(&bbn, bb_model_->bookmark_bar_node());
947 VerifyModelMatchesNode(&other, bb_model_->other_node()); 944 VerifyModelMatchesNode(&other, bb_model_->other_node());
948 VerifyModelMatchesNode(&mobile, bb_model_->mobile_node()); 945 VerifyModelMatchesNode(&mobile, bb_model_->mobile_node());
949 VerifyNoDuplicateIDs(bb_model_); 946 VerifyNoDuplicateIDs(bb_model_);
950 } 947 }
951 } 948 }
952 949
953 // Simple test that removes a bookmark. This test exercises the code paths in
954 // History that block till bookmark bar model is loaded.
955 TEST_F(BookmarkModelTestWithProfile, RemoveNotification) {
956 profile_.reset(new TestingProfile());
957
958 profile_->CreateHistoryService(false, false);
959 profile_->CreateBookmarkModel(true);
960 BlockTillBookmarkModelLoaded();
961
962 // Add a URL.
963 GURL url("http://www.google.com");
964 bookmark_utils::AddIfNotBookmarked(bb_model_, url, string16());
965
966 HistoryServiceFactory::GetForProfile(
967 profile_.get(), Profile::EXPLICIT_ACCESS)->AddPage(
968 url, base::Time::Now(), NULL, 1, GURL(), history::RedirectList(),
969 content::PAGE_TRANSITION_TYPED, history::SOURCE_BROWSED, false);
970
971 // This won't actually delete the URL, rather it'll empty out the visits.
972 // This triggers blocking on the BookmarkModel.
973 HistoryServiceFactory::GetForProfile(
974 profile_.get(), Profile::EXPLICIT_ACCESS)->DeleteURL(url);
975 }
976
977 TEST_F(BookmarkModelTest, Sort) { 950 TEST_F(BookmarkModelTest, Sort) {
978 // Populate the bookmark bar node with nodes for 'B', 'a', 'd' and 'C'. 951 // Populate the bookmark bar node with nodes for 'B', 'a', 'd' and 'C'.
979 // 'C' and 'a' are folders. 952 // 'C' and 'a' are folders.
980 TestNode bbn; 953 TestNode bbn;
981 PopulateNodeFromString("B [ a ] d [ a ]", &bbn); 954 PopulateNodeFromString("B [ a ] d [ a ]", &bbn);
982 const BookmarkNode* parent = model_.bookmark_bar_node(); 955 const BookmarkNode* parent = model_.bookmark_bar_node();
983 PopulateBookmarkNode(&bbn, &model_, parent); 956 PopulateBookmarkNode(&bbn, &model_, parent);
984 957
985 BookmarkNode* child1 = AsMutable(parent->GetChild(1)); 958 BookmarkNode* child1 = AsMutable(parent->GetChild(1));
986 child1->SetTitle(ASCIIToUTF16("a")); 959 child1->SetTitle(ASCIIToUTF16("a"));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 1058
1086 EXPECT_TRUE(node.DeleteMetaInfo("key1")); 1059 EXPECT_TRUE(node.DeleteMetaInfo("key1"));
1087 EXPECT_TRUE(node.DeleteMetaInfo("key2")); 1060 EXPECT_TRUE(node.DeleteMetaInfo("key2"));
1088 EXPECT_FALSE(node.DeleteMetaInfo("key3")); 1061 EXPECT_FALSE(node.DeleteMetaInfo("key3"));
1089 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value)); 1062 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value));
1090 EXPECT_FALSE(node.GetMetaInfo("key2", &out_value)); 1063 EXPECT_FALSE(node.GetMetaInfo("key2", &out_value));
1091 EXPECT_TRUE(node.meta_info_str().empty()); 1064 EXPECT_TRUE(node.meta_info_str().empty());
1092 } 1065 }
1093 1066
1094 } // namespace 1067 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.cc ('k') | chrome/browser/favicon/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698