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