OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #else | 31 #else |
32 #define MAYBE_IMPORTER(x) x | 32 #define MAYBE_IMPORTER(x) x |
33 #endif | 33 #endif |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 struct PasswordInfo { | 37 struct PasswordInfo { |
38 const char* origin; | 38 const char* origin; |
39 const char* action; | 39 const char* action; |
40 const char* realm; | 40 const char* realm; |
41 const wchar_t* username_element; | 41 const char* username_element; |
42 const wchar_t* username; | 42 const char* username; |
43 const wchar_t* password_element; | 43 const char* password_element; |
44 const wchar_t* password; | 44 const char* password; |
45 bool blacklisted; | 45 bool blacklisted; |
46 }; | 46 }; |
47 | 47 |
48 struct KeywordInfo { | 48 struct KeywordInfo { |
49 const wchar_t* keyword; | 49 const wchar_t* keyword; |
50 const char* url; | 50 const char* url; |
51 }; | 51 }; |
52 | 52 |
53 const BookmarkInfo kFirefoxBookmarks[] = { | 53 const BookmarkInfo kFirefoxBookmarks[] = { |
54 {true, 1, {L"Bookmarks Toolbar"}, | 54 {true, 1, {"Bookmarks Toolbar"}, |
55 L"Toolbar", | 55 L"Toolbar", |
56 "http://site/"}, | 56 "http://site/"}, |
57 {false, 0, {}, | 57 {false, 0, {}, |
58 L"Title", | 58 L"Title", |
59 "http://www.google.com/"}, | 59 "http://www.google.com/"}, |
60 }; | 60 }; |
61 | 61 |
62 const PasswordInfo kFirefoxPasswords[] = { | 62 const PasswordInfo kFirefoxPasswords[] = { |
63 {"http://localhost:8080/", "http://localhost:8080/", "http://localhost:8080/", | 63 {"http://localhost:8080/", "http://localhost:8080/", "http://localhost:8080/", |
64 L"loginuser", L"abc", L"loginpass", L"123", false}, | 64 "loginuser", "abc", "loginpass", "123", false}, |
65 {"http://localhost:8080/", "", "http://localhost:8080/localhost", | 65 {"http://localhost:8080/", "", "http://localhost:8080/localhost", |
66 L"", L"http", L"", L"Http1+1abcdefg", false}, | 66 "", "http", "", "Http1+1abcdefg", false}, |
67 }; | 67 }; |
68 | 68 |
69 const KeywordInfo kFirefoxKeywords[] = { | 69 const KeywordInfo kFirefoxKeywords[] = { |
70 { L"amazon.com", | 70 { L"amazon.com", |
71 "http://www.amazon.com/exec/obidos/external-search/?field-keywords=" | 71 "http://www.amazon.com/exec/obidos/external-search/?field-keywords=" |
72 "{searchTerms}&mode=blended" }, | 72 "{searchTerms}&mode=blended" }, |
73 { L"answers.com", | 73 { L"answers.com", |
74 "http://www.answers.com/main/ntquery?s={searchTerms}&gwp=13" }, | 74 "http://www.answers.com/main/ntquery?s={searchTerms}&gwp=13" }, |
75 { L"search.creativecommons.org", | 75 { L"search.creativecommons.org", |
76 "http://search.creativecommons.org/?q={searchTerms}" }, | 76 "http://search.creativecommons.org/?q={searchTerms}" }, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 virtual bool TemplateURLServiceIsLoaded() const OVERRIDE { | 129 virtual bool TemplateURLServiceIsLoaded() const OVERRIDE { |
130 return true; | 130 return true; |
131 } | 131 } |
132 | 132 |
133 virtual void AddPasswordForm(const autofill::PasswordForm& form) OVERRIDE { | 133 virtual void AddPasswordForm(const autofill::PasswordForm& form) OVERRIDE { |
134 PasswordInfo p = kFirefoxPasswords[password_count_]; | 134 PasswordInfo p = kFirefoxPasswords[password_count_]; |
135 EXPECT_EQ(p.origin, form.origin.spec()); | 135 EXPECT_EQ(p.origin, form.origin.spec()); |
136 EXPECT_EQ(p.realm, form.signon_realm); | 136 EXPECT_EQ(p.realm, form.signon_realm); |
137 EXPECT_EQ(p.action, form.action.spec()); | 137 EXPECT_EQ(p.action, form.action.spec()); |
138 EXPECT_EQ(base::WideToUTF16(p.username_element), form.username_element); | 138 EXPECT_EQ(base::ASCIIToUTF16(p.username_element), form.username_element); |
139 EXPECT_EQ(base::WideToUTF16(p.username), form.username_value); | 139 EXPECT_EQ(base::ASCIIToUTF16(p.username), form.username_value); |
140 EXPECT_EQ(base::WideToUTF16(p.password_element), form.password_element); | 140 EXPECT_EQ(base::ASCIIToUTF16(p.password_element), form.password_element); |
141 EXPECT_EQ(base::WideToUTF16(p.password), form.password_value); | 141 EXPECT_EQ(base::ASCIIToUTF16(p.password), form.password_value); |
142 EXPECT_EQ(p.blacklisted, form.blacklisted_by_user); | 142 EXPECT_EQ(p.blacklisted, form.blacklisted_by_user); |
143 ++password_count_; | 143 ++password_count_; |
144 } | 144 } |
145 | 145 |
146 virtual void AddHistoryPage(const history::URLRows& page, | 146 virtual void AddHistoryPage(const history::URLRows& page, |
147 history::VisitSource visit_source) OVERRIDE { | 147 history::VisitSource visit_source) OVERRIDE { |
148 ASSERT_EQ(3U, page.size()); | 148 ASSERT_EQ(3U, page.size()); |
149 EXPECT_EQ("http://www.google.com/", page[0].url().spec()); | 149 EXPECT_EQ("http://www.google.com/", page[0].url().spec()); |
150 EXPECT_EQ(base::ASCIIToUTF16("Google"), page[0].title()); | 150 EXPECT_EQ(base::ASCIIToUTF16("Google"), page[0].title()); |
151 EXPECT_EQ("http://www.google.com/", page[1].url().spec()); | 151 EXPECT_EQ("http://www.google.com/", page[1].url().spec()); |
(...skipping 18 matching lines...) Expand all Loading... |
170 ++bookmark_count_; | 170 ++bookmark_count_; |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 virtual void AddKeywords(ScopedVector<TemplateURL> template_urls, | 174 virtual void AddKeywords(ScopedVector<TemplateURL> template_urls, |
175 bool unique_on_host_and_path) OVERRIDE { | 175 bool unique_on_host_and_path) OVERRIDE { |
176 for (size_t i = 0; i < template_urls.size(); ++i) { | 176 for (size_t i = 0; i < template_urls.size(); ++i) { |
177 // The order might not be deterministic, look in the expected list for | 177 // The order might not be deterministic, look in the expected list for |
178 // that template URL. | 178 // that template URL. |
179 bool found = false; | 179 bool found = false; |
180 base::string16 keyword = template_urls[i]->keyword(); | 180 const base::string16& keyword = template_urls[i]->keyword(); |
181 for (size_t j = 0; j < arraysize(kFirefoxKeywords); ++j) { | 181 for (size_t j = 0; j < arraysize(kFirefoxKeywords); ++j) { |
182 if (template_urls[i]->keyword() == | 182 if (keyword == base::WideToUTF16(kFirefoxKeywords[j].keyword)) { |
183 base::WideToUTF16Hack(kFirefoxKeywords[j].keyword)) { | |
184 EXPECT_EQ(kFirefoxKeywords[j].url, template_urls[i]->url()); | 183 EXPECT_EQ(kFirefoxKeywords[j].url, template_urls[i]->url()); |
185 found = true; | 184 found = true; |
186 break; | 185 break; |
187 } | 186 } |
188 } | 187 } |
189 EXPECT_TRUE(found); | 188 EXPECT_TRUE(found); |
190 ++keyword_count_; | 189 ++keyword_count_; |
191 } | 190 } |
192 } | 191 } |
193 | 192 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, false)); | 239 ASSERT_TRUE(base::CopyDirectory(data_path, profile_path_, false)); |
241 | 240 |
242 base::FilePath search_engine_path = app_path_; | 241 base::FilePath search_engine_path = app_path_; |
243 search_engine_path = search_engine_path.AppendASCII("searchplugins"); | 242 search_engine_path = search_engine_path.AppendASCII("searchplugins"); |
244 base::CreateDirectory(search_engine_path); | 243 base::CreateDirectory(search_engine_path); |
245 if (import_search_plugins) { | 244 if (import_search_plugins) { |
246 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 245 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
247 data_path = data_path.AppendASCII("firefox3_searchplugins"); | 246 data_path = data_path.AppendASCII("firefox3_searchplugins"); |
248 if (!base::PathExists(data_path)) { | 247 if (!base::PathExists(data_path)) { |
249 // TODO(maruel): Create search test data that we can open source! | 248 // TODO(maruel): Create search test data that we can open source! |
250 LOG(ERROR) << L"Missing internal test data"; | 249 LOG(ERROR) << "Missing internal test data"; |
251 return; | 250 return; |
252 } | 251 } |
253 ASSERT_TRUE(base::CopyDirectory(data_path, search_engine_path, false)); | 252 ASSERT_TRUE(base::CopyDirectory(data_path, search_engine_path, false)); |
254 } | 253 } |
255 | 254 |
256 importer::SourceProfile source_profile; | 255 importer::SourceProfile source_profile; |
257 source_profile.importer_type = importer::TYPE_FIREFOX; | 256 source_profile.importer_type = importer::TYPE_FIREFOX; |
258 source_profile.app_path = app_path_; | 257 source_profile.app_path = app_path_; |
259 source_profile.source_path = profile_path_; | 258 source_profile.source_path = profile_path_; |
260 source_profile.locale = "en-US"; | 259 source_profile.locale = "en-US"; |
(...skipping 25 matching lines...) Expand all Loading... |
286 } | 285 } |
287 | 286 |
288 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, | 287 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, |
289 MAYBE_IMPORTER(Firefox35Importer)) { | 288 MAYBE_IMPORTER(Firefox35Importer)) { |
290 bool import_search_engines = false; | 289 bool import_search_engines = false; |
291 scoped_refptr<FirefoxObserver> observer( | 290 scoped_refptr<FirefoxObserver> observer( |
292 new FirefoxObserver(import_search_engines)); | 291 new FirefoxObserver(import_search_engines)); |
293 Firefox3xImporterBrowserTest("firefox35_profile", observer.get(), | 292 Firefox3xImporterBrowserTest("firefox35_profile", observer.get(), |
294 observer.get(), import_search_engines); | 293 observer.get(), import_search_engines); |
295 } | 294 } |
OLD | NEW |