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/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 // result string. | 1093 // result string. |
1094 std::string error = RunFunctionAndReturnError( | 1094 std::string error = RunFunctionAndReturnError( |
1095 MockedGetFileIconFunction(download_item->GetTargetFilePath(), | 1095 MockedGetFileIconFunction(download_item->GetTargetFilePath(), |
1096 IconLoader::NORMAL, | 1096 IconLoader::NORMAL, |
1097 std::string()), | 1097 std::string()), |
1098 args32); | 1098 args32); |
1099 EXPECT_STREQ(download_extension_errors::kIconNotFoundError, error.c_str()); | 1099 EXPECT_STREQ(download_extension_errors::kIconNotFoundError, error.c_str()); |
1100 | 1100 |
1101 // Once the download item is deleted, we should return kInvalidOperationError. | 1101 // Once the download item is deleted, we should return kInvalidOperationError. |
1102 int id = download_item->GetId(); | 1102 int id = download_item->GetId(); |
1103 download_item->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); | 1103 download_item->Remove(); |
1104 download_item = NULL; | 1104 download_item = NULL; |
1105 EXPECT_EQ(static_cast<DownloadItem*>(NULL), | 1105 EXPECT_EQ(static_cast<DownloadItem*>(NULL), |
1106 GetCurrentManager()->GetDownload(id)); | 1106 GetCurrentManager()->GetDownload(id)); |
1107 error = RunFunctionAndReturnError(new DownloadsGetFileIconFunction(), args32); | 1107 error = RunFunctionAndReturnError(new DownloadsGetFileIconFunction(), args32); |
1108 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, | 1108 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
1109 error.c_str()); | 1109 error.c_str()); |
1110 } | 1110 } |
1111 | 1111 |
1112 // Test that we can acquire file icons for history downloads regardless of | 1112 // Test that we can acquire file icons for history downloads regardless of |
1113 // whether they exist or not. If the file doesn't exist we should receive a | 1113 // whether they exist or not. If the file doesn't exist we should receive a |
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2363 | 2363 |
2364 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, | 2364 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, |
2365 base::StringPrintf("[{\"id\": %d," | 2365 base::StringPrintf("[{\"id\": %d," |
2366 " \"danger\": {" | 2366 " \"danger\": {" |
2367 " \"previous\":\"safe\"," | 2367 " \"previous\":\"safe\"," |
2368 " \"current\":\"file\"}," | 2368 " \"current\":\"file\"}," |
2369 " \"dangerAccepted\": {" | 2369 " \"dangerAccepted\": {" |
2370 " \"current\":false}}]", | 2370 " \"current\":false}}]", |
2371 result_id))); | 2371 result_id))); |
2372 | 2372 |
2373 item->DangerousDownloadValidated(); | 2373 item->ValidateDangerousDownload(); |
2374 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, | 2374 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, |
2375 base::StringPrintf("[{\"id\": %d," | 2375 base::StringPrintf("[{\"id\": %d," |
2376 " \"dangerAccepted\": {" | 2376 " \"dangerAccepted\": {" |
2377 " \"previous\":false," | 2377 " \"previous\":false," |
2378 " \"current\":true}}]", | 2378 " \"current\":true}}]", |
2379 result_id))); | 2379 result_id))); |
2380 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, | 2380 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, |
2381 base::StringPrintf("[{\"id\": %d," | 2381 base::StringPrintf("[{\"id\": %d," |
2382 " \"state\": {" | 2382 " \"state\": {" |
2383 " \"previous\": \"in_progress\"," | 2383 " \"previous\": \"in_progress\"," |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3479 DownloadsApiTest() {} | 3479 DownloadsApiTest() {} |
3480 virtual ~DownloadsApiTest() {} | 3480 virtual ~DownloadsApiTest() {} |
3481 private: | 3481 private: |
3482 DISALLOW_COPY_AND_ASSIGN(DownloadsApiTest); | 3482 DISALLOW_COPY_AND_ASSIGN(DownloadsApiTest); |
3483 }; | 3483 }; |
3484 | 3484 |
3485 | 3485 |
3486 IN_PROC_BROWSER_TEST_F(DownloadsApiTest, DownloadsApiTest) { | 3486 IN_PROC_BROWSER_TEST_F(DownloadsApiTest, DownloadsApiTest) { |
3487 ASSERT_TRUE(RunExtensionTest("downloads")) << message_; | 3487 ASSERT_TRUE(RunExtensionTest("downloads")) << message_; |
3488 } | 3488 } |
OLD | NEW |