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

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

Issue 159668: First cut at Safari Import - Home Page & History Only. (Closed)
Patch Set: Fix Stuart's comments. Created 11 years, 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/importer/safari_importer.h"
6
7 #include "base/file_path.h"
8 #include "base/file_util.h"
9 #include "base/path_service.h"
10 #include "base/sys_string_conversions.h"
11 #include "chrome/common/chrome_paths.h"
12 #include "testing/platform_test.h"
13
14 // In order to test the Safari import functionality effectively, we store a
15 // simulated Library directory containing dummy data files in the same
16 // structure as ~/Library in the Chrome test data directory.
17 // This function returns the path to that directory.
18 FilePath GetTestSafariLibraryPath() {
19 std::wstring test_dir_wstring;
20 PathService::Get(chrome::DIR_TEST_DATA, &test_dir_wstring);
21 FilePath test_dir = FilePath::FromWStringHack(test_dir_wstring);
22
23 // Our simulated ~/Library directory
24 test_dir = test_dir.Append("safari_import");
25 return test_dir;
26 }
27
28 class SafariImporterTest : public PlatformTest {};
29
30 TEST_F(SafariImporterTest, HistoryImport) {
31 FilePath test_library_dir = GetTestSafariLibraryPath();
32 ASSERT_TRUE(file_util::PathExists(test_library_dir)) <<
33 "Missing test data directory";
34
35 scoped_refptr<SafariImporter> importer(
36 new SafariImporter(test_library_dir));
37
38 std::vector<history::URLRow> history_items;
39 importer->ParseHistoryItems(&history_items);
40
41 // Should be 2 history items.
42 ASSERT_EQ(history_items.size(), 2U);
43
44 history::URLRow& it1 = history_items[0];
45 EXPECT_EQ(it1.url(), GURL("http://www.firsthistoryitem.com/"));
46 EXPECT_EQ(it1.title(), L"First History Item Title");
47 EXPECT_EQ(it1.visit_count(), 1);
48 EXPECT_EQ(it1.hidden(), 0);
49 EXPECT_EQ(it1.typed_count(), 0);
50 EXPECT_EQ(it1.last_visit().ToDoubleT(),
51 importer->HistoryTimeToEpochTime(@"270598264.4"));
52
53 history::URLRow& it2 = history_items[1];
54 std::string second_item_title("http://www.secondhistoryitem.com/");
55 EXPECT_EQ(it2.url(), GURL(second_item_title));
56 // The second item lacks a title so we expect the URL to be substituted.
57 EXPECT_EQ(base::SysWideToUTF8(it2.title()), second_item_title.c_str());
58 EXPECT_EQ(it2.visit_count(), 55);
59 EXPECT_EQ(it2.hidden(), 0);
60 EXPECT_EQ(it2.typed_count(), 0);
61 EXPECT_EQ(it2.last_visit().ToDoubleT(),
62 importer->HistoryTimeToEpochTime(@"270598231.4"));
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698