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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "content/browser/download/download_file_factory.h" | 7 #include "content/browser/download/download_file_factory.h" |
8 #include "content/browser/download/download_file_impl.h" | 8 #include "content/browser/download/download_file_impl.h" |
9 #include "content/browser/download/download_item_impl.h" | 9 #include "content/browser/download/download_item_impl.h" |
10 #include "content/browser/download/download_manager_impl.h" | 10 #include "content/browser/download/download_manager_impl.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 "DragDownloadFileTest_NetError.txt")); | 92 "DragDownloadFileTest_NetError.txt")); |
93 GURL url(URLRequestMockHTTPJob::GetMockUrl(base::FilePath(FILE_PATH_LITERAL( | 93 GURL url(URLRequestMockHTTPJob::GetMockUrl(base::FilePath(FILE_PATH_LITERAL( |
94 "download-test.lib")))); | 94 "download-test.lib")))); |
95 Referrer referrer; | 95 Referrer referrer; |
96 std::string referrer_encoding; | 96 std::string referrer_encoding; |
97 DragDownloadFile* file = new DragDownloadFile( | 97 DragDownloadFile* file = new DragDownloadFile( |
98 name, scoped_ptr<net::FileStream>(NULL), url, referrer, | 98 name, scoped_ptr<net::FileStream>(NULL), url, referrer, |
99 referrer_encoding, shell()->web_contents()); | 99 referrer_encoding, shell()->web_contents()); |
100 scoped_refptr<MockDownloadFileObserver> observer( | 100 scoped_refptr<MockDownloadFileObserver> observer( |
101 new MockDownloadFileObserver()); | 101 new MockDownloadFileObserver()); |
102 EXPECT_CALL(*observer, OnDownloadAborted()).WillOnce(InvokeWithoutArgs( | 102 EXPECT_CALL(*observer.get(), OnDownloadAborted()) |
103 this, &DragDownloadFileTest::Succeed)); | 103 .WillOnce(InvokeWithoutArgs(this, &DragDownloadFileTest::Succeed)); |
104 ON_CALL(*observer, OnDownloadCompleted(_)).WillByDefault(InvokeWithoutArgs( | 104 ON_CALL(*observer.get(), OnDownloadCompleted(_)) |
105 this, &DragDownloadFileTest::FailFast)); | 105 .WillByDefault(InvokeWithoutArgs(this, &DragDownloadFileTest::FailFast)); |
106 file->Start(observer); | 106 file->Start(observer.get()); |
107 RunMessageLoop(); | 107 RunMessageLoop(); |
108 } | 108 } |
109 | 109 |
110 IN_PROC_BROWSER_TEST_F(DragDownloadFileTest, DragDownloadFileTest_Complete) { | 110 IN_PROC_BROWSER_TEST_F(DragDownloadFileTest, DragDownloadFileTest_Complete) { |
111 base::FilePath name(downloads_directory().AppendASCII( | 111 base::FilePath name(downloads_directory().AppendASCII( |
112 "DragDownloadFileTest_Complete.txt")); | 112 "DragDownloadFileTest_Complete.txt")); |
113 GURL url(URLRequestMockHTTPJob::GetMockUrl(base::FilePath(FILE_PATH_LITERAL( | 113 GURL url(URLRequestMockHTTPJob::GetMockUrl(base::FilePath(FILE_PATH_LITERAL( |
114 "download-test.lib")))); | 114 "download-test.lib")))); |
115 Referrer referrer; | 115 Referrer referrer; |
116 std::string referrer_encoding; | 116 std::string referrer_encoding; |
117 net::FileStream* stream = NULL; | 117 net::FileStream* stream = NULL; |
118 SetUpServer(); | 118 SetUpServer(); |
119 DragDownloadFile* file = new DragDownloadFile( | 119 DragDownloadFile* file = new DragDownloadFile( |
120 name, scoped_ptr<net::FileStream>(stream), url, referrer, | 120 name, scoped_ptr<net::FileStream>(stream), url, referrer, |
121 referrer_encoding, shell()->web_contents()); | 121 referrer_encoding, shell()->web_contents()); |
122 scoped_refptr<MockDownloadFileObserver> observer( | 122 scoped_refptr<MockDownloadFileObserver> observer( |
123 new MockDownloadFileObserver()); | 123 new MockDownloadFileObserver()); |
124 EXPECT_CALL(*observer, OnDownloadCompleted(_)).WillOnce(InvokeWithoutArgs( | 124 EXPECT_CALL(*observer.get(), OnDownloadCompleted(_)) |
125 this, &DragDownloadFileTest::Succeed)); | 125 .WillOnce(InvokeWithoutArgs(this, &DragDownloadFileTest::Succeed)); |
126 ON_CALL(*observer, OnDownloadAborted()).WillByDefault(InvokeWithoutArgs( | 126 ON_CALL(*observer.get(), OnDownloadAborted()) |
127 this, &DragDownloadFileTest::FailFast)); | 127 .WillByDefault(InvokeWithoutArgs(this, &DragDownloadFileTest::FailFast)); |
128 file->Start(observer); | 128 file->Start(observer.get()); |
129 RunMessageLoop(); | 129 RunMessageLoop(); |
130 } | 130 } |
131 | 131 |
132 // TODO(benjhayden): Test Stop(). | 132 // TODO(benjhayden): Test Stop(). |
133 | 133 |
134 } // namespace content | 134 } // namespace content |
OLD | NEW |