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

Side by Side Diff: chrome/browser/importer/safari_importer_unittest.mm

Issue 326024: Mac: remove some now-dead code and add a comment. (Closed)
Patch Set: Further changes as requested by Jeremy. Created 11 years, 2 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
« no previous file with comments | « chrome/browser/importer/safari_importer.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 EXPECT_EQ(entry.in_toolbar, kImportedBookmarksData[i].in_toolbar); 100 EXPECT_EQ(entry.in_toolbar, kImportedBookmarksData[i].in_toolbar);
101 EXPECT_EQ(entry.url, kImportedBookmarksData[i].url); 101 EXPECT_EQ(entry.url, kImportedBookmarksData[i].url);
102 if (kImportedBookmarksData[i].path_is_empty) { 102 if (kImportedBookmarksData[i].path_is_empty) {
103 EXPECT_EQ(entry.path.size(), 0U); 103 EXPECT_EQ(entry.path.size(), 0U);
104 } else { 104 } else {
105 EXPECT_EQ(entry.path.size(), 1U); 105 EXPECT_EQ(entry.path.size(), 1U);
106 EXPECT_EQ(entry.path[0], kImportedBookmarksData[i].path); 106 EXPECT_EQ(entry.path[0], kImportedBookmarksData[i].path);
107 EXPECT_EQ(entry.title, kImportedBookmarksData[i].title); 107 EXPECT_EQ(entry.title, kImportedBookmarksData[i].title);
108 } 108 }
109 } 109 }
110
111 } 110 }
112 111
113 TEST_F(SafariImporterTest, FavIconImport) { 112 TEST_F(SafariImporterTest, FavIconImport) {
114 scoped_refptr<SafariImporter> importer(GetSafariImporter()); 113 scoped_refptr<SafariImporter> importer(GetSafariImporter());
115 sqlite_utils::scoped_sqlite_db_ptr db(importer->OpenFavIconDB()); 114 sqlite_utils::scoped_sqlite_db_ptr db(importer->OpenFavIconDB());
116 ASSERT_TRUE(db.get() != NULL); 115 ASSERT_TRUE(db.get() != NULL);
117 116
118 SafariImporter::FaviconMap favicon_map; 117 SafariImporter::FaviconMap favicon_map;
119 importer->ImportFavIconURLs(db.get(), &favicon_map); 118 importer->ImportFavIconURLs(db.get(), &favicon_map);
120 119
(...skipping 20 matching lines...) Expand all
141 != fav1.urls.end()); 140 != fav1.urls.end());
142 141
143 EXPECT_TRUE(fav1.urls.find( 142 EXPECT_TRUE(fav1.urls.find(
144 GURL("http://www.opensearch.org/Special:Search?search=lalala&go=Search")) 143 GURL("http://www.opensearch.org/Special:Search?search=lalala&go=Search"))
145 != fav1.urls.end()); 144 != fav1.urls.end());
146 } 145 }
147 146
148 TEST_F(SafariImporterTest, CanImport) { 147 TEST_F(SafariImporterTest, CanImport) {
149 uint16 items = NONE; 148 uint16 items = NONE;
150 EXPECT_TRUE(SafariImporter::CanImport(GetTestSafariLibraryPath(), &items)); 149 EXPECT_TRUE(SafariImporter::CanImport(GetTestSafariLibraryPath(), &items));
151 // We can't check the exact value of items because the HOME_PAGE bit depends 150 EXPECT_EQ(items, HISTORY | FAVORITES);
152 // on the defaults of the current machine.
153 EXPECT_EQ(items & HISTORY, HISTORY);
154 EXPECT_EQ(items & FAVORITES, FAVORITES);
155 EXPECT_EQ(items & COOKIES, NONE); 151 EXPECT_EQ(items & COOKIES, NONE);
156 EXPECT_EQ(items & PASSWORDS, NONE); 152 EXPECT_EQ(items & PASSWORDS, NONE);
157 EXPECT_EQ(items & SEARCH_ENGINES, NONE); 153 EXPECT_EQ(items & SEARCH_ENGINES, NONE);
154 EXPECT_EQ(items & HOME_PAGE, NONE);
158 155
159 // Check that we don't import anything from a bogus library directory. 156 // Check that we don't import anything from a bogus library directory.
160 FilePath fake_library_dir; 157 FilePath fake_library_dir;
161 file_util::CreateNewTempDirectory("FakeSafariLibrary", &fake_library_dir); 158 file_util::CreateNewTempDirectory("FakeSafariLibrary", &fake_library_dir);
162 FileAutoDeleter deleter(fake_library_dir); 159 FileAutoDeleter deleter(fake_library_dir);
163 160 EXPECT_FALSE(SafariImporter::CanImport(fake_library_dir, &items));
164 // Despite the fact that we're pointing to an empty library directory,
165 // CanImport may still return true on systems where the Safari defaults
166 // are defined. This means that we can't make assumptions about the return
167 // value here.
168 SafariImporter::CanImport(fake_library_dir, &items);
169 EXPECT_EQ(items & ~HOME_PAGE, NONE); // See comment above about HOME_PAGE.
170
171
172 } 161 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/safari_importer.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698