| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/importer/safari_importer.h" | 5 #include "chrome/browser/importer/safari_importer.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 12 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
| 13 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
| 14 | 14 |
| 15 // In order to test the Safari import functionality effectively, we store a | 15 // In order to test the Safari import functionality effectively, we store a |
| 16 // simulated Library directory containing dummy data files in the same | 16 // simulated Library directory containing dummy data files in the same |
| 17 // structure as ~/Library in the Chrome test data directory. | 17 // structure as ~/Library in the Chrome test data directory. |
| 18 // This function returns the path to that directory. | 18 // This function returns the path to that directory. |
| 19 FilePath GetTestSafariLibraryPath() { | 19 FilePath GetTestSafariLibraryPath() { |
| 20 std::wstring test_dir_wstring; | 20 FilePath test_dir; |
| 21 PathService::Get(chrome::DIR_TEST_DATA, &test_dir_wstring); | 21 PathService::Get(chrome::DIR_TEST_DATA, &test_dir); |
| 22 FilePath test_dir = FilePath::FromWStringHack(test_dir_wstring); | |
| 23 | 22 |
| 24 // Our simulated ~/Library directory | 23 // Our simulated ~/Library directory |
| 25 test_dir = test_dir.Append("safari_import"); | 24 test_dir = test_dir.AppendASCII("safari_import"); |
| 26 return test_dir; | 25 return test_dir; |
| 27 } | 26 } |
| 28 | 27 |
| 29 class SafariImporterTest : public PlatformTest { | 28 class SafariImporterTest : public PlatformTest { |
| 30 public: | 29 public: |
| 31 SafariImporter* GetSafariImporter() { | 30 SafariImporter* GetSafariImporter() { |
| 32 FilePath test_library_dir = GetTestSafariLibraryPath(); | 31 FilePath test_library_dir = GetTestSafariLibraryPath(); |
| 33 CHECK(file_util::PathExists(test_library_dir)) << | 32 CHECK(file_util::PathExists(test_library_dir)) << |
| 34 "Missing test data directory"; | 33 "Missing test data directory"; |
| 35 | 34 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 fav1.favicon_url.spec()); | 135 fav1.favicon_url.spec()); |
| 137 EXPECT_GT(fav1.png_data.size(), 0U); | 136 EXPECT_GT(fav1.png_data.size(), 0U); |
| 138 EXPECT_EQ(fav1.urls.size(), 2U); | 137 EXPECT_EQ(fav1.urls.size(), 2U); |
| 139 EXPECT_TRUE(fav1.urls.find(GURL("http://www.opensearch.org/Home")) | 138 EXPECT_TRUE(fav1.urls.find(GURL("http://www.opensearch.org/Home")) |
| 140 != fav1.urls.end()); | 139 != fav1.urls.end()); |
| 141 | 140 |
| 142 EXPECT_TRUE(fav1.urls.find( | 141 EXPECT_TRUE(fav1.urls.find( |
| 143 GURL("http://www.opensearch.org/Special:Search?search=lalala&go=Search")) | 142 GURL("http://www.opensearch.org/Special:Search?search=lalala&go=Search")) |
| 144 != fav1.urls.end()); | 143 != fav1.urls.end()); |
| 145 } | 144 } |
| OLD | NEW |