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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/contextmenu/ContextMenuTest.java

Issue 2043743004: Start from clean state in DownloadTests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Turned /chrome/test/data/android/download/ into a constant Created 4 years, 6 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 | chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadTest.java » ('j') | 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/contextmenu/ContextMenuTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextmenu/ContextMenuTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextmenu/ContextMenuTest.java
index 5ef2af46eb38fb7385299fb8c28a56ea9e6a3e63..92f08a94e1de68f8a1619560a51d52e6e6ef85ec 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextmenu/ContextMenuTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextmenu/ContextMenuTest.java
@@ -47,17 +47,27 @@ public class ContextMenuTest extends DownloadTestBase {
private EmbeddedTestServer mTestServer;
private String mTestUrl;
+ private static final String FILENAME_GIF = "download.gif";
+ private static final String FILENAME_PNG = "test_image.png";
+ private static final String FILENAME_WEBM = "test.webm";
+
+ private static final String[] TEST_FILES = new String[] {
+ FILENAME_GIF, FILENAME_PNG, FILENAME_WEBM
+ };
+
@Override
protected void setUp() throws Exception {
mTestServer = EmbeddedTestServer.createAndStartFileServer(
getInstrumentation().getContext(), Environment.getExternalStorageDirectory());
mTestUrl = mTestServer.getURL(TEST_PATH);
+ deleteTestFiles();
super.setUp();
}
@Override
protected void tearDown() throws Exception {
mTestServer.stopAndDestroyServer();
+ deleteTestFiles();
super.tearDown();
}
@@ -227,14 +237,14 @@ public class ContextMenuTest extends DownloadTestBase {
@Feature({"Browser"})
public void testSaveDataUrl()
throws InterruptedException, TimeoutException, SecurityException, IOException {
- saveMediaFromContextMenu("dataUrlIcon", R.id.contextmenu_save_image, "download.gif");
+ saveMediaFromContextMenu("dataUrlIcon", R.id.contextmenu_save_image, FILENAME_GIF);
}
@LargeTest
@Feature({"Browser"})
public void testSaveImage()
throws InterruptedException, TimeoutException, SecurityException, IOException {
- saveMediaFromContextMenu("testImage", R.id.contextmenu_save_image, "test_image.png");
+ saveMediaFromContextMenu("testImage", R.id.contextmenu_save_image, FILENAME_PNG);
}
@LargeTest
@@ -243,7 +253,7 @@ public class ContextMenuTest extends DownloadTestBase {
throws InterruptedException, TimeoutException, SecurityException, IOException {
// Click the video to enable playback
DOMUtils.clickNode(this, getActivity().getCurrentContentViewCore(), "videoDOMElement");
- saveMediaFromContextMenu("videoDOMElement", R.id.contextmenu_save_video, "test.webm");
+ saveMediaFromContextMenu("videoDOMElement", R.id.contextmenu_save_video, FILENAME_WEBM);
}
/**
@@ -324,4 +334,12 @@ public class ContextMenuTest extends DownloadTestBase {
assertTrue("String '" + superString + "' does not contain '" + subString + "'",
superString.contains(subString));
}
+
+ /**
+ * Makes sure there are no files with names identical to the ones this test uses in the
+ * downloads directory
+ */
+ private void deleteTestFiles() {
+ deleteFilesInDownloadDirectory(TEST_FILES);
+ }
}
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698