Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/utility/importer/bookmark_html_reader.h" | 5 #include "chrome/utility/importer/bookmark_html_reader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ExpectSecondEpiphanyBookmark(const ImportedBookmarkEntry& entry) { | 174 void ExpectSecondEpiphanyBookmark(const ImportedBookmarkEntry& entry) { |
| 175 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); | 175 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); |
| 176 EXPECT_EQ("http://www.google.com/", entry.url.spec()); | 176 EXPECT_EQ("http://www.google.com/", entry.url.spec()); |
| 177 EXPECT_EQ(0U, entry.path.size()); | 177 EXPECT_EQ(0U, entry.path.size()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace | 180 } // namespace |
| 181 | 181 |
| 182 TEST(BookmarkHTMLReaderTest, Firefox2BookmarkFileImport) { | 182 TEST(BookmarkHTMLReaderTest, Firefox2BookmarkFileImport) { |
|
gab
2013/08/09 13:27:30
Make all the BookmarkHTMLReaderTest here and below
zhchbin
2013/08/09 14:20:00
I will finish it as soon as I can. Thanks for the
| |
| 183 base::FilePath path; | 183 base::FilePath path; |
| 184 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); | 184 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); |
| 185 path = path.AppendASCII("bookmark_html_reader"); | 185 path = path.AppendASCII("bookmark_html_reader"); |
| 186 path = path.AppendASCII("firefox2.html"); | 186 path = path.AppendASCII("firefox2.html"); |
| 187 | 187 |
| 188 std::vector<ImportedBookmarkEntry> bookmarks; | 188 std::vector<ImportedBookmarkEntry> bookmarks; |
| 189 ImportBookmarksFile(base::Callback<bool(void)>(), | 189 ImportBookmarksFile(base::Callback<bool(void)>(), |
| 190 base::Callback<bool(const GURL&)>(), | 190 base::Callback<bool(const GURL&)>(), |
| 191 path, &bookmarks, NULL); | 191 path, &bookmarks, NULL); |
| 192 | 192 |
| 193 ASSERT_EQ(3U, bookmarks.size()); | 193 ASSERT_EQ(3U, bookmarks.size()); |
| 194 ExpectFirstFirefox2Bookmark(bookmarks[0]); | 194 ExpectFirstFirefox2Bookmark(bookmarks[0]); |
| 195 ExpectSecondFirefox2Bookmark(bookmarks[1]); | 195 ExpectSecondFirefox2Bookmark(bookmarks[1]); |
| 196 ExpectThirdFirefox2Bookmark(bookmarks[2]); | 196 ExpectThirdFirefox2Bookmark(bookmarks[2]); |
| 197 } | 197 } |
| 198 | 198 |
| 199 TEST(BookmarkHTMLReaderTest, BookmarkFileWithHrTagImport) { | |
| 200 base::FilePath path; | |
| 201 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); | |
| 202 path = path.AppendASCII("bookmark_html_reader"); | |
| 203 path = path.AppendASCII("firefox3.html"); | |
| 204 | |
| 205 std::vector<ImportedBookmarkEntry> bookmarks; | |
| 206 ImportBookmarksFile(base::Callback<bool(void)>(), | |
| 207 base::Callback<bool(const GURL&)>(), | |
| 208 path, &bookmarks, NULL); | |
| 209 | |
| 210 ASSERT_EQ(7U, bookmarks.size()); | |
|
gab
2013/08/09 13:27:30
Can you also verify the bookmarks' contents like t
zhchbin
2013/08/09 14:20:00
I mean to keep this test case simple and only test
gab
2013/08/09 14:29:03
Well, from knowing the implementation, we know tha
| |
| 211 } | |
| 212 | |
| 199 TEST(BookmarkHTMLReaderTest, EpiphanyBookmarkFileImport) { | 213 TEST(BookmarkHTMLReaderTest, EpiphanyBookmarkFileImport) { |
| 200 base::FilePath path; | 214 base::FilePath path; |
| 201 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); | 215 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); |
| 202 path = path.AppendASCII("bookmark_html_reader"); | 216 path = path.AppendASCII("bookmark_html_reader"); |
| 203 path = path.AppendASCII("epiphany.html"); | 217 path = path.AppendASCII("epiphany.html"); |
| 204 | 218 |
| 205 std::vector<ImportedBookmarkEntry> bookmarks; | 219 std::vector<ImportedBookmarkEntry> bookmarks; |
| 206 ImportBookmarksFile(base::Callback<bool(void)>(), | 220 ImportBookmarksFile(base::Callback<bool(void)>(), |
| 207 base::Callback<bool(const GURL&)>(), | 221 base::Callback<bool(const GURL&)>(), |
| 208 path, &bookmarks, NULL); | 222 path, &bookmarks, NULL); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 ImportBookmarksFile(base::Callback<bool(void)>(), | 280 ImportBookmarksFile(base::Callback<bool(void)>(), |
| 267 base::Bind(&IsURLValid), | 281 base::Bind(&IsURLValid), |
| 268 path, &bookmarks, NULL); | 282 path, &bookmarks, NULL); |
| 269 | 283 |
| 270 ASSERT_EQ(2U, bookmarks.size()); | 284 ASSERT_EQ(2U, bookmarks.size()); |
| 271 ExpectFirstFirefox2Bookmark(bookmarks[0]); | 285 ExpectFirstFirefox2Bookmark(bookmarks[0]); |
| 272 ExpectThirdFirefox2Bookmark(bookmarks[1]); | 286 ExpectThirdFirefox2Bookmark(bookmarks[1]); |
| 273 } | 287 } |
| 274 | 288 |
| 275 } // namespace bookmark_html_reader | 289 } // namespace bookmark_html_reader |
| OLD | NEW |