Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c55fa1b9 authored by Steve Block's avatar Steve Block Committed by Android (Google) Code Review
Browse files

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
parents f7093bef ca501d20
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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 {
+60 −33
Original line number Diff line number Diff line
@@ -131,13 +131,28 @@ 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;
        }
        public byte[] get() {
            start();
            synchronized(this) {
                while (!mGetComplete) {
                    try{
                        wait();
                    } catch(InterruptedException e) {
                    }

        HttpGet httpRequest = new HttpGet(url.toString());
                }
            }
            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 {
@@ -149,7 +164,7 @@ public class FsUtils {
                }
            };

        byte[] bytes = null;
            mBytes = null;
            try {
                /**
                 * TODO: Not exactly sure why some requests hang indefinitely, but adding this
@@ -159,17 +174,29 @@ public class FsUtils {
                do {
                    timedOut = false;
                    try {
                    bytes = getHttpClient().execute(httpRequest, handler);
                        mBytes = getHttpClient().execute(httpRequest, handler);
                    } catch (SocketTimeoutException e) {
                        timedOut = true;
                    Log.w(LOG_TAG, "Expected SocketTimeoutException: " + url, e);
                        Log.w(LOG_TAG, "Expected SocketTimeoutException: " + mUrl, e);
                    }
                } while (timedOut);
            } catch (IOException e) {
            Log.e(LOG_TAG, "url=" + url, e);
                Log.e(LOG_TAG, "url=" + mUrl, e);
            }

        return bytes;
            mGetComplete = true;
            notify();
        }
    }

    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,
+1 −1
Original line number Diff line number Diff line
@@ -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();

+2 −4
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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;

        /**
Loading