OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // The order of these includes is important. | 5 // The order of these includes is important. |
6 #include <windows.h> | 6 #include <windows.h> |
7 #include <unknwn.h> | 7 #include <unknwn.h> |
8 #include <intshcut.h> | 8 #include <intshcut.h> |
9 #include <propvarutil.h> | 9 #include <propvarutil.h> |
10 #include <shlguid.h> | 10 #include <shlguid.h> |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 history_count_(0), | 229 history_count_(0), |
230 password_count_(0), | 230 password_count_(0), |
231 favicon_count_(0), | 231 favicon_count_(0), |
232 homepage_count_(0), | 232 homepage_count_(0), |
233 ie7_password_count_(0), | 233 ie7_password_count_(0), |
234 importer_items_(importer_items), | 234 importer_items_(importer_items), |
235 ie_version_(ie_version) { | 235 ie_version_(ie_version) { |
236 } | 236 } |
237 | 237 |
238 // importer::ImporterProgressObserver: | 238 // importer::ImporterProgressObserver: |
239 virtual void ImportStarted() override {} | 239 void ImportStarted() override {} |
240 virtual void ImportItemStarted(importer::ImportItem item) override {} | 240 void ImportItemStarted(importer::ImportItem item) override {} |
241 virtual void ImportItemEnded(importer::ImportItem item) override {} | 241 void ImportItemEnded(importer::ImportItem item) override {} |
242 virtual void ImportEnded() override { | 242 void ImportEnded() override { |
243 base::MessageLoop::current()->Quit(); | 243 base::MessageLoop::current()->Quit(); |
244 if (importer_items_ & importer::FAVORITES) { | 244 if (importer_items_ & importer::FAVORITES) { |
245 EXPECT_EQ(arraysize(kIEBookmarks), bookmark_count_); | 245 EXPECT_EQ(arraysize(kIEBookmarks), bookmark_count_); |
246 EXPECT_EQ(arraysize(kIEFaviconGroup), favicon_count_); | 246 EXPECT_EQ(arraysize(kIEFaviconGroup), favicon_count_); |
247 } | 247 } |
248 if (importer_items_ & importer::HISTORY) | 248 if (importer_items_ & importer::HISTORY) |
249 EXPECT_EQ(2, history_count_); | 249 EXPECT_EQ(2, history_count_); |
250 if (importer_items_ & importer::HOME_PAGE) | 250 if (importer_items_ & importer::HOME_PAGE) |
251 EXPECT_EQ(1, homepage_count_); | 251 EXPECT_EQ(1, homepage_count_); |
252 if ((importer_items_ & importer::PASSWORDS) && (ie_version_ == IE7)) | 252 if ((importer_items_ & importer::PASSWORDS) && (ie_version_ == IE7)) |
253 EXPECT_EQ(1, ie7_password_count_); | 253 EXPECT_EQ(1, ie7_password_count_); |
254 // We need to test the IE6 password importer code. | 254 // We need to test the IE6 password importer code. |
255 // https://crbug.com/257100 | 255 // https://crbug.com/257100 |
256 // EXPECT_EQ(1, password_count_); | 256 // EXPECT_EQ(1, password_count_); |
257 } | 257 } |
258 | 258 |
259 virtual bool BookmarkModelIsLoaded() const { | 259 // ProfileWriter: |
260 bool BookmarkModelIsLoaded() const override { | |
260 // Profile is ready for writing. | 261 // Profile is ready for writing. |
261 return true; | 262 return true; |
262 } | 263 } |
263 | 264 |
264 virtual bool TemplateURLServiceIsLoaded() const { | 265 bool TemplateURLServiceIsLoaded() const override { |
265 return true; | 266 return true; |
266 } | 267 } |
267 | 268 |
268 virtual void AddPasswordForm(const autofill::PasswordForm& form) { | 269 void AddPasswordForm(const autofill::PasswordForm& form) override { |
269 // Importer should obtain this password form only. | 270 // Importer should obtain this password form only. |
270 EXPECT_EQ(GURL("http://localhost:8080/security/index.htm"), form.origin); | 271 EXPECT_EQ(GURL("http://localhost:8080/security/index.htm"), form.origin); |
271 EXPECT_EQ("http://localhost:8080/", form.signon_realm); | 272 EXPECT_EQ("http://localhost:8080/", form.signon_realm); |
272 EXPECT_EQ(L"user", form.username_element); | 273 EXPECT_EQ(L"user", form.username_element); |
273 EXPECT_EQ(L"1", form.username_value); | 274 EXPECT_EQ(L"1", form.username_value); |
274 EXPECT_EQ(L"", form.password_element); | 275 EXPECT_EQ(L"", form.password_element); |
275 EXPECT_EQ(L"2", form.password_value); | 276 EXPECT_EQ(L"2", form.password_value); |
276 EXPECT_EQ("", form.action.spec()); | 277 EXPECT_EQ("", form.action.spec()); |
277 ++password_count_; | 278 ++password_count_; |
278 } | 279 } |
279 | 280 |
280 virtual void AddHistoryPage(const history::URLRows& page, | 281 void AddHistoryPage(const history::URLRows& page, |
281 history::VisitSource visit_source) { | 282 history::VisitSource visit_source) override { |
282 bool cache_item_found = false; | 283 bool cache_item_found = false; |
283 bool history_item_found = false; | 284 bool history_item_found = false; |
284 // Importer should read the specified URL. | 285 // Importer should read the specified URL. |
285 for (size_t i = 0; i < page.size(); ++i) { | 286 for (size_t i = 0; i < page.size(); ++i) { |
286 if (page[i].title() == kIEIdentifyTitle && | 287 if (page[i].title() == kIEIdentifyTitle && |
287 page[i].url() == GURL(kIEIdentifyUrl)) { | 288 page[i].url() == GURL(kIEIdentifyUrl)) { |
288 EXPECT_FALSE(page[i].hidden()); | 289 EXPECT_FALSE(page[i].hidden()); |
289 history_item_found = true; | 290 history_item_found = true; |
290 ++history_count_; | 291 ++history_count_; |
291 } | 292 } |
292 if (page[i].title() == kIECacheItemTitle && | 293 if (page[i].title() == kIECacheItemTitle && |
293 page[i].url() == GURL(kIECacheItemUrl)) { | 294 page[i].url() == GURL(kIECacheItemUrl)) { |
294 EXPECT_TRUE(page[i].hidden()); | 295 EXPECT_TRUE(page[i].hidden()); |
295 cache_item_found = true; | 296 cache_item_found = true; |
296 ++history_count_; | 297 ++history_count_; |
297 } | 298 } |
298 } | 299 } |
299 EXPECT_TRUE(history_item_found); | 300 EXPECT_TRUE(history_item_found); |
300 EXPECT_TRUE(cache_item_found); | 301 EXPECT_TRUE(cache_item_found); |
301 EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_source); | 302 EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_source); |
302 } | 303 } |
303 | 304 |
304 virtual void AddBookmarks( | 305 void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks, |
305 const std::vector<ImportedBookmarkEntry>& bookmarks, | 306 const base::string16& top_level_folder_name) override { |
306 const base::string16& top_level_folder_name) override { | |
307 ASSERT_LE(bookmark_count_ + bookmarks.size(), arraysize(kIEBookmarks)); | 307 ASSERT_LE(bookmark_count_ + bookmarks.size(), arraysize(kIEBookmarks)); |
308 // Importer should import the IE Favorites folder the same as the list, | 308 // Importer should import the IE Favorites folder the same as the list, |
309 // in the same order. | 309 // in the same order. |
310 for (size_t i = 0; i < bookmarks.size(); ++i) { | 310 for (size_t i = 0; i < bookmarks.size(); ++i) { |
311 EXPECT_NO_FATAL_FAILURE( | 311 EXPECT_NO_FATAL_FAILURE( |
312 TestEqualBookmarkEntry(bookmarks[i], | 312 TestEqualBookmarkEntry(bookmarks[i], |
313 kIEBookmarks[bookmark_count_])) << i; | 313 kIEBookmarks[bookmark_count_])) << i; |
314 ++bookmark_count_; | 314 ++bookmark_count_; |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 virtual void AddKeyword(std::vector<TemplateURL*> template_url, | 318 virtual void AddKeyword(std::vector<TemplateURL*> template_url, |
319 int default_keyword_index) { | 319 int default_keyword_index) { |
320 // TODO(jcampan): bug 1169230: we should test keyword importing for IE. | 320 // TODO(jcampan): bug 1169230: we should test keyword importing for IE. |
321 // In order to do that we'll probably need to mock the Windows registry. | 321 // In order to do that we'll probably need to mock the Windows registry. |
322 NOTREACHED(); | 322 NOTREACHED(); |
323 STLDeleteContainerPointers(template_url.begin(), template_url.end()); | 323 STLDeleteContainerPointers(template_url.begin(), template_url.end()); |
324 } | 324 } |
325 | 325 |
326 virtual void AddFavicons( | 326 void AddFavicons(const favicon_base::FaviconUsageDataList& usage) override { |
327 const favicon_base::FaviconUsageDataList& usage) override { | |
328 // Importer should group the favicon information for each favicon URL. | 327 // Importer should group the favicon information for each favicon URL. |
329 for (size_t i = 0; i < arraysize(kIEFaviconGroup); ++i) { | 328 for (size_t i = 0; i < arraysize(kIEFaviconGroup); ++i) { |
330 GURL favicon_url(kIEFaviconGroup[i].favicon_url); | 329 GURL favicon_url(kIEFaviconGroup[i].favicon_url); |
331 std::set<GURL> urls; | 330 std::set<GURL> urls; |
332 for (size_t j = 0; j < arraysize(kIEFaviconGroup[i].site_url); ++j) | 331 for (size_t j = 0; j < arraysize(kIEFaviconGroup[i].site_url); ++j) |
333 urls.insert(GURL(kIEFaviconGroup[i].site_url[j])); | 332 urls.insert(GURL(kIEFaviconGroup[i].site_url[j])); |
334 | 333 |
335 SCOPED_TRACE(testing::Message() << "Expected Favicon: " << favicon_url); | 334 SCOPED_TRACE(testing::Message() << "Expected Favicon: " << favicon_url); |
336 | 335 |
337 bool expected_favicon_url_found = false; | 336 bool expected_favicon_url_found = false; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 | 377 |
379 class MalformedFavoritesRegistryTestObserver | 378 class MalformedFavoritesRegistryTestObserver |
380 : public ProfileWriter, | 379 : public ProfileWriter, |
381 public importer::ImporterProgressObserver { | 380 public importer::ImporterProgressObserver { |
382 public: | 381 public: |
383 MalformedFavoritesRegistryTestObserver() : ProfileWriter(NULL) { | 382 MalformedFavoritesRegistryTestObserver() : ProfileWriter(NULL) { |
384 bookmark_count_ = 0; | 383 bookmark_count_ = 0; |
385 } | 384 } |
386 | 385 |
387 // importer::ImporterProgressObserver: | 386 // importer::ImporterProgressObserver: |
388 virtual void ImportStarted() override {} | 387 void ImportStarted() override {} |
389 virtual void ImportItemStarted(importer::ImportItem item) override {} | 388 void ImportItemStarted(importer::ImportItem item) override {} |
390 virtual void ImportItemEnded(importer::ImportItem item) override {} | 389 void ImportItemEnded(importer::ImportItem item) override {} |
391 virtual void ImportEnded() override { | 390 void ImportEnded() override { |
392 base::MessageLoop::current()->Quit(); | 391 base::MessageLoop::current()->Quit(); |
393 EXPECT_EQ(arraysize(kIESortedBookmarks), bookmark_count_); | 392 EXPECT_EQ(arraysize(kIESortedBookmarks), bookmark_count_); |
394 } | 393 } |
395 | 394 |
396 virtual bool BookmarkModelIsLoaded() const { return true; } | 395 // ProfileWriter: |
397 virtual bool TemplateURLServiceIsLoaded() const { return true; } | 396 bool BookmarkModelIsLoaded() const override { return true; } |
397 bool TemplateURLServiceIsLoaded() const override { return true; } | |
398 | 398 |
399 virtual void AddPasswordForm(const autofill::PasswordForm& form) {} | 399 void AddPasswordForm(const autofill::PasswordForm& form) override {} |
400 virtual void AddHistoryPage(const history::URLRows& page, | 400 void AddHistoryPage(const history::URLRows& page, |
401 history::VisitSource visit_source) {} | 401 history::VisitSource visit_source) override {} |
402 virtual void AddKeyword(std::vector<TemplateURL*> template_url, | 402 void AddKeywords(ScopedVector<TemplateURL> template_urls, |
Nico
2015/04/24 17:58:18
oops! nice
| |
403 int default_keyword_index) {} | 403 bool unique_on_host_and_path) override {} |
404 virtual void AddBookmarks( | 404 void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks, |
405 const std::vector<ImportedBookmarkEntry>& bookmarks, | 405 const base::string16& top_level_folder_name) override { |
406 const base::string16& top_level_folder_name) override { | |
407 ASSERT_LE(bookmark_count_ + bookmarks.size(), | 406 ASSERT_LE(bookmark_count_ + bookmarks.size(), |
408 arraysize(kIESortedBookmarks)); | 407 arraysize(kIESortedBookmarks)); |
409 for (size_t i = 0; i < bookmarks.size(); ++i) { | 408 for (size_t i = 0; i < bookmarks.size(); ++i) { |
410 EXPECT_NO_FATAL_FAILURE( | 409 EXPECT_NO_FATAL_FAILURE( |
411 TestEqualBookmarkEntry(bookmarks[i], | 410 TestEqualBookmarkEntry(bookmarks[i], |
412 kIESortedBookmarks[bookmark_count_])) << i; | 411 kIESortedBookmarks[bookmark_count_])) << i; |
413 ++bookmark_count_; | 412 ++bookmark_count_; |
414 } | 413 } |
415 } | 414 } |
416 | 415 |
417 private: | 416 private: |
418 ~MalformedFavoritesRegistryTestObserver() {} | 417 ~MalformedFavoritesRegistryTestObserver() override {} |
419 | 418 |
420 size_t bookmark_count_; | 419 size_t bookmark_count_; |
421 }; | 420 }; |
422 | 421 |
423 } // namespace | 422 } // namespace |
424 | 423 |
425 // These tests need to be browser tests in order to be able to run the OOP | 424 // These tests need to be browser tests in order to be able to run the OOP |
426 // import (via ExternalProcessImporterHost) which launches a utility process. | 425 // import (via ExternalProcessImporterHost) which launches a utility process. |
427 class IEImporterBrowserTest : public InProcessBrowserTest { | 426 class IEImporterBrowserTest : public InProcessBrowserTest { |
428 protected: | 427 protected: |
429 virtual void SetUp() override { | 428 void SetUp() override { |
430 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 429 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
431 | 430 |
432 // This will launch the browser test and thus needs to happen last. | 431 // This will launch the browser test and thus needs to happen last. |
433 InProcessBrowserTest::SetUp(); | 432 InProcessBrowserTest::SetUp(); |
434 } | 433 } |
435 | 434 |
436 base::ScopedTempDir temp_dir_; | 435 base::ScopedTempDir temp_dir_; |
437 | 436 |
438 // Overrides the default registry key for IE registry keys like favorites, | 437 // Overrides the default registry key for IE registry keys like favorites, |
439 // settings, password store, etc. | 438 // settings, password store, etc. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 source_profile.source_path = temp_dir_.path(); | 646 source_profile.source_path = temp_dir_.path(); |
648 | 647 |
649 host->StartImportSettings( | 648 host->StartImportSettings( |
650 source_profile, | 649 source_profile, |
651 browser()->profile(), | 650 browser()->profile(), |
652 importer::HOME_PAGE, | 651 importer::HOME_PAGE, |
653 observer); | 652 observer); |
654 base::MessageLoop::current()->Run(); | 653 base::MessageLoop::current()->Run(); |
655 } | 654 } |
656 | 655 |
OLD | NEW |