This source file includes following definitions.
- TEST
- TEST
#include "chrome/browser/ui/bookmarks/bookmark_utils.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
#if !defined(OS_ANDROID) && !defined(OS_IOS)
using base::ASCIIToUTF16;
namespace {
TEST(BookmarkUIUtilsTest, HasBookmarkURLs) {
BookmarkModel model(NULL);
std::vector<const BookmarkNode*> nodes;
const BookmarkNode* page1 = model.AddURL(model.bookmark_bar_node(), 0,
ASCIIToUTF16("Google"),
GURL("http://google.com"));
nodes.push_back(page1);
EXPECT_TRUE(chrome::HasBookmarkURLs(nodes));
nodes.clear();
const BookmarkNode* folder1 = model.AddFolder(model.bookmark_bar_node(), 0,
ASCIIToUTF16("Folder1"));
nodes.push_back(folder1);
EXPECT_FALSE(chrome::HasBookmarkURLs(nodes));
model.AddURL(folder1, 0, ASCIIToUTF16("Foo"), GURL("http://randomsite.com"));
EXPECT_TRUE(chrome::HasBookmarkURLs(nodes));
model.Remove(folder1, 0);
const BookmarkNode* subfolder1 = model.AddFolder(folder1, 0,
ASCIIToUTF16("Subfolder1"));
model.AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com"));
EXPECT_FALSE(chrome::HasBookmarkURLs(nodes));
}
TEST(BookmarkUIUtilsTest, HasBookmarkURLsAllowedInIncognitoMode) {
BookmarkModel model(NULL);
TestingProfile profile;
std::vector<const BookmarkNode*> nodes;
const BookmarkNode* page1 = model.AddURL(model.bookmark_bar_node(), 0,
ASCIIToUTF16("BookmarkManager"),
GURL("chrome://bookmarks"));
nodes.push_back(page1);
EXPECT_FALSE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile));
nodes.clear();
const BookmarkNode* page2 = model.AddURL(model.bookmark_bar_node(), 0,
ASCIIToUTF16("Google"),
GURL("http://google.com"));
nodes.push_back(page2);
EXPECT_TRUE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile));
nodes.clear();
const BookmarkNode* folder1 = model.AddFolder(model.bookmark_bar_node(), 0,
ASCIIToUTF16("Folder1"));
nodes.push_back(folder1);
EXPECT_FALSE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile));
model.AddURL(folder1, 0, ASCIIToUTF16("Foo"), GURL("chrome://bookmarks"));
EXPECT_FALSE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile));
model.AddURL(folder1, 0, ASCIIToUTF16("Foo"), GURL("http://randomsite.com"));
EXPECT_TRUE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile));
model.Remove(folder1, 0);
const BookmarkNode* subfolder1 = model.AddFolder(folder1, 0,
ASCIIToUTF16("Subfolder1"));
model.AddURL(subfolder1, 0, ASCIIToUTF16("BAR"), GURL("http://bar-foo.com"));
EXPECT_FALSE(chrome::HasBookmarkURLsAllowedInIncognitoMode(nodes, &profile));
}
}
#endif