| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "testing/gtest/include/gtest/gtest.h" | |
| 6 | |
| 7 #include "base/files/file_path.h" | |
| 8 #include "base/path_service.h" | |
| 9 #include "base/strings/utf_string_conversions.h" | |
| 10 #include "chrome/browser/importer/firefox_importer_unittest_utils.h" | |
| 11 #include "chrome/browser/importer/nss_decryptor.h" | |
| 12 #include "chrome/common/chrome_paths.h" | |
| 13 | |
| 14 // TODO(jschuh): Disabled on Win64 build. http://crbug.com/179688 | |
| 15 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) | |
| 16 #define MAYBE_NSS(x) DISABLED_##x | |
| 17 #else | |
| 18 #define MAYBE_NSS(x) x | |
| 19 #endif | |
| 20 | |
| 21 // The following test requires the use of the NSSDecryptor, on OSX this needs | |
| 22 // to run in a separate process, so we use a proxy object so we can share the | |
| 23 // same test between platforms. | |
| 24 TEST(FirefoxImporterTest, MAYBE_NSS(Firefox3NSS3Decryptor)) { | |
| 25 base::FilePath nss_path; | |
| 26 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); | |
| 27 #if defined(OS_MACOSX) | |
| 28 nss_path = nss_path.AppendASCII("firefox3_nss_mac"); | |
| 29 #else | |
| 30 nss_path = nss_path.AppendASCII("firefox3_nss"); | |
| 31 #endif // !OS_MACOSX | |
| 32 base::FilePath db_path; | |
| 33 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); | |
| 34 db_path = db_path.AppendASCII("firefox3_profile"); | |
| 35 | |
| 36 FFUnitTestDecryptorProxy decryptor_proxy; | |
| 37 ASSERT_TRUE(decryptor_proxy.Setup(nss_path)); | |
| 38 | |
| 39 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); | |
| 40 EXPECT_EQ(ASCIIToUTF16("hello"), | |
| 41 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECKa" | |
| 42 "jtRg4qFSHBAhv9luFkXgDJA==")); | |
| 43 // Test UTF-16 encoding. | |
| 44 EXPECT_EQ(WideToUTF16(L"\x4E2D"), | |
| 45 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECLW" | |
| 46 "qqiccfQHWBAie74hxnULxlw==")); | |
| 47 } | |
| OLD | NEW |