| OLD | NEW | 
|    1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2006-2008 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/file_path.h" |    7 #include "base/file_path.h" | 
|    8 #include "base/file_util.h" |    8 #include "base/file_util.h" | 
|    9 #include "base/path_service.h" |    9 #include "base/path_service.h" | 
|   10 #include "chrome/browser/importer/firefox2_importer.h" |   10 #include "chrome/browser/importer/firefox2_importer.h" | 
|   11 #include "chrome/browser/importer/firefox_importer_utils.h" |   11 #include "chrome/browser/importer/firefox_importer_utils.h" | 
|   12 #include "chrome/browser/importer/nss_decryptor.h" |   12 #include "chrome/browser/importer/nss_decryptor.h" | 
|   13 #include "chrome/common/chrome_paths.h" |   13 #include "chrome/common/chrome_paths.h" | 
|   14  |   14  | 
|   15 using base::Time; |   15 using base::Time; | 
|   16  |   16  | 
 |   17 // TODO(jeremy): Port NSSDecryptor to OSX and enable these tests. | 
 |   18 #if !defined(OS_MACOSX) | 
|   17 TEST(FirefoxImporterTest, Firefox2NSS3Decryptor) { |   19 TEST(FirefoxImporterTest, Firefox2NSS3Decryptor) { | 
|   18   std::wstring nss_path; |   20   std::wstring nss_path; | 
|   19   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); |   21   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); | 
|   20   file_util::AppendToPath(&nss_path, L"firefox2_nss"); |   22   file_util::AppendToPath(&nss_path, L"firefox2_nss"); | 
|   21   std::wstring db_path; |   23   std::wstring db_path; | 
|   22   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); |   24   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); | 
|   23   file_util::AppendToPath(&db_path, L"firefox2_profile"); |   25   file_util::AppendToPath(&db_path, L"firefox2_profile"); | 
|   24   NSSDecryptor decryptor; |   26   NSSDecryptor decryptor; | 
|   25   EXPECT_TRUE(decryptor.Init(nss_path, db_path)); |   27   EXPECT_TRUE(decryptor.Init(nss_path, db_path)); | 
|   26   EXPECT_EQ(L"hello", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" |   28   EXPECT_EQ(L"hello", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|   38   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); |   40   ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); | 
|   39   file_util::AppendToPath(&db_path, L"firefox3_profile"); |   41   file_util::AppendToPath(&db_path, L"firefox3_profile"); | 
|   40   NSSDecryptor decryptor; |   42   NSSDecryptor decryptor; | 
|   41   EXPECT_TRUE(decryptor.Init(nss_path, db_path)); |   43   EXPECT_TRUE(decryptor.Init(nss_path, db_path)); | 
|   42   EXPECT_EQ(L"hello", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" |   44   EXPECT_EQ(L"hello", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" | 
|   43       "wFAYIKoZIhvcNAwcECKajtRg4qFSHBAhv9luFkXgDJA==")); |   45       "wFAYIKoZIhvcNAwcECKajtRg4qFSHBAhv9luFkXgDJA==")); | 
|   44   // Test UTF-16 encoding. |   46   // Test UTF-16 encoding. | 
|   45   EXPECT_EQ(L"\x4E2D", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" |   47   EXPECT_EQ(L"\x4E2D", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" | 
|   46       "wFAYIKoZIhvcNAwcECLWqqiccfQHWBAie74hxnULxlw==")); |   48       "wFAYIKoZIhvcNAwcECLWqqiccfQHWBAie74hxnULxlw==")); | 
|   47 } |   49 } | 
 |   50 #endif  // !OS_MACOSX | 
|   48  |   51  | 
|   49 TEST(FirefoxImporterTest, Firefox2BookmarkParse) { |   52 TEST(FirefoxImporterTest, Firefox2BookmarkParse) { | 
|   50   bool result; |   53   bool result; | 
|   51  |   54  | 
|   52   // Tests charset. |   55   // Tests charset. | 
|   53   std::string charset; |   56   std::string charset; | 
|   54   result = Firefox2Importer::ParseCharsetFromLine( |   57   result = Firefox2Importer::ParseCharsetFromLine( | 
|   55       "<META HTTP-EQUIV=\"Content-Type\" " |   58       "<META HTTP-EQUIV=\"Content-Type\" " | 
|   56       "CONTENT=\"text/html; charset=UTF-8\">", |   59       "CONTENT=\"text/html; charset=UTF-8\">", | 
|   57       &charset); |   60       &charset); | 
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  144   result = Firefox2Importer::ParseBookmarkFromLine( |  147   result = Firefox2Importer::ParseBookmarkFromLine( | 
|  145       "<DT><A HREF=\"http://domain.com/?q=%22", |  148       "<DT><A HREF=\"http://domain.com/?q=%22", | 
|  146       charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); |  149       charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); | 
|  147   EXPECT_FALSE(result); |  150   EXPECT_FALSE(result); | 
|  148   EXPECT_EQ(L"", title); |  151   EXPECT_EQ(L"", title); | 
|  149   EXPECT_EQ("", url.spec()); |  152   EXPECT_EQ("", url.spec()); | 
|  150   EXPECT_EQ(L"", shortcut); |  153   EXPECT_EQ(L"", shortcut); | 
|  151   EXPECT_EQ(L"", post_data); |  154   EXPECT_EQ(L"", post_data); | 
|  152   EXPECT_TRUE(Time() == add_date); |  155   EXPECT_TRUE(Time() == add_date); | 
|  153 } |  156 } | 
| OLD | NEW |