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