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