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" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 13 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
14 | 14 |
15 using base::ASCIIToUTF16; | 15 using base::ASCIIToUTF16; |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 TEST(BookmarkUIUtilsTest, HasBookmarkURLs) { | 19 TEST(BookmarkUIUtilsTest, HasBookmarkURLs) { |
20 test::TestBookmarkClient client; | 20 test::TestBookmarkClient client; |
21 scoped_ptr<BookmarkModel> model(client.CreateModel()); | 21 scoped_ptr<BookmarkModel> model(client.CreateModel(false)); |
22 | 22 |
23 std::vector<const BookmarkNode*> nodes; | 23 std::vector<const BookmarkNode*> nodes; |
24 | 24 |
25 // This tests that |nodes| contains an URL. | 25 // This tests that |nodes| contains an URL. |
26 const BookmarkNode* page1 = model->AddURL(model->bookmark_bar_node(), | 26 const BookmarkNode* page1 = model->AddURL(model->bookmark_bar_node(), |
27 0, | 27 0, |
28 ASCIIToUTF16("Google"), | 28 ASCIIToUTF16("Google"), |
29 GURL("http://google.com")); | 29 GURL("http://google.com")); |
30 nodes.push_back(page1); | 30 nodes.push_back(page1); |
31 EXPECT_TRUE(chrome::HasBookmarkURLs(nodes)); | 31 EXPECT_TRUE(chrome::HasBookmarkURLs(nodes)); |
(...skipping 21 matching lines...) Expand all Loading... |
53 const BookmarkNode* subfolder1 = | 53 const BookmarkNode* subfolder1 = |
54 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); | 54 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); |
55 | 55 |
56 // Now add the URL to that |subfolder1|. | 56 // Now add the URL to that |subfolder1|. |
57 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); | 57 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); |
58 EXPECT_FALSE(chrome::HasBookmarkURLs(nodes)); | 58 EXPECT_FALSE(chrome::HasBookmarkURLs(nodes)); |
59 } | 59 } |
60 | 60 |
61 TEST(BookmarkUIUtilsTest, HasBookmarkURLsAllowedInIncognitoMode) { | 61 TEST(BookmarkUIUtilsTest, HasBookmarkURLsAllowedInIncognitoMode) { |
62 test::TestBookmarkClient client; | 62 test::TestBookmarkClient client; |
63 scoped_ptr<BookmarkModel> model(client.CreateModel()); | 63 scoped_ptr<BookmarkModel> model(client.CreateModel(false)); |
64 TestingProfile profile; | 64 TestingProfile profile; |
65 | 65 |
66 std::vector<const BookmarkNode*> nodes; | 66 std::vector<const BookmarkNode*> nodes; |
67 | 67 |
68 // This tests that |nodes| contains an disabled-in-incognito URL. | 68 // This tests that |nodes| contains an disabled-in-incognito URL. |
69 const BookmarkNode* page1 = model->AddURL(model->bookmark_bar_node(), | 69 const BookmarkNode* page1 = model->AddURL(model->bookmark_bar_node(), |
70 0, | 70 0, |
71 ASCIIToUTF16("BookmarkManager"), | 71 ASCIIToUTF16("BookmarkManager"), |
72 GURL("chrome://bookmarks")); | 72 GURL("chrome://bookmarks")); |
73 nodes.push_back(page1); | 73 nodes.push_back(page1); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 const BookmarkNode* subfolder1 = | 112 const BookmarkNode* subfolder1 = |
113 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); | 113 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); |
114 | 114 |
115 // Now add the URL to that |subfolder1|. | 115 // Now add the URL to that |subfolder1|. |
116 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); | 116 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); |
117 EXPECT_FALSE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile)); | 117 EXPECT_FALSE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile)); |
118 } | 118 } |
119 | 119 |
120 } // namespace | 120 } // namespace |
121 #endif | 121 #endif |
OLD | NEW |