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

Side by Side Diff: android_webview/tools/WebViewShell/src/org/chromium/webview_shell/WebViewLayoutTest.java

Issue 1215733002: [Android WebViewShell] Make WebViewLayoutTest runnable with test_runner.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile Created 5 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 unified diff | Download patch
« no previous file with comments | « android_webview/android_webview_shell_test_apk.isolate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.webview_shell; 5 package org.chromium.webview_shell;
6 6
7 import android.os.Environment;
7 import android.test.ActivityInstrumentationTestCase2; 8 import android.test.ActivityInstrumentationTestCase2;
8 9
9 import org.chromium.base.Log; 10 import org.chromium.base.Log;
10 11
11 import java.io.BufferedReader; 12 import java.io.BufferedReader;
12 import java.io.File; 13 import java.io.File;
13 import java.io.FileInputStream; 14 import java.io.FileInputStream;
14 import java.io.FileNotFoundException; 15 import java.io.FileNotFoundException;
15 import java.io.FileOutputStream; 16 import java.io.FileOutputStream;
16 import java.io.IOException; 17 import java.io.IOException;
17 import java.io.InputStreamReader; 18 import java.io.InputStreamReader;
18 import java.util.concurrent.TimeUnit; 19 import java.util.concurrent.TimeUnit;
19 import java.util.concurrent.TimeoutException; 20 import java.util.concurrent.TimeoutException;
20 21
21 /** 22 /**
22 * Tests running end-to-end layout tests. 23 * Tests running end-to-end layout tests.
23 */ 24 */
24 public class WebViewLayoutTest 25 public class WebViewLayoutTest
25 extends ActivityInstrumentationTestCase2<WebViewLayoutTestActivity> { 26 extends ActivityInstrumentationTestCase2<WebViewLayoutTestActivity> {
26 27
27 private static final String TAG = "WebViewLayoutTest"; 28 private static final String TAG = "WebViewLayoutTest";
28 private static final String PATH_PREFIX = "/data/local/tmp/webview_test/"; 29
30 private static final String EXTERNAL_PREFIX =
31 Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
32 private static final String BASE_WEBVIEW_TEST_PATH = "android_webview/tools/ WebViewShell/test/";
33 private static final String PATH_WEBVIEW_PREFIX = EXTERNAL_PREFIX + BASE_WEB VIEW_TEST_PATH;
34
29 private static final long TIMEOUT_SECONDS = 20; 35 private static final long TIMEOUT_SECONDS = 20;
36
30 private WebViewLayoutTestActivity mTestActivity; 37 private WebViewLayoutTestActivity mTestActivity;
31 38
32 public WebViewLayoutTest() { 39 public WebViewLayoutTest() {
33 super(WebViewLayoutTestActivity.class); 40 super(WebViewLayoutTestActivity.class);
34 } 41 }
35 42
36 @Override 43 @Override
37 protected void setUp() throws Exception { 44 protected void setUp() throws Exception {
38 super.setUp(); 45 super.setUp();
39 mTestActivity = (WebViewLayoutTestActivity) getActivity(); 46 mTestActivity = (WebViewLayoutTestActivity) getActivity();
40 } 47 }
41 48
42 @Override 49 @Override
43 protected void tearDown() throws Exception { 50 protected void tearDown() throws Exception {
44 mTestActivity.finish(); 51 mTestActivity.finish();
45 super.tearDown(); 52 super.tearDown();
46 } 53 }
47 54
48 @Override 55 @Override
49 public WebViewLayoutTestRunner getInstrumentation() { 56 public WebViewLayoutTestRunner getInstrumentation() {
50 return (WebViewLayoutTestRunner) super.getInstrumentation(); 57 return (WebViewLayoutTestRunner) super.getInstrumentation();
51 } 58 }
52 59
53 public void testSimple() throws Exception { 60 public void testSimple() throws Exception {
54 runTest("experimental/basic-logging.html", "experimental/basic-logging-e xpected.txt"); 61 runTest("experimental/basic-logging.html",
62 "experimental/basic-logging-expected.txt");
55 } 63 }
56 64
57 public void testGlobalInterface() throws Exception { 65 public void testGlobalInterface() throws Exception {
58 runTest("webexposed/global-interface-listing.html", 66 runTest("webexposed/global-interface-listing.html",
jbudorick 2015/06/29 17:49:05 This suite failed locally for me because this file
timvolodine 2015/06/29 18:06:31 correct, the global-interface-listing.html (and th
jbudorick 2015/06/29 18:11:19 In that case, both files should be listed in the i
timvolodine 2015/06/29 18:19:32 that won't work unfortunately as all the test file
jbudorick 2015/06/29 18:35:21 If we need our own js-test.js, why don't we have o
timvolodine 2015/06/29 18:46:31 because the blink html files + what they reference
jbudorick 2015/06/29 18:55:24 Then what about listing the blink files in the .is
timvolodine 2015/06/30 17:39:44 ok, thanks for the suggestion John! I've updated t
59 "webexposed/global-interface-listing-expected.txt"); 67 "webexposed/global-interface-listing-expected.txt");
60 } 68 }
61 69
62 // test helper methods 70 // test helper methods
63 private void runTest(final String fileName, final String fileNameExpected) 71 private void runTest(final String fileName, final String fileNameExpected)
64 throws FileNotFoundException, IOException, InterruptedException, Tim eoutException { 72 throws FileNotFoundException, IOException, InterruptedException, Tim eoutException {
65 loadUrlWebViewAsync("file://" + PATH_PREFIX + fileName, mTestActivity); 73 loadUrlWebViewAsync("file://" + PATH_WEBVIEW_PREFIX + fileName, mTestAct ivity);
66 74
67 if (getInstrumentation().isRebaseline()) { 75 if (getInstrumentation().isRebaseline()) {
68 // this is the rebase line process; 76 // this is the rebase line process;
69 mTestActivity.waitForFinish(TIMEOUT_SECONDS, TimeUnit.SECONDS); 77 mTestActivity.waitForFinish(TIMEOUT_SECONDS, TimeUnit.SECONDS);
70 String result = mTestActivity.getTestResult(); 78 String result = mTestActivity.getTestResult();
71 writeFile(fileNameExpected, result, mTestActivity.getFilesDir()); 79 writeFile(fileNameExpected, result, mTestActivity.getFilesDir());
72 Log.i(TAG, "file: " + fileNameExpected + " --> rebaselined, length=" + result.length()); 80 Log.i(TAG, "file: " + fileNameExpected + " --> rebaselined, length=" + result.length());
73 } else { 81 } else {
74 String expected = readFile(PATH_PREFIX + fileNameExpected); 82 String expected = readFile(PATH_WEBVIEW_PREFIX + fileNameExpected);
75 mTestActivity.waitForFinish(TIMEOUT_SECONDS, TimeUnit.SECONDS); 83 mTestActivity.waitForFinish(TIMEOUT_SECONDS, TimeUnit.SECONDS);
76 String result = mTestActivity.getTestResult(); 84 String result = mTestActivity.getTestResult();
77 assertEquals(expected, result); 85 assertEquals(expected, result);
78 } 86 }
79 } 87 }
80 88
81 private void loadUrlWebViewAsync(final String fileUrl, 89 private void loadUrlWebViewAsync(final String fileUrl,
82 final WebViewLayoutTestActivity activity) { 90 final WebViewLayoutTestActivity activity) {
83 getInstrumentation().runOnMainSync(new Runnable() { 91 getInstrumentation().runOnMainSync(new Runnable() {
84 @Override 92 @Override
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 throw new IOException("failed to create directories: " + path); 127 throw new IOException("failed to create directories: " + path);
120 128
121 FileOutputStream outputStream = new FileOutputStream(fileOut); 129 FileOutputStream outputStream = new FileOutputStream(fileOut);
122 try { 130 try {
123 outputStream.write(contents.getBytes()); 131 outputStream.write(contents.getBytes());
124 } finally { 132 } finally {
125 outputStream.close(); 133 outputStream.close();
126 } 134 }
127 } 135 }
128 } 136 }
OLDNEW
« no previous file with comments | « android_webview/android_webview_shell_test_apk.isolate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698