summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-11-09 06:32:13 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-11-09 06:32:13 -0800
commitc55fa1b999068fc7f242b88a87270b249ab366eb (patch)
treeaf5fb645204cb47af5f9d245f882e6318657915b /tests
parentf7093befbbc64d324b6d4c41e98ae69bbed4cd31 (diff)
parentca501d20360ffee3a37fc87538daf8281f8a14ed (diff)
downloadframeworks_base-c55fa1b999068fc7f242b88a87270b249ab366eb.zip
frameworks_base-c55fa1b999068fc7f242b88a87270b249ab366eb.tar.gz
frameworks_base-c55fa1b999068fc7f242b88a87270b249ab366eb.tar.bz2
Merge changes I650518a4,If15fddac
* changes: Fix DumpRenderTree2 to not attempt to read expected results over HTTPS Fix FsUtils.readDataFromUrl() to do the network request on a background thread
Diffstat (limited to 'tests')
-rw-r--r--tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java9
-rw-r--r--tests/DumpRenderTree2/src/com/android/dumprendertree2/FsUtils.java93
-rw-r--r--tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java2
-rw-r--r--tests/DumpRenderTree2/src/com/android/dumprendertree2/ManagerService.java6
-rw-r--r--tests/DumpRenderTree2/src/com/android/dumprendertree2/Summarizer.java4
-rw-r--r--tests/DumpRenderTree2/src/com/android/dumprendertree2/TestsListPreloaderThread.java2
6 files changed, 71 insertions, 45 deletions
diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java
index 9bbf64a..ebdf9c2 100644
--- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java
+++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java
@@ -243,8 +243,7 @@ public class FileFilter {
* Currently we run .html and .xhtml tests.
*
* @param testName
- * @return
- * if the file is a test
+ * @return if the file is a test
*/
public static boolean isTestFile(String testName) {
return testName.endsWith(".html") || testName.endsWith(".xhtml");
@@ -254,9 +253,11 @@ public class FileFilter {
* Return a URL of the test on the server.
*
* @param relativePath
+ * @param allowHttps Whether to allow the use of HTTPS, even if the file is in the SSL
+ * directory.
* @return a URL of the test on the server
*/
- public static URL getUrl(String relativePath) {
+ public static URL getUrl(String relativePath, boolean allowHttps) {
String urlBase = ForwarderManager.getHostSchemePort(false);
/**
@@ -265,7 +266,7 @@ public class FileFilter {
*/
if (relativePath.startsWith(HTTP_TESTS_PATH)) {
relativePath = relativePath.substring(HTTP_TESTS_PATH.length());
- if (relativePath.startsWith(SSL_PATH)) {
+ if (relativePath.startsWith(SSL_PATH) && allowHttps) {
urlBase = ForwarderManager.getHostSchemePort(true);
}
} else {
diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/FsUtils.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/FsUtils.java
index 4f9a737..a79aead 100644
--- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/FsUtils.java
+++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/FsUtils.java
@@ -131,45 +131,72 @@ public class FsUtils {
return bytes;
}
- public static byte[] readDataFromUrl(URL url) {
- if (url == null) {
- Log.w(LOG_TAG, "readDataFromUrl(): url is null!");
- return null;
+ static class UrlDataGetter extends Thread {
+ private URL mUrl;
+ private byte[] mBytes;
+ private boolean mGetComplete;
+ public UrlDataGetter(URL url) {
+ mUrl = url;
}
-
- HttpGet httpRequest = new HttpGet(url.toString());
- ResponseHandler<byte[]> handler = new ResponseHandler<byte[]>() {
- @Override
- public byte[] handleResponse(HttpResponse response) throws IOException {
- if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
- return null;
+ public byte[] get() {
+ start();
+ synchronized(this) {
+ while (!mGetComplete) {
+ try{
+ wait();
+ } catch(InterruptedException e) {
+ }
}
- HttpEntity entity = response.getEntity();
- return (entity == null ? null : EntityUtils.toByteArray(entity));
}
- };
-
- byte[] bytes = null;
- try {
- /**
- * TODO: Not exactly sure why some requests hang indefinitely, but adding this
- * timeout (in static getter for http client) in loop helps.
- */
- boolean timedOut;
- do {
- timedOut = false;
- try {
- bytes = getHttpClient().execute(httpRequest, handler);
- } catch (SocketTimeoutException e) {
- timedOut = true;
- Log.w(LOG_TAG, "Expected SocketTimeoutException: " + url, e);
+ return mBytes;
+ }
+ public synchronized void run() {
+ mGetComplete = false;
+ HttpGet httpRequest = new HttpGet(mUrl.toString());
+ ResponseHandler<byte[]> handler = new ResponseHandler<byte[]>() {
+ @Override
+ public byte[] handleResponse(HttpResponse response) throws IOException {
+ if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
+ return null;
+ }
+ HttpEntity entity = response.getEntity();
+ return (entity == null ? null : EntityUtils.toByteArray(entity));
}
- } while (timedOut);
- } catch (IOException e) {
- Log.e(LOG_TAG, "url=" + url, e);
+ };
+
+ mBytes = null;
+ try {
+ /**
+ * TODO: Not exactly sure why some requests hang indefinitely, but adding this
+ * timeout (in static getter for http client) in loop helps.
+ */
+ boolean timedOut;
+ do {
+ timedOut = false;
+ try {
+ mBytes = getHttpClient().execute(httpRequest, handler);
+ } catch (SocketTimeoutException e) {
+ timedOut = true;
+ Log.w(LOG_TAG, "Expected SocketTimeoutException: " + mUrl, e);
+ }
+ } while (timedOut);
+ } catch (IOException e) {
+ Log.e(LOG_TAG, "url=" + mUrl, e);
+ }
+
+ mGetComplete = true;
+ notify();
}
+ }
- return bytes;
+ public static byte[] readDataFromUrl(URL url) {
+ if (url == null) {
+ Log.w(LOG_TAG, "readDataFromUrl(): url is null!");
+ return null;
+ }
+
+ UrlDataGetter getter = new UrlDataGetter(url);
+ return getter.get();
}
public static List<String> getLayoutTestsDirContents(String dirRelativePath, boolean recurse,
diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java
index 58f7183..7efb03f 100644
--- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java
+++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsExecutor.java
@@ -439,7 +439,7 @@ public class LayoutTestsExecutor extends Activity {
Log.i(LOG_TAG, "runNextTest(): Start: " + mCurrentTestRelativePath +
" (" + mCurrentTestIndex + ")");
- mCurrentTestUri = FileFilter.getUrl(mCurrentTestRelativePath).toString();
+ mCurrentTestUri = FileFilter.getUrl(mCurrentTestRelativePath, true).toString();
reset();
diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/ManagerService.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/ManagerService.java
index f42dc86..e4df62d 100644
--- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/ManagerService.java
+++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/ManagerService.java
@@ -127,7 +127,6 @@ public class ManagerService extends Service {
}
};
- private FileFilter mFileFilter;
private Summarizer mSummarizer;
private String mCurrentlyRunningTest;
@@ -146,8 +145,7 @@ public class ManagerService extends Service {
public void onCreate() {
super.onCreate();
- mFileFilter = new FileFilter();
- mSummarizer = new Summarizer(mFileFilter, RESULTS_ROOT_DIR_PATH, getApplicationContext());
+ mSummarizer = new Summarizer(RESULTS_ROOT_DIR_PATH, getApplicationContext());
}
@Override
@@ -264,7 +262,7 @@ public class ManagerService extends Service {
int size = EXPECTED_RESULT_LOCATION_RELATIVE_DIR_PREFIXES.size();
for (int i = 0; bytes == null && i < size; i++) {
relativePath = locations.get(i) + originalRelativePath;
- bytes = FsUtils.readDataFromUrl(FileFilter.getUrl(relativePath));
+ bytes = FsUtils.readDataFromUrl(FileFilter.getUrl(relativePath, false));
}
mLastExpectedResultPathFetched = bytes == null ? null : relativePath;
diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/Summarizer.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/Summarizer.java
index bd8c4ad..65c6964 100644
--- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/Summarizer.java
+++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/Summarizer.java
@@ -213,8 +213,8 @@ public class Summarizer {
private SummarizerDBHelper mDbHelper;
- public Summarizer(FileFilter fileFilter, String resultsRootDirPath, Context context) {
- mFileFilter = fileFilter;
+ public Summarizer(String resultsRootDirPath, Context context) {
+ mFileFilter = new FileFilter();
mResultsRootDirPath = resultsRootDirPath;
/**
diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/TestsListPreloaderThread.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/TestsListPreloaderThread.java
index 0e7d47a..ab98830 100644
--- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/TestsListPreloaderThread.java
+++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/TestsListPreloaderThread.java
@@ -50,13 +50,13 @@ public class TestsListPreloaderThread extends Thread {
* @param doneMsg
*/
public TestsListPreloaderThread(String path, Message doneMsg) {
- mFileFilter = new FileFilter();
mRelativePath = path;
mDoneMsg = doneMsg;
}
@Override
public void run() {
+ mFileFilter = new FileFilter();
if (FileFilter.isTestFile(mRelativePath)) {
mTestsList.add(mRelativePath);
} else {