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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 6 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
7 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" | 7 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.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 "content/public/test/test_browser_thread_bundle.h" | 11 #include "content/public/test/test_browser_thread_bundle.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 using base::ASCIIToUTF16; | 14 using base::ASCIIToUTF16; |
15 using bookmarks::BookmarkModel; | 15 using bookmarks::BookmarkModel; |
16 using bookmarks::BookmarkNode; | 16 using bookmarks::BookmarkNode; |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 class BookmarkUIUtilsTest : public testing::Test { | 20 class BookmarkUIUtilsTest : public testing::Test { |
21 content::TestBrowserThreadBundle thread_bundle_; | 21 content::TestBrowserThreadBundle thread_bundle_; |
22 }; | 22 }; |
23 | 23 |
24 TEST_F(BookmarkUIUtilsTest, HasBookmarkURLs) { | 24 TEST_F(BookmarkUIUtilsTest, HasBookmarkURLs) { |
25 scoped_ptr<BookmarkModel> model(bookmarks::TestBookmarkClient::CreateModel()); | 25 std::unique_ptr<BookmarkModel> model( |
| 26 bookmarks::TestBookmarkClient::CreateModel()); |
26 | 27 |
27 std::vector<const BookmarkNode*> nodes; | 28 std::vector<const BookmarkNode*> nodes; |
28 | 29 |
29 // This tests that |nodes| contains an URL. | 30 // This tests that |nodes| contains an URL. |
30 const BookmarkNode* page1 = model->AddURL(model->bookmark_bar_node(), | 31 const BookmarkNode* page1 = model->AddURL(model->bookmark_bar_node(), |
31 0, | 32 0, |
32 ASCIIToUTF16("Google"), | 33 ASCIIToUTF16("Google"), |
33 GURL("http://google.com")); | 34 GURL("http://google.com")); |
34 nodes.push_back(page1); | 35 nodes.push_back(page1); |
35 EXPECT_TRUE(chrome::HasBookmarkURLs(nodes)); | 36 EXPECT_TRUE(chrome::HasBookmarkURLs(nodes)); |
(...skipping 20 matching lines...) Expand all Loading... |
56 | 57 |
57 const BookmarkNode* subfolder1 = | 58 const BookmarkNode* subfolder1 = |
58 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); | 59 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); |
59 | 60 |
60 // Now add the URL to that |subfolder1|. | 61 // Now add the URL to that |subfolder1|. |
61 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); | 62 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); |
62 EXPECT_FALSE(chrome::HasBookmarkURLs(nodes)); | 63 EXPECT_FALSE(chrome::HasBookmarkURLs(nodes)); |
63 } | 64 } |
64 | 65 |
65 TEST_F(BookmarkUIUtilsTest, HasBookmarkURLsAllowedInIncognitoMode) { | 66 TEST_F(BookmarkUIUtilsTest, HasBookmarkURLsAllowedInIncognitoMode) { |
66 scoped_ptr<BookmarkModel> model(bookmarks::TestBookmarkClient::CreateModel()); | 67 std::unique_ptr<BookmarkModel> model( |
| 68 bookmarks::TestBookmarkClient::CreateModel()); |
67 TestingProfile profile; | 69 TestingProfile profile; |
68 | 70 |
69 std::vector<const BookmarkNode*> nodes; | 71 std::vector<const BookmarkNode*> nodes; |
70 | 72 |
71 // This tests that |nodes| contains an disabled-in-incognito URL. | 73 // This tests that |nodes| contains an disabled-in-incognito URL. |
72 const BookmarkNode* page1 = model->AddURL(model->bookmark_bar_node(), | 74 const BookmarkNode* page1 = model->AddURL(model->bookmark_bar_node(), |
73 0, | 75 0, |
74 ASCIIToUTF16("BookmarkManager"), | 76 ASCIIToUTF16("BookmarkManager"), |
75 GURL("chrome://bookmarks")); | 77 GURL("chrome://bookmarks")); |
76 nodes.push_back(page1); | 78 nodes.push_back(page1); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 116 |
115 const BookmarkNode* subfolder1 = | 117 const BookmarkNode* subfolder1 = |
116 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); | 118 model->AddFolder(folder1, 0, ASCIIToUTF16("Subfolder1")); |
117 | 119 |
118 // Now add the URL to that |subfolder1|. | 120 // Now add the URL to that |subfolder1|. |
119 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); | 121 model->AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com")); |
120 EXPECT_FALSE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile)); | 122 EXPECT_FALSE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile)); |
121 } | 123 } |
122 | 124 |
123 } // namespace | 125 } // namespace |
OLD | NEW |