OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 }; | 196 }; |
197 | 197 |
198 std::vector<FaviconGroup> favicon_groups( | 198 std::vector<FaviconGroup> favicon_groups( |
199 kEdgeFaviconGroup, kEdgeFaviconGroup + arraysize(kEdgeFaviconGroup)); | 199 kEdgeFaviconGroup, kEdgeFaviconGroup + arraysize(kEdgeFaviconGroup)); |
200 | 200 |
201 base::FilePath data_path; | 201 base::FilePath data_path; |
202 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 202 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
203 data_path = data_path.AppendASCII("edge_profile"); | 203 data_path = data_path.AppendASCII("edge_profile"); |
204 | 204 |
205 base::FilePath temp_path = temp_dir_.GetPath(); | 205 base::FilePath temp_path = temp_dir_.GetPath(); |
206 ASSERT_TRUE(base::CopyDirectory(data_path, temp_path, true)); | 206 { |
207 ASSERT_TRUE(DecompressDatabase(temp_path.AppendASCII("edge_profile"))); | 207 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 208 ASSERT_TRUE(base::CopyDirectory(data_path, temp_path, true)); |
| 209 ASSERT_TRUE(DecompressDatabase(temp_path.AppendASCII("edge_profile"))); |
| 210 } |
208 | 211 |
209 base::string16 key_path(importer::GetEdgeSettingsKey()); | 212 base::string16 key_path(importer::GetEdgeSettingsKey()); |
210 base::win::RegKey key; | 213 base::win::RegKey key; |
211 ASSERT_EQ(ERROR_SUCCESS, | 214 ASSERT_EQ(ERROR_SUCCESS, |
212 key.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_WRITE)); | 215 key.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_WRITE)); |
213 key.WriteValue(L"FavoritesESEEnabled", 1); | 216 key.WriteValue(L"FavoritesESEEnabled", 1); |
214 ASSERT_FALSE(importer::IsEdgeFavoritesLegacyMode()); | 217 ASSERT_FALSE(importer::IsEdgeFavoritesLegacyMode()); |
215 | 218 |
216 // Starts to import the above settings. | 219 // Starts to import the above settings. |
217 // Deletes itself. | 220 // Deletes itself. |
(...skipping 18 matching lines...) Expand all Loading... |
236 kEdgeBookmarks, kEdgeBookmarks + arraysize(kEdgeBookmarks)); | 239 kEdgeBookmarks, kEdgeBookmarks + arraysize(kEdgeBookmarks)); |
237 const FaviconGroup kEdgeFaviconGroup[] = { | 240 const FaviconGroup kEdgeFaviconGroup[] = { |
238 {L"http://www.google.com/favicon.ico", L"http://www.google.com/"}}; | 241 {L"http://www.google.com/favicon.ico", L"http://www.google.com/"}}; |
239 std::vector<FaviconGroup> favicon_groups( | 242 std::vector<FaviconGroup> favicon_groups( |
240 kEdgeFaviconGroup, kEdgeFaviconGroup + arraysize(kEdgeFaviconGroup)); | 243 kEdgeFaviconGroup, kEdgeFaviconGroup + arraysize(kEdgeFaviconGroup)); |
241 | 244 |
242 base::FilePath data_path; | 245 base::FilePath data_path; |
243 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 246 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
244 data_path = data_path.AppendASCII("edge_profile"); | 247 data_path = data_path.AppendASCII("edge_profile"); |
245 | 248 |
246 ASSERT_TRUE(base::CopyDirectory(data_path, temp_dir_.GetPath(), true)); | 249 { |
247 ASSERT_TRUE(importer::IsEdgeFavoritesLegacyMode()); | 250 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 251 ASSERT_TRUE(base::CopyDirectory(data_path, temp_dir_.GetPath(), true)); |
| 252 ASSERT_TRUE(importer::IsEdgeFavoritesLegacyMode()); |
| 253 } |
248 | 254 |
249 // Starts to import the above settings. | 255 // Starts to import the above settings. |
250 // Deletes itself. | 256 // Deletes itself. |
251 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; | 257 ExternalProcessImporterHost* host = new ExternalProcessImporterHost; |
252 scoped_refptr<TestObserver> observer( | 258 scoped_refptr<TestObserver> observer( |
253 new TestObserver(bookmark_entries, favicon_groups)); | 259 new TestObserver(bookmark_entries, favicon_groups)); |
254 host->set_observer(observer.get()); | 260 host->set_observer(observer.get()); |
255 | 261 |
256 importer::SourceProfile source_profile; | 262 importer::SourceProfile source_profile; |
257 source_profile.importer_type = importer::TYPE_EDGE; | 263 source_profile.importer_type = importer::TYPE_EDGE; |
258 base::FilePath source_path = temp_dir_.GetPath().AppendASCII("edge_profile"); | 264 base::FilePath source_path = temp_dir_.GetPath().AppendASCII("edge_profile"); |
259 ASSERT_NE(-1, | 265 { |
260 base::WriteFile( | 266 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 267 ASSERT_NE( |
| 268 -1, base::WriteFile( |
261 source_path.AppendASCII("Favorites\\Google.url:favicon:$DATA"), | 269 source_path.AppendASCII("Favorites\\Google.url:favicon:$DATA"), |
262 kDummyFaviconImageData, sizeof(kDummyFaviconImageData))); | 270 kDummyFaviconImageData, sizeof(kDummyFaviconImageData))); |
| 271 } |
263 source_profile.source_path = source_path; | 272 source_profile.source_path = source_path; |
264 | 273 |
265 host->StartImportSettings(source_profile, browser()->profile(), | 274 host->StartImportSettings(source_profile, browser()->profile(), |
266 importer::FAVORITES, observer.get()); | 275 importer::FAVORITES, observer.get()); |
267 base::RunLoop().Run(); | 276 base::RunLoop().Run(); |
268 } | 277 } |
269 | 278 |
270 IN_PROC_BROWSER_TEST_F(EdgeImporterBrowserTest, EdgeImporterNoDatabase) { | 279 IN_PROC_BROWSER_TEST_F(EdgeImporterBrowserTest, EdgeImporterNoDatabase) { |
271 // Only verified to work with ESE library on Windows 8.1 and above. | 280 // Only verified to work with ESE library on Windows 8.1 and above. |
272 if (base::win::GetVersion() < base::win::VERSION_WIN8_1) | 281 if (base::win::GetVersion() < base::win::VERSION_WIN8_1) |
(...skipping 17 matching lines...) Expand all Loading... |
290 host->set_observer(observer.get()); | 299 host->set_observer(observer.get()); |
291 | 300 |
292 importer::SourceProfile source_profile; | 301 importer::SourceProfile source_profile; |
293 source_profile.importer_type = importer::TYPE_EDGE; | 302 source_profile.importer_type = importer::TYPE_EDGE; |
294 source_profile.source_path = temp_dir_.GetPath(); | 303 source_profile.source_path = temp_dir_.GetPath(); |
295 | 304 |
296 host->StartImportSettings(source_profile, browser()->profile(), | 305 host->StartImportSettings(source_profile, browser()->profile(), |
297 importer::FAVORITES, observer.get()); | 306 importer::FAVORITES, observer.get()); |
298 base::RunLoop().Run(); | 307 base::RunLoop().Run(); |
299 } | 308 } |
OLD | NEW |