Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: chrome/utility/importer/bookmark_html_reader_unittest.cc

Issue 616763002: Importing certain bookmarks from firefox and HTML file as search engines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replacing custom code by existing function for checking if an url supports replacement terms. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/utility/importer/bookmark_html_reader_unittest.cc
diff --git a/chrome/utility/importer/bookmark_html_reader_unittest.cc b/chrome/utility/importer/bookmark_html_reader_unittest.cc
index fd68f5470fafb05c2d629ca4c4c881baebb286f8..6552e792e976e4e5696cbd104b8fed68f53e9234 100644
--- a/chrome/utility/importer/bookmark_html_reader_unittest.cc
+++ b/chrome/utility/importer/bookmark_html_reader_unittest.cc
@@ -152,6 +152,10 @@ class BookmarkHTMLReaderTestWithData : public testing::Test {
void ExpectFirstFirefox23Bookmark(const ImportedBookmarkEntry& entry);
void ExpectSecondFirefox23Bookmark(const ImportedBookmarkEntry& entry);
void ExpectThirdFirefox23Bookmark(const ImportedBookmarkEntry& entry);
+ void ExpectFirstFirefoxBookmarkWithKeyword(
+ const importer::SearchEngineInfo& info);
+ void ExpectSecondFirefoxBookmarkWithKeyword(
+ const importer::SearchEngineInfo& info);
base::FilePath test_data_path_;
};
@@ -236,6 +240,20 @@ void BookmarkHTMLReaderTestWithData::ExpectThirdFirefox23Bookmark(
EXPECT_EQ("http://code.google.com/p/chromium/codesearch", entry.url.spec());
}
+void BookmarkHTMLReaderTestWithData::ExpectFirstFirefoxBookmarkWithKeyword(
+ const importer::SearchEngineInfo& info) {
+ EXPECT_EQ(ASCIIToUTF16("http://example.%s.com/"), info.url);
+ EXPECT_EQ(ASCIIToUTF16("keyword"), info.keyword);
+ EXPECT_EQ(ASCIIToUTF16("Bookmark Keyword"), info.display_name);
+}
+
+void BookmarkHTMLReaderTestWithData::ExpectSecondFirefoxBookmarkWithKeyword(
+ const importer::SearchEngineInfo& info) {
+ EXPECT_EQ(ASCIIToUTF16("http://example.com/?q=%s"), info.url);
+ EXPECT_EQ(ASCIIToUTF16("keyword"), info.keyword);
+ EXPECT_EQ(ASCIIToUTF16("BookmarkName"), info.display_name);
+}
+
} // namespace
TEST_F(BookmarkHTMLReaderTestWithData, Firefox2BookmarkFileImport) {
@@ -244,7 +262,7 @@ TEST_F(BookmarkHTMLReaderTestWithData, Firefox2BookmarkFileImport) {
std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(),
base::Callback<bool(const GURL&)>(),
- path, &bookmarks, NULL);
+ path, &bookmarks, NULL, NULL);
ASSERT_EQ(3U, bookmarks.size());
ExpectFirstFirefox2Bookmark(bookmarks[0]);
@@ -258,7 +276,7 @@ TEST_F(BookmarkHTMLReaderTestWithData, BookmarkFileWithHrTagImport) {
std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(),
base::Callback<bool(const GURL&)>(),
- path, &bookmarks, NULL);
+ path, &bookmarks, NULL, NULL);
ASSERT_EQ(3U, bookmarks.size());
ExpectFirstFirefox23Bookmark(bookmarks[0]);
@@ -272,13 +290,27 @@ TEST_F(BookmarkHTMLReaderTestWithData, EpiphanyBookmarkFileImport) {
std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(),
base::Callback<bool(const GURL&)>(),
- path, &bookmarks, NULL);
+ path, &bookmarks, NULL, NULL);
ASSERT_EQ(2U, bookmarks.size());
ExpectFirstEpiphanyBookmark(bookmarks[0]);
ExpectSecondEpiphanyBookmark(bookmarks[1]);
}
+TEST_F(BookmarkHTMLReaderTestWithData, FirefoxBookmarkFileWithKeywordImport) {
+ base::FilePath path = test_data_path_.AppendASCII(
+ "firefox_bookmark_keyword.html");
+
+ std::vector<importer::SearchEngineInfo> search_engines;
+ ImportBookmarksFile(base::Callback<bool(void)>(),
+ base::Callback<bool(const GURL&)>(),
+ path, NULL, &search_engines, NULL);
+
+ ASSERT_EQ(2U, search_engines.size());
+ ExpectFirstFirefoxBookmarkWithKeyword(search_engines[0]);
+ ExpectSecondFirefoxBookmarkWithKeyword(search_engines[1]);
+}
+
namespace {
class CancelAfterFifteenCalls {
@@ -301,7 +333,7 @@ TEST_F(BookmarkHTMLReaderTestWithData, CancellationCallback) {
ImportBookmarksFile(base::Bind(&CancelAfterFifteenCalls::ShouldCancel,
base::Unretained(&cancel_fifteen)),
base::Callback<bool(const GURL&)>(),
- path, &bookmarks, NULL);
+ path, &bookmarks, NULL, NULL);
// The cancellation callback is checked before each line is read, so fifteen
// lines are imported. The first fifteen lines of firefox2.html include only
@@ -311,7 +343,6 @@ TEST_F(BookmarkHTMLReaderTestWithData, CancellationCallback) {
}
namespace {
Ilya Sherman 2014/11/07 00:22:34 nit: Please restore the newline after this line.
Tapu Ghose 2014/11/09 14:03:07 Done.
-
bool IsURLValid(const GURL& url) {
// No offense to whomever owns this domain...
return !url.DomainIs("tamurayukari.com");
@@ -326,7 +357,7 @@ TEST_F(BookmarkHTMLReaderTestWithData, ValidURLCallback) {
std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(),
base::Bind(&IsURLValid),
- path, &bookmarks, NULL);
+ path, &bookmarks, NULL, NULL);
ASSERT_EQ(2U, bookmarks.size());
ExpectFirstFirefox2Bookmark(bookmarks[0]);

Powered by Google App Engine
This is Rietveld 408576698