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

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

Issue 265853002: Allow embedder to force visibility of permanent nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase & fix BookmarkModelTest.NodeVisibility Created 6 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
« no previous file with comments | « no previous file | chrome/browser/bookmarks/chrome_bookmark_client.h » ('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 "components/bookmarks/core/browser/bookmark_model.h" 5 #include "components/bookmarks/core/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 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 1054
1055 // Make sure the order matches is correct (it should be reversed). 1055 // Make sure the order matches is correct (it should be reversed).
1056 ASSERT_EQ(4, parent->child_count()); 1056 ASSERT_EQ(4, parent->child_count());
1057 EXPECT_EQ("D", base::UTF16ToASCII(parent->GetChild(0)->GetTitle())); 1057 EXPECT_EQ("D", base::UTF16ToASCII(parent->GetChild(0)->GetTitle()));
1058 EXPECT_EQ("C", base::UTF16ToASCII(parent->GetChild(1)->GetTitle())); 1058 EXPECT_EQ("C", base::UTF16ToASCII(parent->GetChild(1)->GetTitle()));
1059 EXPECT_EQ("B", base::UTF16ToASCII(parent->GetChild(2)->GetTitle())); 1059 EXPECT_EQ("B", base::UTF16ToASCII(parent->GetChild(2)->GetTitle()));
1060 EXPECT_EQ("A", base::UTF16ToASCII(parent->GetChild(3)->GetTitle())); 1060 EXPECT_EQ("A", base::UTF16ToASCII(parent->GetChild(3)->GetTitle()));
1061 } 1061 }
1062 1062
1063 TEST_F(BookmarkModelTest, NodeVisibility) { 1063 TEST_F(BookmarkModelTest, NodeVisibility) {
1064 // Mobile node invisible by default
1064 EXPECT_TRUE(model_->bookmark_bar_node()->IsVisible()); 1065 EXPECT_TRUE(model_->bookmark_bar_node()->IsVisible());
1065 EXPECT_TRUE(model_->other_node()->IsVisible()); 1066 EXPECT_TRUE(model_->other_node()->IsVisible());
1066 // Mobile node invisible by default
1067 EXPECT_FALSE(model_->mobile_node()->IsVisible()); 1067 EXPECT_FALSE(model_->mobile_node()->IsVisible());
1068 1068
1069 // Change visibility of permanent nodes. 1069 // Visibility of permanent node can only be changed if they are not
1070 // forced to be visible by the client.
1070 model_->SetPermanentNodeVisible(BookmarkNode::BOOKMARK_BAR, false); 1071 model_->SetPermanentNodeVisible(BookmarkNode::BOOKMARK_BAR, false);
1071 EXPECT_FALSE(model_->bookmark_bar_node()->IsVisible()); 1072 EXPECT_TRUE(model_->bookmark_bar_node()->IsVisible());
1072 model_->SetPermanentNodeVisible(BookmarkNode::OTHER_NODE, false); 1073 model_->SetPermanentNodeVisible(BookmarkNode::OTHER_NODE, false);
1073 EXPECT_FALSE(model_->other_node()->IsVisible()); 1074 EXPECT_TRUE(model_->other_node()->IsVisible());
1074 model_->SetPermanentNodeVisible(BookmarkNode::MOBILE, true); 1075 model_->SetPermanentNodeVisible(BookmarkNode::MOBILE, true);
1075 EXPECT_TRUE(model_->mobile_node()->IsVisible()); 1076 EXPECT_TRUE(model_->mobile_node()->IsVisible());
1077 model_->SetPermanentNodeVisible(BookmarkNode::MOBILE, false);
1078 EXPECT_FALSE(model_->mobile_node()->IsVisible());
1076 1079
1077 // Arbitrary node should be visible 1080 // Arbitrary node should be visible
1078 TestNode bbn; 1081 TestNode bbn;
1079 PopulateNodeFromString("B", &bbn); 1082 PopulateNodeFromString("B", &bbn);
1080 const BookmarkNode* parent = model_->bookmark_bar_node(); 1083 const BookmarkNode* parent = model_->mobile_node();
1081 PopulateBookmarkNode(&bbn, model_.get(), parent); 1084 PopulateBookmarkNode(&bbn, model_.get(), parent);
1082 EXPECT_TRUE(parent->GetChild(0)->IsVisible()); 1085 EXPECT_TRUE(parent->GetChild(0)->IsVisible());
1083 1086
1084 // Bookmark bar should be visible now that it has a child. 1087 // Mobile folder should be visible now that it has a child.
1085 EXPECT_TRUE(model_->bookmark_bar_node()->IsVisible()); 1088 EXPECT_TRUE(model_->mobile_node()->IsVisible());
1086 } 1089 }
1087 1090
1088 TEST_F(BookmarkModelTest, MobileNodeVisibileWithChildren) { 1091 TEST_F(BookmarkModelTest, MobileNodeVisibileWithChildren) {
1089 const BookmarkNode* root = model_->mobile_node(); 1092 const BookmarkNode* root = model_->mobile_node();
1090 const base::string16 title(ASCIIToUTF16("foo")); 1093 const base::string16 title(ASCIIToUTF16("foo"));
1091 const GURL url("http://foo.com"); 1094 const GURL url("http://foo.com");
1092 1095
1093 model_->AddURL(root, 0, title, url); 1096 model_->AddURL(root, 0, title, url);
1094 EXPECT_TRUE(model_->mobile_node()->IsVisible()); 1097 EXPECT_TRUE(model_->mobile_node()->IsVisible());
1095 } 1098 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 EXPECT_TRUE(node.DeleteMetaInfo("key2.subkey2.leaf")); 1151 EXPECT_TRUE(node.DeleteMetaInfo("key2.subkey2.leaf"));
1149 EXPECT_FALSE(node.DeleteMetaInfo("key3")); 1152 EXPECT_FALSE(node.DeleteMetaInfo("key3"));
1150 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value)); 1153 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value));
1151 EXPECT_FALSE(node.GetMetaInfo("key2.subkey1", &out_value)); 1154 EXPECT_FALSE(node.GetMetaInfo("key2.subkey1", &out_value));
1152 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2", &out_value)); 1155 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2", &out_value));
1153 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2.leaf", &out_value)); 1156 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2.leaf", &out_value));
1154 EXPECT_FALSE(node.GetMetaInfoMap()); 1157 EXPECT_FALSE(node.GetMetaInfoMap());
1155 } 1158 }
1156 1159
1157 } // namespace 1160 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/bookmarks/chrome_bookmark_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698