OLD | NEW |
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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "chrome/browser/download/download_extension_api.h" | 10 #include "chrome/browser/download/download_extension_api.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 new DownloadsResumeFunction(), DownloadItemIdAsArgList(download_item)); | 271 new DownloadsResumeFunction(), DownloadItemIdAsArgList(download_item)); |
272 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, | 272 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
273 error.c_str()); | 273 error.c_str()); |
274 | 274 |
275 // Calling pause()/resume()/cancel() with invalid download Ids is | 275 // Calling pause()/resume()/cancel() with invalid download Ids is |
276 // tested in the API test (DownloadsApiTest). | 276 // tested in the API test (DownloadsApiTest). |
277 } | 277 } |
278 | 278 |
279 // Test downloads.getFileIcon() on in-progress, finished, cancelled and deleted | 279 // Test downloads.getFileIcon() on in-progress, finished, cancelled and deleted |
280 // download items. | 280 // download items. |
281 // TODO(asanka): Fails on ChromeOS (http://crbug.com/109677) | 281 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, DownloadsApi_FileIcon_Active) { |
282 #if defined(OS_CHROMEOS) | |
283 #define MAYBE_DownloadsApi_FileIcon_Active \ | |
284 FAILS_DownloadsApi_FileIcon_Active | |
285 #else | |
286 #define MAYBE_DownloadsApi_FileIcon_Active DownloadsApi_FileIcon_Active | |
287 #endif | |
288 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | |
289 MAYBE_DownloadsApi_FileIcon_Active) { | |
290 DownloadItem* download_item = CreateSlowTestDownload(); | 282 DownloadItem* download_item = CreateSlowTestDownload(); |
291 ASSERT_TRUE(download_item); | 283 ASSERT_TRUE(download_item); |
292 | 284 |
293 // Get the icon for the in-progress download. This call should succeed even | 285 // Get the icon for the in-progress download. This call should succeed even |
294 // if the file type isn't registered. | 286 // if the file type isn't registered. |
295 std::string args = base::StringPrintf("[%d, {}]", download_item->GetId()); | 287 std::string args = base::StringPrintf("[%d, {}]", download_item->GetId()); |
296 std::string result_string; | 288 std::string result_string; |
297 EXPECT_TRUE(RunFunctionAndReturnString(new DownloadsGetFileIconFunction(), | 289 EXPECT_TRUE(RunFunctionAndReturnString(new DownloadsGetFileIconFunction(), |
298 args, &result_string)); | 290 args, &result_string)); |
299 | 291 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 error.c_str()); | 370 error.c_str()); |
379 | 371 |
380 // Asking for icons of other (invalid) sizes is tested in the API test | 372 // Asking for icons of other (invalid) sizes is tested in the API test |
381 // (DownloadsApiTest). | 373 // (DownloadsApiTest). |
382 } | 374 } |
383 | 375 |
384 // Test that we can acquire file icons for history downloads regardless of | 376 // Test that we can acquire file icons for history downloads regardless of |
385 // whether they exist or not. If the file doesn't exist we should receive a | 377 // whether they exist or not. If the file doesn't exist we should receive a |
386 // generic icon from the OS/toolkit that may or may not be specific to the file | 378 // generic icon from the OS/toolkit that may or may not be specific to the file |
387 // type. | 379 // type. |
388 // TODO(asanka): Fails on ChromeOS (http://crbug.com/109677) | 380 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, DownloadsApi_FileIcon_History) { |
389 #if defined(OS_CHROMEOS) | |
390 #define MAYBE_DownloadsApi_FileIcon_History \ | |
391 FAILS_DownloadsApi_FileIcon_History | |
392 #else | |
393 #define MAYBE_DownloadsApi_FileIcon_History DownloadsApi_FileIcon_History | |
394 #endif | |
395 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | |
396 MAYBE_DownloadsApi_FileIcon_History) { | |
397 base::Time current(base::Time::Now()); | 381 base::Time current(base::Time::Now()); |
398 FilePath real_path( | 382 FilePath real_path( |
399 downloads_directory().Append(FILE_PATH_LITERAL("real.txt"))); | 383 downloads_directory().Append(FILE_PATH_LITERAL("real.txt"))); |
400 FilePath fake_path( | 384 FilePath fake_path( |
401 downloads_directory().Append(FILE_PATH_LITERAL("fake.txt"))); | 385 downloads_directory().Append(FILE_PATH_LITERAL("fake.txt"))); |
402 DownloadPersistentStoreInfo history_entries[] = { | 386 DownloadPersistentStoreInfo history_entries[] = { |
403 DownloadPersistentStoreInfo( | 387 DownloadPersistentStoreInfo( |
404 real_path, | 388 real_path, |
405 GURL("http://does.not.exist/foo"), | 389 GURL("http://does.not.exist/foo"), |
406 GURL(), | 390 GURL(), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 new DownloadsGetFileIconFunction()); | 439 new DownloadsGetFileIconFunction()); |
456 function->SetIconExtractorForTesting(new MockIconExtractorImpl( | 440 function->SetIconExtractorForTesting(new MockIconExtractorImpl( |
457 (*iter)->GetFullPath(), IconLoader::NORMAL, "hello")); | 441 (*iter)->GetFullPath(), IconLoader::NORMAL, "hello")); |
458 EXPECT_TRUE(RunFunctionAndReturnString(function.release(), args, | 442 EXPECT_TRUE(RunFunctionAndReturnString(function.release(), args, |
459 &result_string)); | 443 &result_string)); |
460 EXPECT_STREQ("hello", result_string.c_str()); | 444 EXPECT_STREQ("hello", result_string.c_str()); |
461 } | 445 } |
462 | 446 |
463 // The temporary files should be cleaned up when the ScopedTempDir is removed. | 447 // The temporary files should be cleaned up when the ScopedTempDir is removed. |
464 } | 448 } |
OLD | NEW |