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 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 BookmarkModel* model, | 852 BookmarkModel* model, |
853 const BookmarkNode* bb_node) { | 853 const BookmarkNode* bb_node) { |
854 for (int i = 0; i < parent->child_count(); ++i) { | 854 for (int i = 0; i < parent->child_count(); ++i) { |
855 TestNode* child = parent->GetChild(i); | 855 TestNode* child = parent->GetChild(i); |
856 if (child->value == BookmarkNode::FOLDER) { | 856 if (child->value == BookmarkNode::FOLDER) { |
857 const BookmarkNode* new_bb_node = | 857 const BookmarkNode* new_bb_node = |
858 model->AddFolder(bb_node, i, child->GetTitle()); | 858 model->AddFolder(bb_node, i, child->GetTitle()); |
859 PopulateBookmarkNode(child, model, new_bb_node); | 859 PopulateBookmarkNode(child, model, new_bb_node); |
860 } else { | 860 } else { |
861 model->AddURL(bb_node, i, child->GetTitle(), | 861 model->AddURL(bb_node, i, child->GetTitle(), |
862 GURL("http://" + UTF16ToASCII(child->GetTitle()))); | 862 GURL("http://" + base::UTF16ToASCII(child->GetTitle()))); |
863 } | 863 } |
864 } | 864 } |
865 } | 865 } |
866 | 866 |
867 // Test class that creates a BookmarkModel with a real history backend. | 867 // Test class that creates a BookmarkModel with a real history backend. |
868 class BookmarkModelTestWithProfile : public testing::Test { | 868 class BookmarkModelTestWithProfile : public testing::Test { |
869 public: | 869 public: |
870 BookmarkModelTestWithProfile() | 870 BookmarkModelTestWithProfile() |
871 : bb_model_(NULL) {} | 871 : bb_model_(NULL) {} |
872 | 872 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 new_order.push_back(parent->GetChild(2)); | 1015 new_order.push_back(parent->GetChild(2)); |
1016 new_order.push_back(parent->GetChild(1)); | 1016 new_order.push_back(parent->GetChild(1)); |
1017 new_order.push_back(parent->GetChild(0)); | 1017 new_order.push_back(parent->GetChild(0)); |
1018 model_.ReorderChildren(parent, new_order); | 1018 model_.ReorderChildren(parent, new_order); |
1019 | 1019 |
1020 // Make sure we were notified. | 1020 // Make sure we were notified. |
1021 AssertObserverCount(0, 0, 0, 0, 1, 0, 0, 1, 0); | 1021 AssertObserverCount(0, 0, 0, 0, 1, 0, 0, 1, 0); |
1022 | 1022 |
1023 // Make sure the order matches is correct (it should be reversed). | 1023 // Make sure the order matches is correct (it should be reversed). |
1024 ASSERT_EQ(4, parent->child_count()); | 1024 ASSERT_EQ(4, parent->child_count()); |
1025 EXPECT_EQ("D", UTF16ToASCII(parent->GetChild(0)->GetTitle())); | 1025 EXPECT_EQ("D", base::UTF16ToASCII(parent->GetChild(0)->GetTitle())); |
1026 EXPECT_EQ("C", UTF16ToASCII(parent->GetChild(1)->GetTitle())); | 1026 EXPECT_EQ("C", base::UTF16ToASCII(parent->GetChild(1)->GetTitle())); |
1027 EXPECT_EQ("B", UTF16ToASCII(parent->GetChild(2)->GetTitle())); | 1027 EXPECT_EQ("B", base::UTF16ToASCII(parent->GetChild(2)->GetTitle())); |
1028 EXPECT_EQ("A", UTF16ToASCII(parent->GetChild(3)->GetTitle())); | 1028 EXPECT_EQ("A", base::UTF16ToASCII(parent->GetChild(3)->GetTitle())); |
1029 } | 1029 } |
1030 | 1030 |
1031 TEST_F(BookmarkModelTest, NodeVisibility) { | 1031 TEST_F(BookmarkModelTest, NodeVisibility) { |
1032 EXPECT_TRUE(model_.bookmark_bar_node()->IsVisible()); | 1032 EXPECT_TRUE(model_.bookmark_bar_node()->IsVisible()); |
1033 EXPECT_TRUE(model_.other_node()->IsVisible()); | 1033 EXPECT_TRUE(model_.other_node()->IsVisible()); |
1034 // Mobile node invisible by default | 1034 // Mobile node invisible by default |
1035 EXPECT_FALSE(model_.mobile_node()->IsVisible()); | 1035 EXPECT_FALSE(model_.mobile_node()->IsVisible()); |
1036 | 1036 |
1037 // Change visibility of permanent nodes. | 1037 // Change visibility of permanent nodes. |
1038 model_.SetPermanentNodeVisible(BookmarkNode::BOOKMARK_BAR, false); | 1038 model_.SetPermanentNodeVisible(BookmarkNode::BOOKMARK_BAR, false); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 EXPECT_TRUE(node.DeleteMetaInfo("key2.subkey2.leaf")); | 1116 EXPECT_TRUE(node.DeleteMetaInfo("key2.subkey2.leaf")); |
1117 EXPECT_FALSE(node.DeleteMetaInfo("key3")); | 1117 EXPECT_FALSE(node.DeleteMetaInfo("key3")); |
1118 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value)); | 1118 EXPECT_FALSE(node.GetMetaInfo("key1", &out_value)); |
1119 EXPECT_FALSE(node.GetMetaInfo("key2.subkey1", &out_value)); | 1119 EXPECT_FALSE(node.GetMetaInfo("key2.subkey1", &out_value)); |
1120 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2", &out_value)); | 1120 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2", &out_value)); |
1121 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2.leaf", &out_value)); | 1121 EXPECT_FALSE(node.GetMetaInfo("key2.subkey2.leaf", &out_value)); |
1122 EXPECT_FALSE(node.GetMetaInfoMap()); | 1122 EXPECT_FALSE(node.GetMetaInfoMap()); |
1123 } | 1123 } |
1124 | 1124 |
1125 } // namespace | 1125 } // namespace |
OLD | NEW |