OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.chrome.browser.download; | 5 package org.chromium.chrome.browser.download; |
6 | 6 |
7 import android.os.Environment; | 7 import android.os.Environment; |
8 import android.test.suitebuilder.annotation.MediumTest; | 8 import android.test.suitebuilder.annotation.MediumTest; |
9 import android.view.View; | 9 import android.view.View; |
10 | 10 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 @Override | 136 @Override |
137 public Integer call() { | 137 public Integer call() { |
138 return getActivity().getCurrentTabModel().getCount(); | 138 return getActivity().getCurrentTabModel().getCount(); |
139 } | 139 } |
140 })); | 140 })); |
141 } | 141 } |
142 | 142 |
143 @MediumTest | 143 @MediumTest |
144 @Feature({"Downloads"}) | 144 @Feature({"Downloads"}) |
145 @RetryOnFailure | 145 @RetryOnFailure |
146 public void testDuplicateHttpPostDownload_Overwrite() throws Exception { | 146 public void testDuplicateHttpPostDownload_Download() throws Exception { |
147 // Snackbar overlaps the infobar which is clicked in this test. | 147 // Snackbar overlaps the infobar which is clicked in this test. |
148 getActivity().getSnackbarManager().disableForTesting(); | 148 getActivity().getSnackbarManager().disableForTesting(); |
149 // Download a file. | 149 // Download a file. |
150 loadUrl(mTestServer.getURL(TEST_DOWNLOAD_DIRECTORY + "post.html")); | 150 loadUrl(mTestServer.getURL(TEST_DOWNLOAD_DIRECTORY + "post.html")); |
151 waitForFocus(); | 151 waitForFocus(); |
152 View currentView = getActivity().getActivityTab().getView(); | 152 View currentView = getActivity().getActivityTab().getView(); |
153 int callCount = getChromeDownloadCallCount(); | 153 int callCount = getChromeDownloadCallCount(); |
154 singleClickView(currentView); | 154 singleClickView(currentView); |
155 assertTrue("Failed to finish downloading file for the first time.", | 155 assertTrue("Failed to finish downloading file for the first time.", |
156 waitForChromeDownloadToFinish(callCount)); | 156 waitForChromeDownloadToFinish(callCount)); |
157 | 157 |
158 // Download a file with the same name. | 158 // Download a file with the same name. |
159 loadUrl(mTestServer.getURL(TEST_DOWNLOAD_DIRECTORY + "post.html")); | 159 loadUrl(mTestServer.getURL(TEST_DOWNLOAD_DIRECTORY + "post.html")); |
160 waitForFocus(); | 160 waitForFocus(); |
161 currentView = getActivity().getActivityTab().getView(); | 161 currentView = getActivity().getActivityTab().getView(); |
162 callCount = getChromeDownloadCallCount(); | 162 callCount = getChromeDownloadCallCount(); |
163 singleClickView(currentView); | 163 singleClickView(currentView); |
164 assertPollForInfoBarSize(1); | 164 assertPollForInfoBarSize(1); |
165 assertTrue("OVERWRITE button wasn't found", | 165 assertTrue("Download button wasn't found", |
166 InfoBarUtil.clickPrimaryButton(getInfoBars().get(0))); | 166 InfoBarUtil.clickPrimaryButton(getInfoBars().get(0))); |
167 assertTrue("Failed to finish downloading file for the second time.", | 167 assertTrue("Failed to finish downloading file for the second time.", |
168 waitForChromeDownloadToFinish(callCount)); | 168 waitForChromeDownloadToFinish(callCount)); |
169 | 169 |
170 assertTrue("Missing first download", hasDownload(FILENAME_TEXT, SUPERBO_
CONTENTS)); | 170 assertTrue("Missing first download", hasDownload(FILENAME_TEXT, SUPERBO_
CONTENTS)); |
171 assertFalse("Should not have second download", | 171 assertTrue("Missing second download", hasDownload(FILENAME_TEXT_1, SUPER
BO_CONTENTS)); |
172 hasDownload(FILENAME_TEXT_1, SUPERBO_CONTENTS)); | |
173 } | 172 } |
174 | 173 |
175 @MediumTest | 174 @MediumTest |
176 @Feature({"Downloads"}) | 175 @Feature({"Downloads"}) |
177 @DisabledTest(message = "crbug.com/597230") | 176 @DisabledTest(message = "crbug.com/597230") |
178 public void testDuplicateHttpPostDownload_CreateNew() throws Exception { | 177 public void testDuplicateHttpPostDownload_Cancel() throws Exception { |
179 // Download a file. | 178 // Download a file. |
180 loadUrl(mTestServer.getURL(TEST_DOWNLOAD_DIRECTORY + "post.html")); | 179 loadUrl(mTestServer.getURL(TEST_DOWNLOAD_DIRECTORY + "post.html")); |
181 waitForFocus(); | 180 waitForFocus(); |
182 View currentView = getActivity().getActivityTab().getView(); | 181 View currentView = getActivity().getActivityTab().getView(); |
183 int callCount = getChromeDownloadCallCount(); | 182 int callCount = getChromeDownloadCallCount(); |
184 singleClickView(currentView); | 183 singleClickView(currentView); |
185 assertTrue("Failed to finish downloading file for the first time.", | 184 assertTrue("Failed to finish downloading file for the first time.", |
186 waitForChromeDownloadToFinish(callCount)); | 185 waitForChromeDownloadToFinish(callCount)); |
187 | 186 |
188 // Download a file with the same name. | 187 // Download a file with the same name. |
189 loadUrl(mTestServer.getURL(TEST_DOWNLOAD_DIRECTORY + "post.html")); | 188 loadUrl(mTestServer.getURL(TEST_DOWNLOAD_DIRECTORY + "post.html")); |
190 waitForFocus(); | 189 waitForFocus(); |
191 currentView = getActivity().getActivityTab().getView(); | 190 currentView = getActivity().getActivityTab().getView(); |
192 callCount = getChromeDownloadCallCount(); | 191 callCount = getChromeDownloadCallCount(); |
193 singleClickView(currentView); | 192 singleClickView(currentView); |
194 assertPollForInfoBarSize(1); | 193 assertPollForInfoBarSize(1); |
195 assertTrue("CREATE NEW button wasn't found", | 194 assertTrue("CREATE NEW button wasn't found", |
196 InfoBarUtil.clickSecondaryButton(getInfoBars().get(0))); | 195 InfoBarUtil.clickSecondaryButton(getInfoBars().get(0))); |
197 assertTrue("Failed to finish downloading file for the second time.", | 196 assertFalse("Download should not happen when clicking cancel button", |
198 waitForChromeDownloadToFinish(callCount)); | 197 waitForChromeDownloadToFinish(callCount)); |
199 | |
200 assertTrue("Missing first download", hasDownload(FILENAME_TEXT, SUPERBO_
CONTENTS)); | |
201 assertTrue("Missing second download", | |
202 hasDownload(FILENAME_TEXT_1, SUPERBO_CONTENTS)); | |
203 } | 198 } |
204 | 199 |
205 @MediumTest | 200 @MediumTest |
206 @Feature({"Downloads"}) | 201 @Feature({"Downloads"}) |
207 @FlakyTest(message = "crbug.com/415711") | 202 @FlakyTest(message = "crbug.com/415711") |
208 public void testDuplicateHttpPostDownload_Dismiss() throws Exception { | 203 public void testDuplicateHttpPostDownload_Dismiss() throws Exception { |
209 // Download a file. | 204 // Download a file. |
210 loadUrl(mTestServer.getURL(TEST_DOWNLOAD_DIRECTORY + "post.html")); | 205 loadUrl(mTestServer.getURL(TEST_DOWNLOAD_DIRECTORY + "post.html")); |
211 waitForFocus(); | 206 waitForFocus(); |
212 View currentView = getActivity().getActivityTab().getView(); | 207 View currentView = getActivity().getActivityTab().getView(); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 } | 401 } |
407 | 402 |
408 /** | 403 /** |
409 * Makes sure there are no files with names identical to the ones this test
uses in the | 404 * Makes sure there are no files with names identical to the ones this test
uses in the |
410 * downloads directory | 405 * downloads directory |
411 */ | 406 */ |
412 private void deleteTestFiles() { | 407 private void deleteTestFiles() { |
413 deleteFilesInDownloadDirectory(TEST_FILES); | 408 deleteFilesInDownloadDirectory(TEST_FILES); |
414 } | 409 } |
415 } | 410 } |
OLD | NEW |