OLD | NEW |
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_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 history_count_ = 0; | 135 history_count_ = 0; |
136 password_count_ = 0; | 136 password_count_ = 0; |
137 keyword_count_ = 0; | 137 keyword_count_ = 0; |
138 } | 138 } |
139 | 139 |
140 // importer::ImporterProgressObserver: | 140 // importer::ImporterProgressObserver: |
141 virtual void ImportStarted() OVERRIDE {} | 141 virtual void ImportStarted() OVERRIDE {} |
142 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} | 142 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} |
143 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} | 143 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} |
144 virtual void ImportEnded() OVERRIDE { | 144 virtual void ImportEnded() OVERRIDE { |
145 MessageLoop::current()->Quit(); | 145 base::MessageLoop::current()->Quit(); |
146 EXPECT_EQ(arraysize(kFirefox2Bookmarks), bookmark_count_); | 146 EXPECT_EQ(arraysize(kFirefox2Bookmarks), bookmark_count_); |
147 EXPECT_EQ(1U, history_count_); | 147 EXPECT_EQ(1U, history_count_); |
148 EXPECT_EQ(arraysize(kFirefox2Passwords), password_count_); | 148 EXPECT_EQ(arraysize(kFirefox2Passwords), password_count_); |
149 EXPECT_EQ(arraysize(kFirefox2Keywords), keyword_count_); | 149 EXPECT_EQ(arraysize(kFirefox2Keywords), keyword_count_); |
150 } | 150 } |
151 | 151 |
152 virtual bool BookmarkModelIsLoaded() const OVERRIDE { | 152 virtual bool BookmarkModelIsLoaded() const OVERRIDE { |
153 // Profile is ready for writing. | 153 // Profile is ready for writing. |
154 return true; | 154 return true; |
155 } | 155 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 : ProfileWriter(NULL), bookmark_count_(0), history_count_(0), | 280 : ProfileWriter(NULL), bookmark_count_(0), history_count_(0), |
281 password_count_(0), keyword_count_(0), | 281 password_count_(0), keyword_count_(0), |
282 import_search_engines_(import_search_engines) { | 282 import_search_engines_(import_search_engines) { |
283 } | 283 } |
284 | 284 |
285 // importer::ImporterProgressObserver: | 285 // importer::ImporterProgressObserver: |
286 virtual void ImportStarted() OVERRIDE {} | 286 virtual void ImportStarted() OVERRIDE {} |
287 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} | 287 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} |
288 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} | 288 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} |
289 virtual void ImportEnded() OVERRIDE { | 289 virtual void ImportEnded() OVERRIDE { |
290 MessageLoop::current()->Quit(); | 290 base::MessageLoop::current()->Quit(); |
291 EXPECT_EQ(arraysize(kFirefox3Bookmarks), bookmark_count_); | 291 EXPECT_EQ(arraysize(kFirefox3Bookmarks), bookmark_count_); |
292 EXPECT_EQ(1U, history_count_); | 292 EXPECT_EQ(1U, history_count_); |
293 EXPECT_EQ(arraysize(kFirefox3Passwords), password_count_); | 293 EXPECT_EQ(arraysize(kFirefox3Passwords), password_count_); |
294 if (import_search_engines_) | 294 if (import_search_engines_) |
295 EXPECT_EQ(arraysize(kFirefox3Keywords), keyword_count_); | 295 EXPECT_EQ(arraysize(kFirefox3Keywords), keyword_count_); |
296 } | 296 } |
297 | 297 |
298 virtual bool BookmarkModelIsLoaded() const OVERRIDE { | 298 virtual bool BookmarkModelIsLoaded() const OVERRIDE { |
299 // Profile is ready for writing. | 299 // Profile is ready for writing. |
300 return true; | 300 return true; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 data_path = data_path.AppendASCII("firefox3_searchplugins"); | 409 data_path = data_path.AppendASCII("firefox3_searchplugins"); |
410 if (!file_util::PathExists(data_path)) { | 410 if (!file_util::PathExists(data_path)) { |
411 // TODO(maruel): Create search test data that we can open source! | 411 // TODO(maruel): Create search test data that we can open source! |
412 LOG(ERROR) << L"Missing internal test data"; | 412 LOG(ERROR) << L"Missing internal test data"; |
413 return; | 413 return; |
414 } | 414 } |
415 ASSERT_TRUE(file_util::CopyDirectory(data_path, | 415 ASSERT_TRUE(file_util::CopyDirectory(data_path, |
416 search_engine_path, false)); | 416 search_engine_path, false)); |
417 } | 417 } |
418 | 418 |
419 MessageLoop* loop = MessageLoop::current(); | 419 base::MessageLoop* loop = base::MessageLoop::current(); |
420 importer::SourceProfile source_profile; | 420 importer::SourceProfile source_profile; |
421 source_profile.importer_type = importer::TYPE_FIREFOX3; | 421 source_profile.importer_type = importer::TYPE_FIREFOX3; |
422 source_profile.app_path = app_path_; | 422 source_profile.app_path = app_path_; |
423 source_profile.source_path = profile_path_; | 423 source_profile.source_path = profile_path_; |
424 scoped_refptr<ImporterHost> host(new ImporterHost); | 424 scoped_refptr<ImporterHost> host(new ImporterHost); |
425 host->SetObserver(observer); | 425 host->SetObserver(observer); |
426 int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES; | 426 int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES; |
427 if (import_search_plugins) | 427 if (import_search_plugins) |
428 items = items | importer::SEARCH_ENGINES; | 428 items = items | importer::SEARCH_ENGINES; |
429 loop->PostTask(FROM_HERE, base::Bind( | 429 loop->PostTask(FROM_HERE, base::Bind( |
(...skipping 20 matching lines...) Expand all Loading... |
450 file_util::CreateDirectory(search_engine_path); | 450 file_util::CreateDirectory(search_engine_path); |
451 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 451 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
452 data_path = data_path.AppendASCII("firefox2_searchplugins"); | 452 data_path = data_path.AppendASCII("firefox2_searchplugins"); |
453 if (!file_util::PathExists(data_path)) { | 453 if (!file_util::PathExists(data_path)) { |
454 // TODO(maruel): Create test data that we can open source! | 454 // TODO(maruel): Create test data that we can open source! |
455 LOG(ERROR) << L"Missing internal test data"; | 455 LOG(ERROR) << L"Missing internal test data"; |
456 return; | 456 return; |
457 } | 457 } |
458 ASSERT_TRUE(file_util::CopyDirectory(data_path, search_engine_path, false)); | 458 ASSERT_TRUE(file_util::CopyDirectory(data_path, search_engine_path, false)); |
459 | 459 |
460 MessageLoop* loop = MessageLoop::current(); | 460 base::MessageLoop* loop = base::MessageLoop::current(); |
461 scoped_refptr<ImporterHost> host(new ImporterHost); | 461 scoped_refptr<ImporterHost> host(new ImporterHost); |
462 FirefoxObserver* observer = new FirefoxObserver(); | 462 FirefoxObserver* observer = new FirefoxObserver(); |
463 host->SetObserver(observer); | 463 host->SetObserver(observer); |
464 importer::SourceProfile source_profile; | 464 importer::SourceProfile source_profile; |
465 source_profile.importer_type = importer::TYPE_FIREFOX2; | 465 source_profile.importer_type = importer::TYPE_FIREFOX2; |
466 source_profile.app_path = app_path_; | 466 source_profile.app_path = app_path_; |
467 source_profile.source_path = profile_path_; | 467 source_profile.source_path = profile_path_; |
468 | 468 |
469 loop->PostTask(FROM_HERE, base::Bind( | 469 loop->PostTask(FROM_HERE, base::Bind( |
470 &ImporterHost::StartImportSettings, | 470 &ImporterHost::StartImportSettings, |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); | 764 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); |
765 EXPECT_EQ(0U, entry.path.size()); | 765 EXPECT_EQ(0U, entry.path.size()); |
766 entry = *it++; | 766 entry = *it++; |
767 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); | 767 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); |
768 EXPECT_EQ("http://www.google.com/", entry.url.spec()); | 768 EXPECT_EQ("http://www.google.com/", entry.url.spec()); |
769 EXPECT_EQ(0U, entry.path.size()); | 769 EXPECT_EQ(0U, entry.path.size()); |
770 } | 770 } |
771 | 771 |
772 importer->Release(); | 772 importer->Release(); |
773 } | 773 } |
OLD | NEW |