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

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

Issue 22408007: Remove "<HR>" tags to import Firefox bookmarks correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comment. Created 7 years, 4 months 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 72f42cf52bae9db26b5c65e6e7f9bc0119c8cb8f..2ccbd67b0c2b6747f8a8b591b61418cb5c4726f8 100644
--- a/chrome/utility/importer/bookmark_html_reader_unittest.cc
+++ b/chrome/utility/importer/bookmark_html_reader_unittest.cc
@@ -134,9 +134,43 @@ TEST(BookmarkHTMLReaderTest, ParseTests) {
EXPECT_EQ("http://www.google.com/", url.spec());
}
-namespace {
+class BookmarkHTMLReaderTestWithData : public testing::Test {
gab 2013/08/12 14:17:41 Put the fixture in the unnamed namespace.
zhchbin 2013/08/12 14:42:09 Done.
+ public:
+ BookmarkHTMLReaderTestWithData() {}
gab 2013/08/12 14:17:41 Don't need this empty constructor.
zhchbin 2013/08/12 14:42:09 Done.
+
+ virtual void SetUp() OVERRIDE;
+
+ protected:
+ class CancelAfterFifteenCalls {
+ int count;
+ public:
+ CancelAfterFifteenCalls() : count(0) { }
+ bool ShouldCancel() {
+ return ++count > 16;
+ }
+ };
+
+ void ExpectFirstFirefox2Bookmark(const ImportedBookmarkEntry& entry);
+ void ExpectSecondFirefox2Bookmark(const ImportedBookmarkEntry& entry);
+ void ExpectThirdFirefox2Bookmark(const ImportedBookmarkEntry& entry);
+ void ExpectFirstEpiphanyBookmark(const ImportedBookmarkEntry& entry);
+ void ExpectSecondEpiphanyBookmark(const ImportedBookmarkEntry& entry);
+ void ExpectFirstFirefox23Bookmark(const ImportedBookmarkEntry& entry);
+ void ExpectSecondFirefox23Bookmark(const ImportedBookmarkEntry& entry);
+ void ExpectThirdFirefox23Bookmark(const ImportedBookmarkEntry& entry);
+
+ static bool IsURLValid(const GURL& url);
+
+ base::FilePath test_data_path_;
+};
-void ExpectFirstFirefox2Bookmark(const ImportedBookmarkEntry& entry) {
+void BookmarkHTMLReaderTestWithData::SetUp() {
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_path_));
+ test_data_path_ = test_data_path_.AppendASCII("bookmark_html_reader");
+}
+
+void BookmarkHTMLReaderTestWithData::ExpectFirstFirefox2Bookmark(
+ const ImportedBookmarkEntry& entry) {
EXPECT_EQ(ASCIIToUTF16("Empty"), entry.title);
EXPECT_TRUE(entry.is_folder);
EXPECT_EQ(base::Time::FromTimeT(1295938143), entry.creation_time);
@@ -145,7 +179,8 @@ void ExpectFirstFirefox2Bookmark(const ImportedBookmarkEntry& entry) {
EXPECT_EQ(ASCIIToUTF16("Empty's Parent"), entry.path.front());
}
-void ExpectSecondFirefox2Bookmark(const ImportedBookmarkEntry& entry) {
+void BookmarkHTMLReaderTestWithData::ExpectSecondFirefox2Bookmark(
+ const ImportedBookmarkEntry& entry) {
EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title);
EXPECT_FALSE(entry.is_folder);
EXPECT_EQ(base::Time::FromTimeT(1234567890), entry.creation_time);
@@ -155,7 +190,8 @@ void ExpectSecondFirefox2Bookmark(const ImportedBookmarkEntry& entry) {
EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec());
}
-void ExpectThirdFirefox2Bookmark(const ImportedBookmarkEntry& entry) {
+void BookmarkHTMLReaderTestWithData::ExpectThirdFirefox2Bookmark(
+ const ImportedBookmarkEntry& entry) {
EXPECT_EQ(ASCIIToUTF16("Google"), entry.title);
EXPECT_FALSE(entry.is_folder);
EXPECT_EQ(base::Time::FromTimeT(0000000000), entry.creation_time);
@@ -165,25 +201,57 @@ void ExpectThirdFirefox2Bookmark(const ImportedBookmarkEntry& entry) {
EXPECT_EQ("http://www.google.com/", entry.url.spec());
}
-void ExpectFirstEpiphanyBookmark(const ImportedBookmarkEntry& entry) {
+void BookmarkHTMLReaderTestWithData::ExpectFirstEpiphanyBookmark(
+ const ImportedBookmarkEntry& entry) {
EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title);
EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec());
EXPECT_EQ(0U, entry.path.size());
}
-void ExpectSecondEpiphanyBookmark(const ImportedBookmarkEntry& entry) {
+void BookmarkHTMLReaderTestWithData::ExpectSecondEpiphanyBookmark(
+ const ImportedBookmarkEntry& entry) {
EXPECT_EQ(ASCIIToUTF16("Google"), entry.title);
EXPECT_EQ("http://www.google.com/", entry.url.spec());
EXPECT_EQ(0U, entry.path.size());
}
-} // namespace
+void BookmarkHTMLReaderTestWithData::ExpectFirstFirefox23Bookmark(
+ const ImportedBookmarkEntry& entry) {
+ EXPECT_EQ(ASCIIToUTF16("Google"), entry.title);
+ EXPECT_FALSE(entry.is_folder);
+ EXPECT_EQ(base::Time::FromTimeT(1376102167), entry.creation_time);
+ EXPECT_EQ(0U, entry.path.size());
+ EXPECT_EQ("https://www.google.com/", entry.url.spec());
+}
+
+void BookmarkHTMLReaderTestWithData::ExpectSecondFirefox23Bookmark(
+ const ImportedBookmarkEntry& entry) {
+ EXPECT_EQ(ASCIIToUTF16("Issues"), entry.title);
+ EXPECT_FALSE(entry.is_folder);
+ EXPECT_EQ(base::Time::FromTimeT(1376102304), entry.creation_time);
+ EXPECT_EQ(1U, entry.path.size());
+ EXPECT_EQ(ASCIIToUTF16("Chromium"), entry.path.front());
+ EXPECT_EQ("https://code.google.com/p/chromium/issues/list", entry.url.spec());
+}
+
+void BookmarkHTMLReaderTestWithData::ExpectThirdFirefox23Bookmark(
+ const ImportedBookmarkEntry& entry) {
+ EXPECT_EQ(ASCIIToUTF16("CodeSearch"), entry.title);
+ EXPECT_FALSE(entry.is_folder);
+ EXPECT_EQ(base::Time::FromTimeT(1376102224), entry.creation_time);
+ EXPECT_EQ(1U, entry.path.size());
+ EXPECT_EQ(ASCIIToUTF16("Chromium"), entry.path.front());
+ EXPECT_EQ("http://code.google.com/p/chromium/codesearch", entry.url.spec());
+}
+
+// static
+bool BookmarkHTMLReaderTestWithData::IsURLValid(const GURL& url) {
+ // No offense to whomever owns this domain...
+ return !url.DomainIs("tamurayukari.com");
+}
-TEST(BookmarkHTMLReaderTest, Firefox2BookmarkFileImport) {
- base::FilePath path;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
- path = path.AppendASCII("bookmark_html_reader");
- path = path.AppendASCII("firefox2.html");
+TEST_F(BookmarkHTMLReaderTestWithData, Firefox2BookmarkFileImport) {
+ base::FilePath path = test_data_path_.AppendASCII("firefox2.html");
std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(),
@@ -196,41 +264,36 @@ TEST(BookmarkHTMLReaderTest, Firefox2BookmarkFileImport) {
ExpectThirdFirefox2Bookmark(bookmarks[2]);
}
-TEST(BookmarkHTMLReaderTest, EpiphanyBookmarkFileImport) {
- base::FilePath path;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
- path = path.AppendASCII("bookmark_html_reader");
- path = path.AppendASCII("epiphany.html");
+TEST_F(BookmarkHTMLReaderTestWithData, BookmarkFileWithHrTagImport) {
+ base::FilePath path = test_data_path_.AppendASCII("firefox23.html");
std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(),
base::Callback<bool(const GURL&)>(),
path, &bookmarks, NULL);
- ASSERT_EQ(2U, bookmarks.size());
- ExpectFirstEpiphanyBookmark(bookmarks[0]);
- ExpectSecondEpiphanyBookmark(bookmarks[1]);
+ ASSERT_EQ(3U, bookmarks.size());
+ ExpectFirstFirefox23Bookmark(bookmarks[0]);
+ ExpectSecondFirefox23Bookmark(bookmarks[1]);
+ ExpectThirdFirefox23Bookmark(bookmarks[2]);
}
-namespace {
+TEST_F(BookmarkHTMLReaderTestWithData, EpiphanyBookmarkFileImport) {
+ base::FilePath path = test_data_path_.AppendASCII("epiphany.html");
-class CancelAfterFifteenCalls {
gab 2013/08/12 14:17:41 I like to have this beside the test that uses it..
zhchbin 2013/08/12 14:42:09 Done.
- int count;
- public:
- CancelAfterFifteenCalls() : count(0) { }
- bool ShouldCancel() {
- return ++count > 16;
- }
-};
+ std::vector<ImportedBookmarkEntry> bookmarks;
+ ImportBookmarksFile(base::Callback<bool(void)>(),
+ base::Callback<bool(const GURL&)>(),
+ path, &bookmarks, NULL);
-} // namespace
+ ASSERT_EQ(2U, bookmarks.size());
+ ExpectFirstEpiphanyBookmark(bookmarks[0]);
+ ExpectSecondEpiphanyBookmark(bookmarks[1]);
+}
-TEST(BookmarkHTMLReaderTest, CancellationCallback) {
- base::FilePath path;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
- path = path.AppendASCII("bookmark_html_reader");
+TEST_F(BookmarkHTMLReaderTestWithData, CancellationCallback) {
// Use a file for testing that has multiple bookmarks.
- path = path.AppendASCII("firefox2.html");
+ base::FilePath path = test_data_path_.AppendASCII("firefox2.html");
std::vector<ImportedBookmarkEntry> bookmarks;
CancelAfterFifteenCalls cancel_fifteen;
@@ -246,21 +309,9 @@ TEST(BookmarkHTMLReaderTest, CancellationCallback) {
ExpectFirstFirefox2Bookmark(bookmarks[0]);
}
-namespace {
-
-bool IsURLValid(const GURL& url) {
gab 2013/08/12 14:17:41 I like to have this beside the test that uses it..
zhchbin 2013/08/12 14:42:09 Done.
- // No offense to whomever owns this domain...
- return !url.DomainIs("tamurayukari.com");
-}
-
-} // namespace
-
-TEST(BookmarkHTMLReaderTest, ValidURLCallback) {
- base::FilePath path;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
- path = path.AppendASCII("bookmark_html_reader");
+TEST_F(BookmarkHTMLReaderTestWithData, ValidURLCallback) {
// Use a file for testing that has multiple bookmarks.
- path = path.AppendASCII("firefox2.html");
+ base::FilePath path = test_data_path_.AppendASCII("firefox2.html");
std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(),

Powered by Google App Engine
This is Rietveld 408576698