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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 new DownloadsResumeFunction(), DownloadItemIdAsArgList(download_item)); | 325 new DownloadsResumeFunction(), DownloadItemIdAsArgList(download_item)); |
326 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, | 326 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
327 error.c_str()); | 327 error.c_str()); |
328 | 328 |
329 // Calling pause()/resume()/cancel() with invalid download Ids is | 329 // Calling pause()/resume()/cancel() with invalid download Ids is |
330 // tested in the API test (DownloadsApiTest). | 330 // tested in the API test (DownloadsApiTest). |
331 } | 331 } |
332 | 332 |
333 // Test downloads.getFileIcon() on in-progress, finished, cancelled and deleted | 333 // Test downloads.getFileIcon() on in-progress, finished, cancelled and deleted |
334 // download items. | 334 // download items. |
335 // TODO(asanka): Fails on ChromeOS (http://crbug.com/109677) | 335 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, DownloadsApi_FileIcon_Active) { |
336 #if defined(OS_CHROMEOS) | |
337 #define MAYBE_DownloadsApi_FileIcon_Active \ | |
338 FAILS_DownloadsApi_FileIcon_Active | |
339 #else | |
340 #define MAYBE_DownloadsApi_FileIcon_Active DownloadsApi_FileIcon_Active | |
341 #endif | |
342 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | |
343 MAYBE_DownloadsApi_FileIcon_Active) { | |
344 DownloadItem* download_item = CreateSlowTestDownload(); | 336 DownloadItem* download_item = CreateSlowTestDownload(); |
345 ASSERT_TRUE(download_item); | 337 ASSERT_TRUE(download_item); |
346 | 338 |
347 // Get the icon for the in-progress download. This call should succeed even | 339 // Get the icon for the in-progress download. This call should succeed even |
348 // if the file type isn't registered. | 340 // if the file type isn't registered. |
349 std::string args = base::StringPrintf("[%d, {}]", download_item->GetId()); | 341 std::string args = base::StringPrintf("[%d, {}]", download_item->GetId()); |
350 std::string result_string; | 342 std::string result_string; |
351 EXPECT_TRUE(RunFunctionAndReturnString(new DownloadsGetFileIconFunction(), | 343 EXPECT_TRUE(RunFunctionAndReturnString(new DownloadsGetFileIconFunction(), |
352 args, &result_string)); | 344 args, &result_string)); |
353 | 345 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 error.c_str()); | 424 error.c_str()); |
433 | 425 |
434 // Asking for icons of other (invalid) sizes is tested in the API test | 426 // Asking for icons of other (invalid) sizes is tested in the API test |
435 // (DownloadsApiTest). | 427 // (DownloadsApiTest). |
436 } | 428 } |
437 | 429 |
438 // Test that we can acquire file icons for history downloads regardless of | 430 // Test that we can acquire file icons for history downloads regardless of |
439 // whether they exist or not. If the file doesn't exist we should receive a | 431 // whether they exist or not. If the file doesn't exist we should receive a |
440 // generic icon from the OS/toolkit that may or may not be specific to the file | 432 // generic icon from the OS/toolkit that may or may not be specific to the file |
441 // type. | 433 // type. |
442 // TODO(asanka): Fails on ChromeOS (http://crbug.com/109677) | 434 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, DownloadsApi_FileIcon_History) { |
443 #if defined(OS_CHROMEOS) | |
444 #define MAYBE_DownloadsApi_FileIcon_History \ | |
445 FAILS_DownloadsApi_FileIcon_History | |
446 #else | |
447 #define MAYBE_DownloadsApi_FileIcon_History DownloadsApi_FileIcon_History | |
448 #endif | |
449 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | |
450 MAYBE_DownloadsApi_FileIcon_History) { | |
451 base::Time current(base::Time::Now()); | 435 base::Time current(base::Time::Now()); |
452 FilePath real_path( | 436 FilePath real_path( |
453 downloads_directory().Append(FILE_PATH_LITERAL("real.txt"))); | 437 downloads_directory().Append(FILE_PATH_LITERAL("real.txt"))); |
454 FilePath fake_path( | 438 FilePath fake_path( |
455 downloads_directory().Append(FILE_PATH_LITERAL("fake.txt"))); | 439 downloads_directory().Append(FILE_PATH_LITERAL("fake.txt"))); |
456 DownloadPersistentStoreInfo history_entries[] = { | 440 DownloadPersistentStoreInfo history_entries[] = { |
457 DownloadPersistentStoreInfo( | 441 DownloadPersistentStoreInfo( |
458 real_path, | 442 real_path, |
459 GURL("http://does.not.exist/foo"), | 443 GURL("http://does.not.exist/foo"), |
460 GURL(), | 444 GURL(), |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 ASSERT_TRUE(result.get()); | 703 ASSERT_TRUE(result.get()); |
720 base::ListValue* result_list = NULL; | 704 base::ListValue* result_list = NULL; |
721 ASSERT_TRUE(result->GetAsList(&result_list)); | 705 ASSERT_TRUE(result->GetAsList(&result_list)); |
722 ASSERT_EQ(1UL, result_list->GetSize()); | 706 ASSERT_EQ(1UL, result_list->GetSize()); |
723 base::DictionaryValue* item_value = NULL; | 707 base::DictionaryValue* item_value = NULL; |
724 ASSERT_TRUE(result_list->GetDictionary(0, &item_value)); | 708 ASSERT_TRUE(result_list->GetDictionary(0, &item_value)); |
725 FilePath::StringType item_name; | 709 FilePath::StringType item_name; |
726 ASSERT_TRUE(item_value->GetString("filename", &item_name)); | 710 ASSERT_TRUE(item_value->GetString("filename", &item_name)); |
727 ASSERT_EQ(items[2]->GetFullPath().value(), item_name); | 711 ASSERT_EQ(items[2]->GetFullPath().value(), item_name); |
728 } | 712 } |
OLD | NEW |