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

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

Issue 94013004: Add base:: to string16s in chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try again Created 7 years 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 "chrome/utility/importer/safari_importer.h" 5 #include "chrome/utility/importer/safari_importer.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.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/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 EXPECT_EQ(it2.last_visit.ToDoubleT(), 75 EXPECT_EQ(it2.last_visit.ToDoubleT(),
76 importer->HistoryTimeToEpochTime(@"270598231.4")); 76 importer->HistoryTimeToEpochTime(@"270598231.4"));
77 } 77 }
78 78
79 TEST_F(SafariImporterTest, BookmarkImport) { 79 TEST_F(SafariImporterTest, BookmarkImport) {
80 // Expected results 80 // Expected results
81 const struct { 81 const struct {
82 bool in_toolbar; 82 bool in_toolbar;
83 GURL url; 83 GURL url;
84 // We store the path with levels of nesting delimited by forward slashes. 84 // We store the path with levels of nesting delimited by forward slashes.
85 string16 path; 85 base::string16 path;
86 string16 title; 86 base::string16 title;
87 } kImportedBookmarksData[] = { 87 } kImportedBookmarksData[] = {
88 { 88 {
89 true, 89 true,
90 GURL("http://www.apple.com/"), 90 GURL("http://www.apple.com/"),
91 ASCIIToUTF16("Toolbar/"), 91 ASCIIToUTF16("Toolbar/"),
92 ASCIIToUTF16("Apple") 92 ASCIIToUTF16("Apple")
93 }, 93 },
94 { 94 {
95 true, 95 true,
96 GURL("http://www.yahoo.com/"), 96 GURL("http://www.yahoo.com/"),
97 ASCIIToUTF16("Toolbar/"), 97 ASCIIToUTF16("Toolbar/"),
98 ASCIIToUTF16("Yahoo!") 98 ASCIIToUTF16("Yahoo!")
99 }, 99 },
100 { 100 {
101 true, 101 true,
102 GURL("http://www.cnn.com/"), 102 GURL("http://www.cnn.com/"),
103 ASCIIToUTF16("Toolbar/News"), 103 ASCIIToUTF16("Toolbar/News"),
104 ASCIIToUTF16("CNN") 104 ASCIIToUTF16("CNN")
105 }, 105 },
106 { 106 {
107 true, 107 true,
108 GURL("http://www.nytimes.com/"), 108 GURL("http://www.nytimes.com/"),
109 ASCIIToUTF16("Toolbar/News"), 109 ASCIIToUTF16("Toolbar/News"),
110 ASCIIToUTF16("The New York Times") 110 ASCIIToUTF16("The New York Times")
111 }, 111 },
112 { 112 {
113 false, 113 false,
114 GURL("http://www.reddit.com/"), 114 GURL("http://www.reddit.com/"),
115 string16(), 115 base::string16(),
116 ASCIIToUTF16("reddit.com: what's new online!") 116 ASCIIToUTF16("reddit.com: what's new online!")
117 }, 117 },
118 { 118 {
119 false, 119 false,
120 GURL(), 120 GURL(),
121 string16(), 121 base::string16(),
122 ASCIIToUTF16("Empty Folder") 122 ASCIIToUTF16("Empty Folder")
123 }, 123 },
124 { 124 {
125 false, 125 false,
126 GURL("http://www.webkit.org/blog/"), 126 GURL("http://www.webkit.org/blog/"),
127 string16(), 127 base::string16(),
128 ASCIIToUTF16("Surfin' Safari - The WebKit Blog") 128 ASCIIToUTF16("Surfin' Safari - The WebKit Blog")
129 }, 129 },
130 }; 130 };
131 131
132 scoped_refptr<SafariImporter> importer(GetSafariImporter()); 132 scoped_refptr<SafariImporter> importer(GetSafariImporter());
133 std::vector<ImportedBookmarkEntry> bookmarks; 133 std::vector<ImportedBookmarkEntry> bookmarks;
134 importer->ParseBookmarks(ASCIIToUTF16("Toolbar"), &bookmarks); 134 importer->ParseBookmarks(ASCIIToUTF16("Toolbar"), &bookmarks);
135 size_t num_bookmarks = bookmarks.size(); 135 size_t num_bookmarks = bookmarks.size();
136 ASSERT_EQ(ARRAYSIZE_UNSAFE(kImportedBookmarksData), num_bookmarks); 136 ASSERT_EQ(ARRAYSIZE_UNSAFE(kImportedBookmarksData), num_bookmarks);
137 137
138 for (size_t i = 0; i < num_bookmarks; ++i) { 138 for (size_t i = 0; i < num_bookmarks; ++i) {
139 ImportedBookmarkEntry& entry = bookmarks[i]; 139 ImportedBookmarkEntry& entry = bookmarks[i];
140 EXPECT_EQ(kImportedBookmarksData[i].in_toolbar, entry.in_toolbar); 140 EXPECT_EQ(kImportedBookmarksData[i].in_toolbar, entry.in_toolbar);
141 EXPECT_EQ(kImportedBookmarksData[i].url, entry.url); 141 EXPECT_EQ(kImportedBookmarksData[i].url, entry.url);
142 142
143 std::vector<string16> path; 143 std::vector<base::string16> path;
144 Tokenize(kImportedBookmarksData[i].path, ASCIIToUTF16("/"), &path); 144 Tokenize(kImportedBookmarksData[i].path, ASCIIToUTF16("/"), &path);
145 ASSERT_EQ(path.size(), entry.path.size()); 145 ASSERT_EQ(path.size(), entry.path.size());
146 for (size_t j = 0; j < path.size(); ++j) { 146 for (size_t j = 0; j < path.size(); ++j) {
147 EXPECT_EQ(path[j], entry.path[j]); 147 EXPECT_EQ(path[j], entry.path[j]);
148 } 148 }
149 149
150 EXPECT_EQ(kImportedBookmarksData[i].title, entry.title); 150 EXPECT_EQ(kImportedBookmarksData[i].title, entry.title);
151 } 151 }
152 } 152 }
153 153
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 EXPECT_EQ(items & importer::COOKIES, importer::NONE); 193 EXPECT_EQ(items & importer::COOKIES, importer::NONE);
194 EXPECT_EQ(items & importer::PASSWORDS, importer::NONE); 194 EXPECT_EQ(items & importer::PASSWORDS, importer::NONE);
195 EXPECT_EQ(items & importer::SEARCH_ENGINES, importer::NONE); 195 EXPECT_EQ(items & importer::SEARCH_ENGINES, importer::NONE);
196 EXPECT_EQ(items & importer::HOME_PAGE, importer::NONE); 196 EXPECT_EQ(items & importer::HOME_PAGE, importer::NONE);
197 197
198 // Check that we don't import anything from a bogus library directory. 198 // Check that we don't import anything from a bogus library directory.
199 base::ScopedTempDir fake_library_dir; 199 base::ScopedTempDir fake_library_dir;
200 ASSERT_TRUE(fake_library_dir.CreateUniqueTempDir()); 200 ASSERT_TRUE(fake_library_dir.CreateUniqueTempDir());
201 EXPECT_FALSE(SafariImporterCanImport(fake_library_dir.path(), &items)); 201 EXPECT_FALSE(SafariImporterCanImport(fake_library_dir.path(), &items));
202 } 202 }
OLDNEW
« no previous file with comments | « chrome/utility/importer/safari_importer.mm ('k') | chrome/utility/media_galleries/itunes_library_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698