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

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

Issue 12212048: Linux/ChromeOS Chromium style checker cleanup, chrome/browser edition. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/bind.h" 7 #include "base/bind.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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} 134 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {}
135 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} 135 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {}
136 virtual void ImportEnded() OVERRIDE { 136 virtual void ImportEnded() OVERRIDE {
137 MessageLoop::current()->Quit(); 137 MessageLoop::current()->Quit();
138 EXPECT_EQ(arraysize(kFirefox2Bookmarks), bookmark_count_); 138 EXPECT_EQ(arraysize(kFirefox2Bookmarks), bookmark_count_);
139 EXPECT_EQ(1U, history_count_); 139 EXPECT_EQ(1U, history_count_);
140 EXPECT_EQ(arraysize(kFirefox2Passwords), password_count_); 140 EXPECT_EQ(arraysize(kFirefox2Passwords), password_count_);
141 EXPECT_EQ(arraysize(kFirefox2Keywords), keyword_count_); 141 EXPECT_EQ(arraysize(kFirefox2Keywords), keyword_count_);
142 } 142 }
143 143
144 virtual bool BookmarkModelIsLoaded() const { 144 virtual bool BookmarkModelIsLoaded() const OVERRIDE {
145 // Profile is ready for writing. 145 // Profile is ready for writing.
146 return true; 146 return true;
147 } 147 }
148 148
149 virtual bool TemplateURLServiceIsLoaded() const { 149 virtual bool TemplateURLServiceIsLoaded() const OVERRIDE {
150 return true; 150 return true;
151 } 151 }
152 152
153 virtual void AddPasswordForm(const content::PasswordForm& form) { 153 virtual void AddPasswordForm(const content::PasswordForm& form) OVERRIDE {
154 PasswordInfo p = kFirefox2Passwords[password_count_]; 154 PasswordInfo p = kFirefox2Passwords[password_count_];
155 EXPECT_EQ(p.origin, form.origin.spec()); 155 EXPECT_EQ(p.origin, form.origin.spec());
156 EXPECT_EQ(p.realm, form.signon_realm); 156 EXPECT_EQ(p.realm, form.signon_realm);
157 EXPECT_EQ(p.action, form.action.spec()); 157 EXPECT_EQ(p.action, form.action.spec());
158 EXPECT_EQ(WideToUTF16(p.username_element), form.username_element); 158 EXPECT_EQ(WideToUTF16(p.username_element), form.username_element);
159 EXPECT_EQ(WideToUTF16(p.username), form.username_value); 159 EXPECT_EQ(WideToUTF16(p.username), form.username_value);
160 EXPECT_EQ(WideToUTF16(p.password_element), form.password_element); 160 EXPECT_EQ(WideToUTF16(p.password_element), form.password_element);
161 EXPECT_EQ(WideToUTF16(p.password), form.password_value); 161 EXPECT_EQ(WideToUTF16(p.password), form.password_value);
162 EXPECT_EQ(p.blacklisted, form.blacklisted_by_user); 162 EXPECT_EQ(p.blacklisted, form.blacklisted_by_user);
163 ++password_count_; 163 ++password_count_;
164 } 164 }
165 165
166 virtual void AddHistoryPage(const history::URLRows& page, 166 virtual void AddHistoryPage(const history::URLRows& page,
167 history::VisitSource visit_source) { 167 history::VisitSource visit_source) OVERRIDE {
168 ASSERT_EQ(1U, page.size()); 168 ASSERT_EQ(1U, page.size());
169 EXPECT_EQ("http://en-us.www.mozilla.com/", page[0].url().spec()); 169 EXPECT_EQ("http://en-us.www.mozilla.com/", page[0].url().spec());
170 EXPECT_EQ(ASCIIToUTF16("Firefox Updated"), page[0].title()); 170 EXPECT_EQ(ASCIIToUTF16("Firefox Updated"), page[0].title());
171 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source); 171 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source);
172 ++history_count_; 172 ++history_count_;
173 } 173 }
174 174
175 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks, 175 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks,
176 const string16& top_level_folder_name) OVERRIDE { 176 const string16& top_level_folder_name) OVERRIDE {
177 for (size_t i = 0; i < bookmarks.size(); ++i) { 177 for (size_t i = 0; i < bookmarks.size(); ++i) {
178 if (FindBookmarkEntry(bookmarks[i], kFirefox2Bookmarks, 178 if (FindBookmarkEntry(bookmarks[i], kFirefox2Bookmarks,
179 arraysize(kFirefox2Bookmarks))) 179 arraysize(kFirefox2Bookmarks)))
180 ++bookmark_count_; 180 ++bookmark_count_;
181 } 181 }
182 } 182 }
183 183
184 virtual void AddKeywords(ScopedVector<TemplateURL> template_urls, 184 virtual void AddKeywords(ScopedVector<TemplateURL> template_urls,
185 bool unique_on_host_and_path) { 185 bool unique_on_host_and_path) OVERRIDE {
186 for (size_t i = 0; i < template_urls.size(); ++i) { 186 for (size_t i = 0; i < template_urls.size(); ++i) {
187 // The order might not be deterministic, look in the expected list for 187 // The order might not be deterministic, look in the expected list for
188 // that template URL. 188 // that template URL.
189 bool found = false; 189 bool found = false;
190 string16 keyword = template_urls[i]->keyword(); 190 string16 keyword = template_urls[i]->keyword();
191 for (size_t j = 0; j < arraysize(kFirefox2Keywords); ++j) { 191 for (size_t j = 0; j < arraysize(kFirefox2Keywords); ++j) {
192 if (template_urls[i]->keyword() == 192 if (template_urls[i]->keyword() ==
193 WideToUTF16Hack(kFirefox2Keywords[j].keyword)) { 193 WideToUTF16Hack(kFirefox2Keywords[j].keyword)) {
194 EXPECT_EQ(kFirefox2Keywords[j].url, template_urls[i]->url()); 194 EXPECT_EQ(kFirefox2Keywords[j].url, template_urls[i]->url());
195 found = true; 195 found = true;
196 break; 196 break;
197 } 197 }
198 } 198 }
199 EXPECT_TRUE(found); 199 EXPECT_TRUE(found);
200 ++keyword_count_; 200 ++keyword_count_;
201 } 201 }
202 } 202 }
203 203
204 void AddFavicons(const std::vector<history::ImportedFaviconUsage>& favicons) { 204 virtual void AddFavicons(
205 const std::vector<history::ImportedFaviconUsage>& favicons) OVERRIDE {
205 } 206 }
206 207
207 private: 208 private:
208 ~FirefoxObserver() {} 209 virtual ~FirefoxObserver() {}
209 210
210 size_t bookmark_count_; 211 size_t bookmark_count_;
211 size_t history_count_; 212 size_t history_count_;
212 size_t password_count_; 213 size_t password_count_;
213 size_t keyword_count_; 214 size_t keyword_count_;
214 }; 215 };
215 216
216 const BookmarkInfo kFirefox3Bookmarks[] = { 217 const BookmarkInfo kFirefox3Bookmarks[] = {
217 {true, 1, {L"Bookmarks Toolbar"}, 218 {true, 1, {L"Bookmarks Toolbar"},
218 L"Toolbar", 219 L"Toolbar",
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} 280 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {}
280 virtual void ImportEnded() OVERRIDE { 281 virtual void ImportEnded() OVERRIDE {
281 MessageLoop::current()->Quit(); 282 MessageLoop::current()->Quit();
282 EXPECT_EQ(arraysize(kFirefox3Bookmarks), bookmark_count_); 283 EXPECT_EQ(arraysize(kFirefox3Bookmarks), bookmark_count_);
283 EXPECT_EQ(1U, history_count_); 284 EXPECT_EQ(1U, history_count_);
284 EXPECT_EQ(arraysize(kFirefox3Passwords), password_count_); 285 EXPECT_EQ(arraysize(kFirefox3Passwords), password_count_);
285 if (import_search_engines_) 286 if (import_search_engines_)
286 EXPECT_EQ(arraysize(kFirefox3Keywords), keyword_count_); 287 EXPECT_EQ(arraysize(kFirefox3Keywords), keyword_count_);
287 } 288 }
288 289
289 virtual bool BookmarkModelIsLoaded() const { 290 virtual bool BookmarkModelIsLoaded() const OVERRIDE {
290 // Profile is ready for writing. 291 // Profile is ready for writing.
291 return true; 292 return true;
292 } 293 }
293 294
294 virtual bool TemplateURLServiceIsLoaded() const { 295 virtual bool TemplateURLServiceIsLoaded() const OVERRIDE {
295 return true; 296 return true;
296 } 297 }
297 298
298 virtual void AddPasswordForm(const content::PasswordForm& form) { 299 virtual void AddPasswordForm(const content::PasswordForm& form) OVERRIDE {
299 PasswordInfo p = kFirefox3Passwords[password_count_]; 300 PasswordInfo p = kFirefox3Passwords[password_count_];
300 EXPECT_EQ(p.origin, form.origin.spec()); 301 EXPECT_EQ(p.origin, form.origin.spec());
301 EXPECT_EQ(p.realm, form.signon_realm); 302 EXPECT_EQ(p.realm, form.signon_realm);
302 EXPECT_EQ(p.action, form.action.spec()); 303 EXPECT_EQ(p.action, form.action.spec());
303 EXPECT_EQ(WideToUTF16(p.username_element), form.username_element); 304 EXPECT_EQ(WideToUTF16(p.username_element), form.username_element);
304 EXPECT_EQ(WideToUTF16(p.username), form.username_value); 305 EXPECT_EQ(WideToUTF16(p.username), form.username_value);
305 EXPECT_EQ(WideToUTF16(p.password_element), form.password_element); 306 EXPECT_EQ(WideToUTF16(p.password_element), form.password_element);
306 EXPECT_EQ(WideToUTF16(p.password), form.password_value); 307 EXPECT_EQ(WideToUTF16(p.password), form.password_value);
307 EXPECT_EQ(p.blacklisted, form.blacklisted_by_user); 308 EXPECT_EQ(p.blacklisted, form.blacklisted_by_user);
308 ++password_count_; 309 ++password_count_;
309 } 310 }
310 311
311 virtual void AddHistoryPage(const history::URLRows& page, 312 virtual void AddHistoryPage(const history::URLRows& page,
312 history::VisitSource visit_source) { 313 history::VisitSource visit_source) OVERRIDE {
313 ASSERT_EQ(3U, page.size()); 314 ASSERT_EQ(3U, page.size());
314 EXPECT_EQ("http://www.google.com/", page[0].url().spec()); 315 EXPECT_EQ("http://www.google.com/", page[0].url().spec());
315 EXPECT_EQ(ASCIIToUTF16("Google"), page[0].title()); 316 EXPECT_EQ(ASCIIToUTF16("Google"), page[0].title());
316 EXPECT_EQ("http://www.google.com/", page[1].url().spec()); 317 EXPECT_EQ("http://www.google.com/", page[1].url().spec());
317 EXPECT_EQ(ASCIIToUTF16("Google"), page[1].title()); 318 EXPECT_EQ(ASCIIToUTF16("Google"), page[1].title());
318 EXPECT_EQ("http://www.cs.unc.edu/~jbs/resources/perl/perl-cgi/programs/" 319 EXPECT_EQ("http://www.cs.unc.edu/~jbs/resources/perl/perl-cgi/programs/"
319 "form1-POST.html", page[2].url().spec()); 320 "form1-POST.html", page[2].url().spec());
320 EXPECT_EQ(ASCIIToUTF16("example form (POST)"), page[2].title()); 321 EXPECT_EQ(ASCIIToUTF16("example form (POST)"), page[2].title());
321 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source); 322 EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source);
322 ++history_count_; 323 ++history_count_;
323 } 324 }
324 325
325 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks, 326 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks,
326 const string16& top_level_folder_name) OVERRIDE { 327 const string16& top_level_folder_name) OVERRIDE {
327 for (size_t i = 0; i < bookmarks.size(); ++i) { 328 for (size_t i = 0; i < bookmarks.size(); ++i) {
328 if (FindBookmarkEntry(bookmarks[i], kFirefox3Bookmarks, 329 if (FindBookmarkEntry(bookmarks[i], kFirefox3Bookmarks,
329 arraysize(kFirefox3Bookmarks))) 330 arraysize(kFirefox3Bookmarks)))
330 ++bookmark_count_; 331 ++bookmark_count_;
331 } 332 }
332 } 333 }
333 334
334 void AddKeywords(ScopedVector<TemplateURL> template_urls, 335 virtual void AddKeywords(ScopedVector<TemplateURL> template_urls,
335 bool unique_on_host_and_path) { 336 bool unique_on_host_and_path) OVERRIDE {
336 for (size_t i = 0; i < template_urls.size(); ++i) { 337 for (size_t i = 0; i < template_urls.size(); ++i) {
337 // The order might not be deterministic, look in the expected list for 338 // The order might not be deterministic, look in the expected list for
338 // that template URL. 339 // that template URL.
339 bool found = false; 340 bool found = false;
340 string16 keyword = template_urls[i]->keyword(); 341 string16 keyword = template_urls[i]->keyword();
341 for (size_t j = 0; j < arraysize(kFirefox3Keywords); ++j) { 342 for (size_t j = 0; j < arraysize(kFirefox3Keywords); ++j) {
342 if (template_urls[i]->keyword() == 343 if (template_urls[i]->keyword() ==
343 WideToUTF16Hack(kFirefox3Keywords[j].keyword)) { 344 WideToUTF16Hack(kFirefox3Keywords[j].keyword)) {
344 EXPECT_EQ(kFirefox3Keywords[j].url, template_urls[i]->url()); 345 EXPECT_EQ(kFirefox3Keywords[j].url, template_urls[i]->url());
345 found = true; 346 found = true;
346 break; 347 break;
347 } 348 }
348 } 349 }
349 EXPECT_TRUE(found); 350 EXPECT_TRUE(found);
350 ++keyword_count_; 351 ++keyword_count_;
351 } 352 }
352 } 353 }
353 354
354 void AddFavicons(const std::vector<history::ImportedFaviconUsage>& favicons) { 355 virtual void AddFavicons(
356 const std::vector<history::ImportedFaviconUsage>& favicons) OVERRIDE {
355 } 357 }
356 358
357 private: 359 private:
358 ~Firefox3Observer() {} 360 virtual ~Firefox3Observer() {}
359 361
360 size_t bookmark_count_; 362 size_t bookmark_count_;
361 size_t history_count_; 363 size_t history_count_;
362 size_t password_count_; 364 size_t password_count_;
363 size_t keyword_count_; 365 size_t keyword_count_;
364 bool import_search_engines_; 366 bool import_search_engines_;
365 }; 367 };
366 368
367 } // namespace 369 } // namespace
368 370
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); 757 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec());
756 EXPECT_EQ(0U, entry.path.size()); 758 EXPECT_EQ(0U, entry.path.size());
757 entry = *it++; 759 entry = *it++;
758 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); 760 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title);
759 EXPECT_EQ("http://www.google.com/", entry.url.spec()); 761 EXPECT_EQ("http://www.google.com/", entry.url.spec());
760 EXPECT_EQ(0U, entry.path.size()); 762 EXPECT_EQ(0U, entry.path.size());
761 } 763 }
762 764
763 importer->Release(); 765 importer->Release();
764 } 766 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698