Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: chrome/browser/importer/firefox_importer_unittest.cc

Issue 174259: Recommit "Bring up Firefox Password Import Unittest on OS X." (Closed)
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_unittest_utils.h"
11 #include "chrome/browser/importer/firefox_importer_utils.h" 12 #include "chrome/browser/importer/firefox_importer_utils.h"
12 #include "chrome/browser/importer/nss_decryptor.h" 13 #include "chrome/browser/importer/nss_decryptor.h"
13 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
14 15
15 using base::Time; 16 using base::Time;
16 17
17 // TODO(jeremy): Port NSSDecryptor to OSX and enable these tests. 18 // The following 2 tests require the use of the NSSDecryptor, on OSX this needs
18 #if !defined(OS_MACOSX) 19 // to run in a separate process, so we use a proxy object so we can share the
20 // same test between platforms.
19 TEST(FirefoxImporterTest, Firefox2NSS3Decryptor) { 21 TEST(FirefoxImporterTest, Firefox2NSS3Decryptor) {
20 std::wstring nss_path; 22 std::wstring nss_path;
21 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); 23 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path));
24 #ifdef OS_MACOSX
25 file_util::AppendToPath(&nss_path, L"firefox2_nss_mac");
26 #else
22 file_util::AppendToPath(&nss_path, L"firefox2_nss"); 27 file_util::AppendToPath(&nss_path, L"firefox2_nss");
28 #endif // !OS_MACOSX
23 std::wstring db_path; 29 std::wstring db_path;
24 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); 30 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path));
25 file_util::AppendToPath(&db_path, L"firefox2_profile"); 31 file_util::AppendToPath(&db_path, L"firefox2_profile");
26 NSSDecryptor decryptor; 32
27 EXPECT_TRUE(decryptor.Init(nss_path, db_path)); 33 FFUnitTestDecryptorProxy decryptor_proxy;
28 EXPECT_EQ(L"hello", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" 34 ASSERT_TRUE(decryptor_proxy.Setup(nss_path));
35
36 EXPECT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path));
37 EXPECT_EQ(L"hello", decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE"
29 "wFAYIKoZIhvcNAwcECBJM63MpT9rtBAjMCm7qo/EhlA==")); 38 "wFAYIKoZIhvcNAwcECBJM63MpT9rtBAjMCm7qo/EhlA=="));
30 // Test UTF-16 encoding. 39 // Test UTF-16 encoding.
31 EXPECT_EQ(L"\x4E2D", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" 40 EXPECT_EQ(L"\x4E2D", decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE"
32 "wFAYIKoZIhvcNAwcECN9OQ5ZFmhb8BAiFo1Z+fUvaIQ==")); 41 "wFAYIKoZIhvcNAwcECN9OQ5ZFmhb8BAiFo1Z+fUvaIQ=="));
33 } 42 }
34 43
35 TEST(FirefoxImporterTest, Firefox3NSS3Decryptor) { 44 TEST(FirefoxImporterTest, Firefox3NSS3Decryptor) {
36 std::wstring nss_path; 45 std::wstring nss_path;
37 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); 46 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path));
47 #ifdef OS_MACOSX
48 file_util::AppendToPath(&nss_path, L"firefox3_nss_mac");
49 #else
38 file_util::AppendToPath(&nss_path, L"firefox3_nss"); 50 file_util::AppendToPath(&nss_path, L"firefox3_nss");
51 #endif // !OS_MACOSX
39 std::wstring db_path; 52 std::wstring db_path;
40 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); 53 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path));
41 file_util::AppendToPath(&db_path, L"firefox3_profile"); 54 file_util::AppendToPath(&db_path, L"firefox3_profile");
42 NSSDecryptor decryptor; 55
43 EXPECT_TRUE(decryptor.Init(nss_path, db_path)); 56 FFUnitTestDecryptorProxy decryptor_proxy;
44 EXPECT_EQ(L"hello", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" 57 ASSERT_TRUE(decryptor_proxy.Setup(nss_path));
58
59 EXPECT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path));
60 EXPECT_EQ(L"hello", decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE"
45 "wFAYIKoZIhvcNAwcECKajtRg4qFSHBAhv9luFkXgDJA==")); 61 "wFAYIKoZIhvcNAwcECKajtRg4qFSHBAhv9luFkXgDJA=="));
46 // Test UTF-16 encoding. 62 // Test UTF-16 encoding.
47 EXPECT_EQ(L"\x4E2D", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" 63 EXPECT_EQ(L"\x4E2D", decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE"
48 "wFAYIKoZIhvcNAwcECLWqqiccfQHWBAie74hxnULxlw==")); 64 "wFAYIKoZIhvcNAwcECLWqqiccfQHWBAie74hxnULxlw=="));
49 } 65 }
50 #endif // !OS_MACOSX
51 66
52 TEST(FirefoxImporterTest, Firefox2BookmarkParse) { 67 TEST(FirefoxImporterTest, Firefox2BookmarkParse) {
53 bool result; 68 bool result;
54 69
55 // Tests charset. 70 // Tests charset.
56 std::string charset; 71 std::string charset;
57 result = Firefox2Importer::ParseCharsetFromLine( 72 result = Firefox2Importer::ParseCharsetFromLine(
58 "<META HTTP-EQUIV=\"Content-Type\" " 73 "<META HTTP-EQUIV=\"Content-Type\" "
59 "CONTENT=\"text/html; charset=UTF-8\">", 74 "CONTENT=\"text/html; charset=UTF-8\">",
60 &charset); 75 &charset);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 result = Firefox2Importer::ParseBookmarkFromLine( 162 result = Firefox2Importer::ParseBookmarkFromLine(
148 "<DT><A HREF=\"http://domain.com/?q=%22", 163 "<DT><A HREF=\"http://domain.com/?q=%22",
149 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 164 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
150 EXPECT_FALSE(result); 165 EXPECT_FALSE(result);
151 EXPECT_EQ(L"", title); 166 EXPECT_EQ(L"", title);
152 EXPECT_EQ("", url.spec()); 167 EXPECT_EQ("", url.spec());
153 EXPECT_EQ(L"", shortcut); 168 EXPECT_EQ(L"", shortcut);
154 EXPECT_EQ(L"", post_data); 169 EXPECT_EQ(L"", post_data);
155 EXPECT_TRUE(Time() == add_date); 170 EXPECT_TRUE(Time() == add_date);
156 } 171 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/firefox3_importer.h ('k') | chrome/browser/importer/firefox_importer_unittest_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698