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/ui/bookmarks/bookmark_utils.h" | 5 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
9 #include "components/bookmarks/browser/bookmark_model.h" | 9 #include "components/bookmarks/browser/bookmark_model.h" |
10 #include "components/bookmarks/test/test_bookmark_client.h" | 10 #include "components/bookmarks/test/test_bookmark_client.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // This verifies if HasBookmarkURLs iterates through immediate children. | 48 // This verifies if HasBookmarkURLs iterates through immediate children. |
49 model->AddURL(folder1, 0, ASCIIToUTF16("Foo"), GURL("http://randomsite.com")); | 49 model->AddURL(folder1, 0, ASCIIToUTF16("Foo"), GURL("http://randomsite.com")); |
50 EXPECT_TRUE(chrome::HasBookmarkURLs(nodes)); | 50 EXPECT_TRUE(chrome::HasBookmarkURLs(nodes)); |
51 | 51 |
52 // This verifies that HasBookmarkURLS does not iterate through descendants. | 52 // This verifies that HasBookmarkURLS does not iterate through descendants. |
53 // i.e, it should not find an URL inside a two or three level hierarchy. | 53 // i.e, it should not find an URL inside a two or three level hierarchy. |
54 // So we add another folder to |folder1| and add another page to that new | 54 // So we add another folder to |folder1| and add another page to that new |
55 // folder to create a two level hierarchy. | 55 // folder to create a two level hierarchy. |
56 | 56 |
57 // But first we have to remove the URL from |folder1|. | 57 // But first we have to remove the URL from |folder1|. |
58 model->Remove(folder1, 0); | 58 model->Remove(folder1->GetChild(0)); |
59 | 59 |
60 const BookmarkNode* subfolder1 = | 60 const BookmarkNode* subfolder1 = |
61 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); | 61 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); |
62 | 62 |
63 // Now add the URL to that |subfolder1|. | 63 // Now add the URL to that |subfolder1|. |
64 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); | 64 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); |
65 EXPECT_FALSE(chrome::HasBookmarkURLs(nodes)); | 65 EXPECT_FALSE(chrome::HasBookmarkURLs(nodes)); |
66 } | 66 } |
67 | 67 |
68 TEST_F(BookmarkUIUtilsTest, HasBookmarkURLsAllowedInIncognitoMode) { | 68 TEST_F(BookmarkUIUtilsTest, HasBookmarkURLsAllowedInIncognitoMode) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 model->AddURL(folder1, 0, ASCIIToUTF16("Foo"), GURL("http://randomsite.com")); | 107 model->AddURL(folder1, 0, ASCIIToUTF16("Foo"), GURL("http://randomsite.com")); |
108 EXPECT_TRUE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile)); | 108 EXPECT_TRUE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile)); |
109 | 109 |
110 // This verifies that HasBookmarkURLsAllowedInIncognitoMode does not iterate | 110 // This verifies that HasBookmarkURLsAllowedInIncognitoMode does not iterate |
111 // through descendants. | 111 // through descendants. |
112 // i.e, it should not find an URL inside a two or three level hierarchy. | 112 // i.e, it should not find an URL inside a two or three level hierarchy. |
113 // So we add another folder to |folder1| and add another page to that new | 113 // So we add another folder to |folder1| and add another page to that new |
114 // folder to create a two level hierarchy. | 114 // folder to create a two level hierarchy. |
115 | 115 |
116 // But first we have to remove the URL from |folder1|. | 116 // But first we have to remove the URL from |folder1|. |
117 model->Remove(folder1, 0); | 117 model->Remove(folder1->GetChild(0)); |
118 | 118 |
119 const BookmarkNode* subfolder1 = | 119 const BookmarkNode* subfolder1 = |
120 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); | 120 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); |
121 | 121 |
122 // Now add the URL to that |subfolder1|. | 122 // Now add the URL to that |subfolder1|. |
123 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); | 123 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); |
124 EXPECT_FALSE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile)); | 124 EXPECT_FALSE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile)); |
125 } | 125 } |
126 | 126 |
127 } // namespace | 127 } // namespace |
128 #endif | 128 #endif |
OLD | NEW |