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