OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/importer/importer_host.h" | 21 #include "chrome/browser/importer/importer_host.h" |
22 #include "chrome/browser/importer/importer_progress_observer.h" | 22 #include "chrome/browser/importer/importer_progress_observer.h" |
23 #include "chrome/browser/importer/importer_unittest_utils.h" | 23 #include "chrome/browser/importer/importer_unittest_utils.h" |
24 #include "chrome/browser/importer/nss_decryptor.h" | 24 #include "chrome/browser/importer/nss_decryptor.h" |
25 #include "chrome/browser/search_engines/template_url.h" | 25 #include "chrome/browser/search_engines/template_url.h" |
26 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
27 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
28 #include "content/public/common/password_form.h" | 28 #include "content/public/common/password_form.h" |
29 | 29 |
30 // TODO(estade): some of these are disabled on mac. http://crbug.com/48007 | 30 // TODO(estade): some of these are disabled on mac. http://crbug.com/48007 |
31 #if defined(OS_MACOSX) | 31 // TODO(jschuh): Disabled on Win64 build. http://crbug.com/179688 |
32 #define MAYBE(x) DISABLED_##x | 32 #if defined(OS_MACOSX) || (defined(OS_WIN) && defined(ARCH_CPU_X86_64)) |
| 33 #define MAYBE_IMPORTER(x) DISABLED_##x |
33 #else | 34 #else |
34 #define MAYBE(x) x | 35 #define MAYBE_IMPORTER(x) x |
| 36 #endif |
| 37 |
| 38 // TODO(jschuh): Disabled on Win64 build. http://crbug.com/179688 |
| 39 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) |
| 40 #define MAYBE_NSS(x) DISABLED_##x |
| 41 #else |
| 42 #define MAYBE_NSS(x) x |
35 #endif | 43 #endif |
36 | 44 |
37 namespace { | 45 namespace { |
38 | 46 |
39 const BookmarkInfo kFirefox2Bookmarks[] = { | 47 const BookmarkInfo kFirefox2Bookmarks[] = { |
40 {true, 2, {L"Bookmarks Toolbar Folder", L"Folder"}, | 48 {true, 2, {L"Bookmarks Toolbar Folder", L"Folder"}, |
41 L"On Toolbar's Subfolder", | 49 L"On Toolbar's Subfolder", |
42 "http://on.toolbar/bookmark/folder"}, | 50 "http://on.toolbar/bookmark/folder"}, |
43 {true, 1, {L"Bookmarks Toolbar Folder"}, | 51 {true, 1, {L"Bookmarks Toolbar Folder"}, |
44 L"On Bookmark Toolbar", | 52 L"On Bookmark Toolbar", |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 loop->PostTask(FROM_HERE, base::Bind( | 429 loop->PostTask(FROM_HERE, base::Bind( |
422 &ImporterHost::StartImportSettings, host.get(), source_profile, | 430 &ImporterHost::StartImportSettings, host.get(), source_profile, |
423 profile_.get(), items, make_scoped_refptr(writer), true)); | 431 profile_.get(), items, make_scoped_refptr(writer), true)); |
424 loop->Run(); | 432 loop->Run(); |
425 } | 433 } |
426 | 434 |
427 base::FilePath profile_path_; | 435 base::FilePath profile_path_; |
428 base::FilePath app_path_; | 436 base::FilePath app_path_; |
429 }; | 437 }; |
430 | 438 |
431 TEST_F(FirefoxProfileImporterTest, MAYBE(Firefox2Importer)) { | 439 TEST_F(FirefoxProfileImporterTest, MAYBE_IMPORTER(Firefox2Importer)) { |
432 base::FilePath data_path; | 440 base::FilePath data_path; |
433 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 441 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
434 data_path = data_path.AppendASCII("firefox2_profile"); | 442 data_path = data_path.AppendASCII("firefox2_profile"); |
435 ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, true)); | 443 ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, true)); |
436 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 444 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
437 data_path = data_path.AppendASCII("firefox2_nss"); | 445 data_path = data_path.AppendASCII("firefox2_nss"); |
438 ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, false)); | 446 ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, false)); |
439 | 447 |
440 base::FilePath search_engine_path = app_path_; | 448 base::FilePath search_engine_path = app_path_; |
441 search_engine_path = search_engine_path.AppendASCII("searchplugins"); | 449 search_engine_path = search_engine_path.AppendASCII("searchplugins"); |
(...skipping 21 matching lines...) Expand all Loading... |
463 host.get(), | 471 host.get(), |
464 source_profile, | 472 source_profile, |
465 profile_.get(), | 473 profile_.get(), |
466 importer::HISTORY | importer::PASSWORDS | | 474 importer::HISTORY | importer::PASSWORDS | |
467 importer::FAVORITES | importer::SEARCH_ENGINES, | 475 importer::FAVORITES | importer::SEARCH_ENGINES, |
468 make_scoped_refptr(observer), | 476 make_scoped_refptr(observer), |
469 true)); | 477 true)); |
470 loop->Run(); | 478 loop->Run(); |
471 } | 479 } |
472 | 480 |
473 TEST_F(FirefoxProfileImporterTest, MAYBE(Firefox30Importer)) { | 481 TEST_F(FirefoxProfileImporterTest, MAYBE_IMPORTER(Firefox30Importer)) { |
474 scoped_refptr<Firefox3Observer> observer(new Firefox3Observer()); | 482 scoped_refptr<Firefox3Observer> observer(new Firefox3Observer()); |
475 Firefox3xImporterTest("firefox3_profile", observer.get(), observer.get(), | 483 Firefox3xImporterTest("firefox3_profile", observer.get(), observer.get(), |
476 true); | 484 true); |
477 } | 485 } |
478 | 486 |
479 TEST_F(FirefoxProfileImporterTest, MAYBE(Firefox35Importer)) { | 487 TEST_F(FirefoxProfileImporterTest, MAYBE_IMPORTER(Firefox35Importer)) { |
480 bool import_search_engines = false; | 488 bool import_search_engines = false; |
481 scoped_refptr<Firefox3Observer> observer( | 489 scoped_refptr<Firefox3Observer> observer( |
482 new Firefox3Observer(import_search_engines)); | 490 new Firefox3Observer(import_search_engines)); |
483 Firefox3xImporterTest("firefox35_profile", observer.get(), observer.get(), | 491 Firefox3xImporterTest("firefox35_profile", observer.get(), observer.get(), |
484 import_search_engines); | 492 import_search_engines); |
485 } | 493 } |
486 | 494 |
487 // The following 2 tests require the use of the NSSDecryptor, on OSX this needs | 495 // The following 2 tests require the use of the NSSDecryptor, on OSX this needs |
488 // to run in a separate process, so we use a proxy object so we can share the | 496 // to run in a separate process, so we use a proxy object so we can share the |
489 // same test between platforms. | 497 // same test between platforms. |
490 TEST(FirefoxImporterTest, Firefox2NSS3Decryptor) { | 498 TEST(FirefoxImporterTest, MAYBE_NSS(Firefox2NSS3Decryptor)) { |
491 base::FilePath nss_path; | 499 base::FilePath nss_path; |
492 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); | 500 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); |
493 #ifdef OS_MACOSX | 501 #ifdef OS_MACOSX |
494 nss_path = nss_path.AppendASCII("firefox2_nss_mac"); | 502 nss_path = nss_path.AppendASCII("firefox2_nss_mac"); |
495 #else | 503 #else |
496 nss_path = nss_path.AppendASCII("firefox2_nss"); | 504 nss_path = nss_path.AppendASCII("firefox2_nss"); |
497 #endif // !OS_MACOSX | 505 #endif // !OS_MACOSX |
498 base::FilePath db_path; | 506 base::FilePath db_path; |
499 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); | 507 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); |
500 db_path = db_path.AppendASCII("firefox2_profile"); | 508 db_path = db_path.AppendASCII("firefox2_profile"); |
501 | 509 |
502 FFUnitTestDecryptorProxy decryptor_proxy; | 510 FFUnitTestDecryptorProxy decryptor_proxy; |
503 ASSERT_TRUE(decryptor_proxy.Setup(nss_path)); | 511 ASSERT_TRUE(decryptor_proxy.Setup(nss_path)); |
504 | 512 |
505 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); | 513 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); |
506 EXPECT_EQ(ASCIIToUTF16("hello"), | 514 EXPECT_EQ(ASCIIToUTF16("hello"), |
507 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECBJ" | 515 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECBJ" |
508 "M63MpT9rtBAjMCm7qo/EhlA==")); | 516 "M63MpT9rtBAjMCm7qo/EhlA==")); |
509 // Test UTF-16 encoding. | 517 // Test UTF-16 encoding. |
510 EXPECT_EQ(WideToUTF16(L"\x4E2D"), | 518 EXPECT_EQ(WideToUTF16(L"\x4E2D"), |
511 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECN9" | 519 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECN9" |
512 "OQ5ZFmhb8BAiFo1Z+fUvaIQ==")); | 520 "OQ5ZFmhb8BAiFo1Z+fUvaIQ==")); |
513 } | 521 } |
514 | 522 |
515 TEST(FirefoxImporterTest, Firefox3NSS3Decryptor) { | 523 TEST(FirefoxImporterTest, MAYBE_NSS(Firefox3NSS3Decryptor)) { |
516 base::FilePath nss_path; | 524 base::FilePath nss_path; |
517 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); | 525 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); |
518 #ifdef OS_MACOSX | 526 #ifdef OS_MACOSX |
519 nss_path = nss_path.AppendASCII("firefox3_nss_mac"); | 527 nss_path = nss_path.AppendASCII("firefox3_nss_mac"); |
520 #else | 528 #else |
521 nss_path = nss_path.AppendASCII("firefox3_nss"); | 529 nss_path = nss_path.AppendASCII("firefox3_nss"); |
522 #endif // !OS_MACOSX | 530 #endif // !OS_MACOSX |
523 base::FilePath db_path; | 531 base::FilePath db_path; |
524 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); | 532 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); |
525 db_path = db_path.AppendASCII("firefox3_profile"); | 533 db_path = db_path.AppendASCII("firefox3_profile"); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); | 765 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); |
758 EXPECT_EQ(0U, entry.path.size()); | 766 EXPECT_EQ(0U, entry.path.size()); |
759 entry = *it++; | 767 entry = *it++; |
760 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); | 768 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); |
761 EXPECT_EQ("http://www.google.com/", entry.url.spec()); | 769 EXPECT_EQ("http://www.google.com/", entry.url.spec()); |
762 EXPECT_EQ(0U, entry.path.size()); | 770 EXPECT_EQ(0U, entry.path.size()); |
763 } | 771 } |
764 | 772 |
765 importer->Release(); | 773 importer->Release(); |
766 } | 774 } |
OLD | NEW |