| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 history_count_(0), | 225 history_count_(0), |
| 226 password_count_(0), | 226 password_count_(0), |
| 227 favicon_count_(0), | 227 favicon_count_(0), |
| 228 homepage_count_(0), | 228 homepage_count_(0), |
| 229 ie7_password_count_(0), | 229 ie7_password_count_(0), |
| 230 importer_items_(importer_items), | 230 importer_items_(importer_items), |
| 231 ie_version_(ie_version) { | 231 ie_version_(ie_version) { |
| 232 } | 232 } |
| 233 | 233 |
| 234 // importer::ImporterProgressObserver: | 234 // importer::ImporterProgressObserver: |
| 235 virtual void ImportStarted() OVERRIDE {} | 235 virtual void ImportStarted() override {} |
| 236 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} | 236 virtual void ImportItemStarted(importer::ImportItem item) override {} |
| 237 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} | 237 virtual void ImportItemEnded(importer::ImportItem item) override {} |
| 238 virtual void ImportEnded() OVERRIDE { | 238 virtual void ImportEnded() override { |
| 239 base::MessageLoop::current()->Quit(); | 239 base::MessageLoop::current()->Quit(); |
| 240 if (importer_items_ & importer::FAVORITES) { | 240 if (importer_items_ & importer::FAVORITES) { |
| 241 EXPECT_EQ(arraysize(kIEBookmarks), bookmark_count_); | 241 EXPECT_EQ(arraysize(kIEBookmarks), bookmark_count_); |
| 242 EXPECT_EQ(arraysize(kIEFaviconGroup), favicon_count_); | 242 EXPECT_EQ(arraysize(kIEFaviconGroup), favicon_count_); |
| 243 } | 243 } |
| 244 if (importer_items_ & importer::HISTORY) | 244 if (importer_items_ & importer::HISTORY) |
| 245 EXPECT_EQ(1, history_count_); | 245 EXPECT_EQ(1, history_count_); |
| 246 if (importer_items_ & importer::HOME_PAGE) | 246 if (importer_items_ & importer::HOME_PAGE) |
| 247 EXPECT_EQ(1, homepage_count_); | 247 EXPECT_EQ(1, homepage_count_); |
| 248 if ((importer_items_ & importer::PASSWORDS) && (ie_version_ == IE7)) | 248 if ((importer_items_ & importer::PASSWORDS) && (ie_version_ == IE7)) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 279 for (size_t i = 0; i < page.size(); ++i) { | 279 for (size_t i = 0; i < page.size(); ++i) { |
| 280 if (page[i].title() == kIEIdentifyTitle && | 280 if (page[i].title() == kIEIdentifyTitle && |
| 281 page[i].url() == GURL(kIEIdentifyUrl)) | 281 page[i].url() == GURL(kIEIdentifyUrl)) |
| 282 ++history_count_; | 282 ++history_count_; |
| 283 } | 283 } |
| 284 EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_source); | 284 EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_source); |
| 285 } | 285 } |
| 286 | 286 |
| 287 virtual void AddBookmarks( | 287 virtual void AddBookmarks( |
| 288 const std::vector<ImportedBookmarkEntry>& bookmarks, | 288 const std::vector<ImportedBookmarkEntry>& bookmarks, |
| 289 const base::string16& top_level_folder_name) OVERRIDE { | 289 const base::string16& top_level_folder_name) override { |
| 290 ASSERT_LE(bookmark_count_ + bookmarks.size(), arraysize(kIEBookmarks)); | 290 ASSERT_LE(bookmark_count_ + bookmarks.size(), arraysize(kIEBookmarks)); |
| 291 // Importer should import the IE Favorites folder the same as the list, | 291 // Importer should import the IE Favorites folder the same as the list, |
| 292 // in the same order. | 292 // in the same order. |
| 293 for (size_t i = 0; i < bookmarks.size(); ++i) { | 293 for (size_t i = 0; i < bookmarks.size(); ++i) { |
| 294 EXPECT_NO_FATAL_FAILURE( | 294 EXPECT_NO_FATAL_FAILURE( |
| 295 TestEqualBookmarkEntry(bookmarks[i], | 295 TestEqualBookmarkEntry(bookmarks[i], |
| 296 kIEBookmarks[bookmark_count_])) << i; | 296 kIEBookmarks[bookmark_count_])) << i; |
| 297 ++bookmark_count_; | 297 ++bookmark_count_; |
| 298 } | 298 } |
| 299 } | 299 } |
| 300 | 300 |
| 301 virtual void AddKeyword(std::vector<TemplateURL*> template_url, | 301 virtual void AddKeyword(std::vector<TemplateURL*> template_url, |
| 302 int default_keyword_index) { | 302 int default_keyword_index) { |
| 303 // TODO(jcampan): bug 1169230: we should test keyword importing for IE. | 303 // TODO(jcampan): bug 1169230: we should test keyword importing for IE. |
| 304 // In order to do that we'll probably need to mock the Windows registry. | 304 // In order to do that we'll probably need to mock the Windows registry. |
| 305 NOTREACHED(); | 305 NOTREACHED(); |
| 306 STLDeleteContainerPointers(template_url.begin(), template_url.end()); | 306 STLDeleteContainerPointers(template_url.begin(), template_url.end()); |
| 307 } | 307 } |
| 308 | 308 |
| 309 virtual void AddFavicons( | 309 virtual void AddFavicons( |
| 310 const std::vector<ImportedFaviconUsage>& usage) OVERRIDE { | 310 const std::vector<ImportedFaviconUsage>& usage) override { |
| 311 // Importer should group the favicon information for each favicon URL. | 311 // Importer should group the favicon information for each favicon URL. |
| 312 for (size_t i = 0; i < arraysize(kIEFaviconGroup); ++i) { | 312 for (size_t i = 0; i < arraysize(kIEFaviconGroup); ++i) { |
| 313 GURL favicon_url(kIEFaviconGroup[i].favicon_url); | 313 GURL favicon_url(kIEFaviconGroup[i].favicon_url); |
| 314 std::set<GURL> urls; | 314 std::set<GURL> urls; |
| 315 for (size_t j = 0; j < arraysize(kIEFaviconGroup[i].site_url); ++j) | 315 for (size_t j = 0; j < arraysize(kIEFaviconGroup[i].site_url); ++j) |
| 316 urls.insert(GURL(kIEFaviconGroup[i].site_url[j])); | 316 urls.insert(GURL(kIEFaviconGroup[i].site_url[j])); |
| 317 | 317 |
| 318 SCOPED_TRACE(testing::Message() << "Expected Favicon: " << favicon_url); | 318 SCOPED_TRACE(testing::Message() << "Expected Favicon: " << favicon_url); |
| 319 | 319 |
| 320 bool expected_favicon_url_found = false; | 320 bool expected_favicon_url_found = false; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 361 |
| 362 class MalformedFavoritesRegistryTestObserver | 362 class MalformedFavoritesRegistryTestObserver |
| 363 : public ProfileWriter, | 363 : public ProfileWriter, |
| 364 public importer::ImporterProgressObserver { | 364 public importer::ImporterProgressObserver { |
| 365 public: | 365 public: |
| 366 MalformedFavoritesRegistryTestObserver() : ProfileWriter(NULL) { | 366 MalformedFavoritesRegistryTestObserver() : ProfileWriter(NULL) { |
| 367 bookmark_count_ = 0; | 367 bookmark_count_ = 0; |
| 368 } | 368 } |
| 369 | 369 |
| 370 // importer::ImporterProgressObserver: | 370 // importer::ImporterProgressObserver: |
| 371 virtual void ImportStarted() OVERRIDE {} | 371 virtual void ImportStarted() override {} |
| 372 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} | 372 virtual void ImportItemStarted(importer::ImportItem item) override {} |
| 373 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} | 373 virtual void ImportItemEnded(importer::ImportItem item) override {} |
| 374 virtual void ImportEnded() OVERRIDE { | 374 virtual void ImportEnded() override { |
| 375 base::MessageLoop::current()->Quit(); | 375 base::MessageLoop::current()->Quit(); |
| 376 EXPECT_EQ(arraysize(kIESortedBookmarks), bookmark_count_); | 376 EXPECT_EQ(arraysize(kIESortedBookmarks), bookmark_count_); |
| 377 } | 377 } |
| 378 | 378 |
| 379 virtual bool BookmarkModelIsLoaded() const { return true; } | 379 virtual bool BookmarkModelIsLoaded() const { return true; } |
| 380 virtual bool TemplateURLServiceIsLoaded() const { return true; } | 380 virtual bool TemplateURLServiceIsLoaded() const { return true; } |
| 381 | 381 |
| 382 virtual void AddPasswordForm(const autofill::PasswordForm& form) {} | 382 virtual void AddPasswordForm(const autofill::PasswordForm& form) {} |
| 383 virtual void AddHistoryPage(const history::URLRows& page, | 383 virtual void AddHistoryPage(const history::URLRows& page, |
| 384 history::VisitSource visit_source) {} | 384 history::VisitSource visit_source) {} |
| 385 virtual void AddKeyword(std::vector<TemplateURL*> template_url, | 385 virtual void AddKeyword(std::vector<TemplateURL*> template_url, |
| 386 int default_keyword_index) {} | 386 int default_keyword_index) {} |
| 387 virtual void AddBookmarks( | 387 virtual void AddBookmarks( |
| 388 const std::vector<ImportedBookmarkEntry>& bookmarks, | 388 const std::vector<ImportedBookmarkEntry>& bookmarks, |
| 389 const base::string16& top_level_folder_name) OVERRIDE { | 389 const base::string16& top_level_folder_name) override { |
| 390 ASSERT_LE(bookmark_count_ + bookmarks.size(), | 390 ASSERT_LE(bookmark_count_ + bookmarks.size(), |
| 391 arraysize(kIESortedBookmarks)); | 391 arraysize(kIESortedBookmarks)); |
| 392 for (size_t i = 0; i < bookmarks.size(); ++i) { | 392 for (size_t i = 0; i < bookmarks.size(); ++i) { |
| 393 EXPECT_NO_FATAL_FAILURE( | 393 EXPECT_NO_FATAL_FAILURE( |
| 394 TestEqualBookmarkEntry(bookmarks[i], | 394 TestEqualBookmarkEntry(bookmarks[i], |
| 395 kIESortedBookmarks[bookmark_count_])) << i; | 395 kIESortedBookmarks[bookmark_count_])) << i; |
| 396 ++bookmark_count_; | 396 ++bookmark_count_; |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 | 399 |
| 400 private: | 400 private: |
| 401 ~MalformedFavoritesRegistryTestObserver() {} | 401 ~MalformedFavoritesRegistryTestObserver() {} |
| 402 | 402 |
| 403 size_t bookmark_count_; | 403 size_t bookmark_count_; |
| 404 }; | 404 }; |
| 405 | 405 |
| 406 } // namespace | 406 } // namespace |
| 407 | 407 |
| 408 // These tests need to be browser tests in order to be able to run the OOP | 408 // These tests need to be browser tests in order to be able to run the OOP |
| 409 // import (via ExternalProcessImporterHost) which launches a utility process. | 409 // import (via ExternalProcessImporterHost) which launches a utility process. |
| 410 class IEImporterBrowserTest : public InProcessBrowserTest { | 410 class IEImporterBrowserTest : public InProcessBrowserTest { |
| 411 protected: | 411 protected: |
| 412 virtual void SetUp() OVERRIDE { | 412 virtual void SetUp() override { |
| 413 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 413 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 414 | 414 |
| 415 // This will launch the browser test and thus needs to happen last. | 415 // This will launch the browser test and thus needs to happen last. |
| 416 InProcessBrowserTest::SetUp(); | 416 InProcessBrowserTest::SetUp(); |
| 417 } | 417 } |
| 418 | 418 |
| 419 base::ScopedTempDir temp_dir_; | 419 base::ScopedTempDir temp_dir_; |
| 420 | 420 |
| 421 // Overrides the default registry key for IE registry keys like favorites, | 421 // Overrides the default registry key for IE registry keys like favorites, |
| 422 // settings, password store, etc. | 422 // settings, password store, etc. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 source_profile.source_path = temp_dir_.path(); | 627 source_profile.source_path = temp_dir_.path(); |
| 628 | 628 |
| 629 host->StartImportSettings( | 629 host->StartImportSettings( |
| 630 source_profile, | 630 source_profile, |
| 631 browser()->profile(), | 631 browser()->profile(), |
| 632 importer::HOME_PAGE, | 632 importer::HOME_PAGE, |
| 633 observer); | 633 observer); |
| 634 base::MessageLoop::current()->Run(); | 634 base::MessageLoop::current()->Run(); |
| 635 } | 635 } |
| 636 | 636 |
| OLD | NEW |