| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
| 12 #include "base/string16.h" |
| 12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 13 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
| 14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/history/history_types.h" | 16 #include "chrome/browser/history/history_types.h" |
| 16 #include "chrome/browser/importer/importer_bridge.h" | 17 #include "chrome/browser/importer/importer_bridge.h" |
| 17 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 18 #include "sql/connection.h" | 19 #include "sql/connection.h" |
| 19 #include "testing/platform_test.h" | 20 #include "testing/platform_test.h" |
| 20 | 21 |
| 21 // In order to test the Safari import functionality effectively, we store a | 22 // In order to test the Safari import functionality effectively, we store a |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 }, | 102 }, |
| 102 { | 103 { |
| 103 true, | 104 true, |
| 104 GURL("http://www.nytimes.com/"), | 105 GURL("http://www.nytimes.com/"), |
| 105 ASCIIToUTF16("Toolbar/News"), | 106 ASCIIToUTF16("Toolbar/News"), |
| 106 ASCIIToUTF16("The New York Times") | 107 ASCIIToUTF16("The New York Times") |
| 107 }, | 108 }, |
| 108 { | 109 { |
| 109 false, | 110 false, |
| 110 GURL("http://www.reddit.com/"), | 111 GURL("http://www.reddit.com/"), |
| 111 ASCIIToUTF16(""), | 112 string16(), |
| 112 ASCIIToUTF16("reddit.com: what's new online!") | 113 ASCIIToUTF16("reddit.com: what's new online!") |
| 113 }, | 114 }, |
| 114 { | 115 { |
| 115 false, | 116 false, |
| 116 GURL(), | 117 GURL(), |
| 117 ASCIIToUTF16(""), | 118 string16(), |
| 118 ASCIIToUTF16("Empty Folder") | 119 ASCIIToUTF16("Empty Folder") |
| 119 }, | 120 }, |
| 120 { | 121 { |
| 121 false, | 122 false, |
| 122 GURL("http://www.webkit.org/blog/"), | 123 GURL("http://www.webkit.org/blog/"), |
| 123 ASCIIToUTF16(""), | 124 string16(), |
| 124 ASCIIToUTF16("Surfin' Safari - The WebKit Blog") | 125 ASCIIToUTF16("Surfin' Safari - The WebKit Blog") |
| 125 }, | 126 }, |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 scoped_refptr<SafariImporter> importer(GetSafariImporter()); | 129 scoped_refptr<SafariImporter> importer(GetSafariImporter()); |
| 129 std::vector<ProfileWriter::BookmarkEntry> bookmarks; | 130 std::vector<ProfileWriter::BookmarkEntry> bookmarks; |
| 130 importer->ParseBookmarks(ASCIIToUTF16("Toolbar"), &bookmarks); | 131 importer->ParseBookmarks(ASCIIToUTF16("Toolbar"), &bookmarks); |
| 131 size_t num_bookmarks = bookmarks.size(); | 132 size_t num_bookmarks = bookmarks.size(); |
| 132 ASSERT_EQ(ARRAYSIZE_UNSAFE(kImportedBookmarksData), num_bookmarks); | 133 ASSERT_EQ(ARRAYSIZE_UNSAFE(kImportedBookmarksData), num_bookmarks); |
| 133 | 134 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 EXPECT_EQ(items & importer::COOKIES, importer::NONE); | 190 EXPECT_EQ(items & importer::COOKIES, importer::NONE); |
| 190 EXPECT_EQ(items & importer::PASSWORDS, importer::NONE); | 191 EXPECT_EQ(items & importer::PASSWORDS, importer::NONE); |
| 191 EXPECT_EQ(items & importer::SEARCH_ENGINES, importer::NONE); | 192 EXPECT_EQ(items & importer::SEARCH_ENGINES, importer::NONE); |
| 192 EXPECT_EQ(items & importer::HOME_PAGE, importer::NONE); | 193 EXPECT_EQ(items & importer::HOME_PAGE, importer::NONE); |
| 193 | 194 |
| 194 // Check that we don't import anything from a bogus library directory. | 195 // Check that we don't import anything from a bogus library directory. |
| 195 ScopedTempDir fake_library_dir; | 196 ScopedTempDir fake_library_dir; |
| 196 ASSERT_TRUE(fake_library_dir.CreateUniqueTempDir()); | 197 ASSERT_TRUE(fake_library_dir.CreateUniqueTempDir()); |
| 197 EXPECT_FALSE(SafariImporter::CanImport(fake_library_dir.path(), &items)); | 198 EXPECT_FALSE(SafariImporter::CanImport(fake_library_dir.path(), &items)); |
| 198 } | 199 } |
| OLD | NEW |