| 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 "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
| 6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 DownloadsDOMHandlerTest() {} | 122 DownloadsDOMHandlerTest() {} |
| 123 | 123 |
| 124 ~DownloadsDOMHandlerTest() override {} | 124 ~DownloadsDOMHandlerTest() override {} |
| 125 | 125 |
| 126 void SetUpOnMainThread() override { | 126 void SetUpOnMainThread() override { |
| 127 mock_handler_.reset(new MockDownloadsDOMHandler(download_manager())); | 127 mock_handler_.reset(new MockDownloadsDOMHandler(download_manager())); |
| 128 CHECK(downloads_directory_.CreateUniqueTempDir()); | 128 CHECK(downloads_directory_.CreateUniqueTempDir()); |
| 129 browser()->profile()->GetPrefs()->SetFilePath( | 129 browser()->profile()->GetPrefs()->SetFilePath( |
| 130 prefs::kDownloadDefaultDirectory, | 130 prefs::kDownloadDefaultDirectory, |
| 131 downloads_directory_.path()); | 131 downloads_directory_.path()); |
| 132 CHECK(test_server()->Start()); | 132 CHECK(embedded_test_server()->Start()); |
| 133 mock_handler_->HandleGetDownloads(nullptr); | 133 mock_handler_->HandleGetDownloads(nullptr); |
| 134 } | 134 } |
| 135 | 135 |
| 136 content::DownloadManager* download_manager() { | 136 content::DownloadManager* download_manager() { |
| 137 return content::BrowserContext::GetDownloadManager(browser()->profile()); | 137 return content::BrowserContext::GetDownloadManager(browser()->profile()); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void DownloadAnItem() { | 140 void DownloadAnItem() { |
| 141 GURL url = test_server()->GetURL("files/downloads/image.jpg"); | 141 GURL url = embedded_test_server()->GetURL("/downloads/image.jpg"); |
| 142 std::vector<GURL> url_chain; | 142 std::vector<GURL> url_chain; |
| 143 url_chain.push_back(url); | 143 url_chain.push_back(url); |
| 144 base::Time current(base::Time::Now()); | 144 base::Time current(base::Time::Now()); |
| 145 download_manager()->CreateDownloadItem( | 145 download_manager()->CreateDownloadItem( |
| 146 1, // id | 146 1, // id |
| 147 base::FilePath(FILE_PATH_LITERAL("/path/to/file")), | 147 base::FilePath(FILE_PATH_LITERAL("/path/to/file")), |
| 148 base::FilePath(FILE_PATH_LITERAL("/path/to/file")), | 148 base::FilePath(FILE_PATH_LITERAL("/path/to/file")), |
| 149 url_chain, | 149 url_chain, |
| 150 GURL(std::string()), | 150 GURL(std::string()), |
| 151 "application/octet-stream", | 151 "application/octet-stream", |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 // TODO(benjhayden): Test incognito, both downloads_list() and that on-record | 317 // TODO(benjhayden): Test incognito, both downloads_list() and that on-record |
| 318 // calls can't access off-record items. | 318 // calls can't access off-record items. |
| 319 | 319 |
| 320 // TODO(benjhayden): Test that bad download ids incoming from the javascript are | 320 // TODO(benjhayden): Test that bad download ids incoming from the javascript are |
| 321 // dropped on the floor. | 321 // dropped on the floor. |
| 322 | 322 |
| 323 // TODO(benjhayden): Test that IsTemporary() downloads are not shown. | 323 // TODO(benjhayden): Test that IsTemporary() downloads are not shown. |
| 324 | 324 |
| 325 // TODO(benjhayden): Test that RemoveObserver is called on all download items, | 325 // TODO(benjhayden): Test that RemoveObserver is called on all download items, |
| 326 // including items that crossed IsTemporary() and back. | 326 // including items that crossed IsTemporary() and back. |
| OLD | NEW |