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

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

Issue 4079: Porting refactoring changes:... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <windows.h> 7 #include <windows.h>
8 #include <unknwn.h> 8 #include <unknwn.h>
9 #include <intshcut.h> 9 #include <intshcut.h>
10 #include <pstore.h> 10 #include <pstore.h>
11 #include <urlhist.h> 11 #include <urlhist.h>
12 #include <shlguid.h> 12 #include <shlguid.h>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "chrome/browser/ie7_password.h" 17 #include "chrome/browser/ie7_password.h"
18 #include "chrome/browser/importer/ie_importer.h" 18 #include "chrome/browser/importer/ie_importer.h"
19 #include "chrome/browser/importer/importer.h" 19 #include "chrome/browser/importer/importer.h"
20 #include "chrome/browser/profile.h" 20 #include "chrome/browser/profile.h"
21 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/env_util.h"
23 #include "chrome/common/win_util.h" 22 #include "chrome/common/win_util.h"
24 23
25 class ImporterTest : public testing::Test { 24 class ImporterTest : public testing::Test {
26 public: 25 public:
27 protected: 26 protected:
28 virtual void SetUp() { 27 virtual void SetUp() {
29 // Creates a new profile in a new subdirectory in the temp directory. 28 // Creates a new profile in a new subdirectory in the temp directory.
30 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_path_)); 29 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_path_));
31 file_util::AppendToPath(&test_path_, L"ImporterTest"); 30 file_util::AppendToPath(&test_path_, L"ImporterTest");
32 file_util::Delete(test_path_, true); 31 file_util::Delete(test_path_, true);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 266
268 for (int i = 0; i < arraysize(items); ++i) { 267 for (int i = 0; i < arraysize(items); ++i) {
269 HRESULT res = pstore->WriteItem(0, type, subtype, items[i].name, 268 HRESULT res = pstore->WriteItem(0, type, subtype, items[i].name,
270 items[i].data_size, reinterpret_cast<BYTE*>(items[i].data), 269 items[i].data_size, reinterpret_cast<BYTE*>(items[i].data),
271 NULL, 0, 0); 270 NULL, 0, 0);
272 ASSERT_TRUE(res == PST_E_OK); 271 ASSERT_TRUE(res == PST_E_OK);
273 } 272 }
274 } 273 }
275 274
276 TEST_F(ImporterTest, IEImporter) { 275 TEST_F(ImporterTest, IEImporter) {
277 // Skips in Win2000 for the running environment can not be set up.
278 if (env_util::GetOperatingSystemVersion() == "5.0")
279 return;
280
281 // Sets up a favorites folder. 276 // Sets up a favorites folder.
282 win_util::ScopedCOMInitializer com_init; 277 win_util::ScopedCOMInitializer com_init;
283 std::wstring path = test_path_; 278 std::wstring path = test_path_;
284 file_util::AppendToPath(&path, L"Favorites"); 279 file_util::AppendToPath(&path, L"Favorites");
285 CreateDirectory(path.c_str(), NULL); 280 CreateDirectory(path.c_str(), NULL);
286 CreateDirectory((path + L"\\SubFolder").c_str(), NULL); 281 CreateDirectory((path + L"\\SubFolder").c_str(), NULL);
287 CreateDirectory((path + L"\\Links").c_str(), NULL); 282 CreateDirectory((path + L"\\Links").c_str(), NULL);
288 CreateDirectory((path + L"\\Links\\SubFolderOfLinks").c_str(), NULL); 283 CreateDirectory((path + L"\\Links\\SubFolderOfLinks").c_str(), NULL);
289 CreateDirectory((path + L"\\\x0061").c_str(), NULL); 284 CreateDirectory((path + L"\\\x0061").c_str(), NULL);
290 ASSERT_TRUE(CreateUrlFile(path + L"\\Google Home Page.url", 285 ASSERT_TRUE(CreateUrlFile(path + L"\\Google Home Page.url",
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 profile_info.source_path = profile_path_; 811 profile_info.source_path = profile_path_;
817 scoped_refptr<ImporterHost> host = new ImporterHost(loop); 812 scoped_refptr<ImporterHost> host = new ImporterHost(loop);
818 Firefox3Observer* observer = new Firefox3Observer(); 813 Firefox3Observer* observer = new Firefox3Observer();
819 host->SetObserver(observer); 814 host->SetObserver(observer);
820 loop->PostTask(FROM_HERE, NewRunnableMethod(host.get(), 815 loop->PostTask(FROM_HERE, NewRunnableMethod(host.get(),
821 &ImporterHost::StartImportSettings, profile_info, 816 &ImporterHost::StartImportSettings, profile_info,
822 HISTORY | PASSWORDS | FAVORITES | SEARCH_ENGINES, observer, true)); 817 HISTORY | PASSWORDS | FAVORITES | SEARCH_ENGINES, observer, true));
823 loop->Run(); 818 loop->Run();
824 } 819 }
825 820
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698