Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3121)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadTest.java

Issue 1586593003: [Android] Remove test file after download test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadTest.java
index 0c390756d5f7d27952302d2f4150e525e1c1976a..3fd68ee169927336020ffb6c38b666c8c308fb0c 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadTest.java
@@ -9,6 +9,7 @@ import android.test.FlakyTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.view.View;
+import org.chromium.base.Log;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R;
@@ -31,6 +32,7 @@ import java.io.File;
* Tests Chrome download feature by attempting to download some files.
*/
public class DownloadTest extends DownloadTestBase {
+ private static final String TAG = "cr_DownloadTest";
private static final String SUPERBO_CONTENTS =
"plain text response from a POST";
@@ -311,26 +313,32 @@ public class DownloadTest extends DownloadTestBase {
File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
assertTrue(dir.isDirectory());
final File file = new File(dir, "test.gzip");
- if (!file.exists()) {
- assertTrue(file.createNewFile());
- }
-
- // Open in a new tab again.
- loadUrl(url);
- waitForFocus();
-
- View currentView = getActivity().getActivityTab().getView();
- TouchCommon.longPressView(currentView);
- getInstrumentation().invokeContextMenuAction(
- getActivity(), R.id.contextmenu_open_in_new_tab, 0);
- waitForNewTabToStabilize(2);
-
- goToLastTab();
- assertPollForInfoBarSize(1);
+ try {
+ if (!file.exists()) {
gone 2016/01/13 22:27:12 This file really shouldn't ever exist between test
boliu 2016/01/13 22:34:01 Well, I assume there are corner cases. Eg native c
gone 2016/01/13 22:36:32 Yeah, I meant that the file should always be expli
+ assertTrue(file.createNewFile());
+ }
- // Now create two new files by clicking on the infobars.
- assertTrue("OVERWRITE button wasn't found",
- InfoBarUtil.clickPrimaryButton(getInfoBars().get(0)));
+ // Open in a new tab again.
+ loadUrl(url);
+ waitForFocus();
+
+ View currentView = getActivity().getActivityTab().getView();
+ TouchCommon.longPressView(currentView);
+ getInstrumentation().invokeContextMenuAction(
+ getActivity(), R.id.contextmenu_open_in_new_tab, 0);
+ waitForNewTabToStabilize(2);
+
+ goToLastTab();
+ assertPollForInfoBarSize(1);
+
+ // Now create two new files by clicking on the infobars.
+ assertTrue("OVERWRITE button wasn't found",
+ InfoBarUtil.clickPrimaryButton(getInfoBars().get(0)));
+ } finally {
+ if (!file.delete()) {
+ Log.d(TAG, "Failed to delete test.gzip");
gone 2016/01/13 22:27:12 Is this something that should be handled in the se
boliu 2016/01/13 22:34:01 Not every single test wants this. I can put the re
gone 2016/01/13 22:36:32 Eh, not so awkward, but if you're fine with that t
+ }
+ }
}
@MediumTest
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698