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

Commit 977f7691 authored by Ben Murdoch's avatar Ben Murdoch
Browse files

Only move to the next test in DRT after the test has completed AND the page has finished loading.

Change-Id: I157da58bb99f7bf0fcd00073d078c26c7df201ed
parent bcef9ac3
Loading
Loading
Loading
Loading
+31 −6
Original line number Diff line number Diff line
@@ -291,6 +291,7 @@ public class TestShellActivity extends Activity implements LayoutTestController
    }

    public void finished() {
        if (mTestPageLoaded) {
            if (mUiAutoTestPath != null) {
                //don't really finish here
                moveToNextTest();
@@ -299,6 +300,12 @@ public class TestShellActivity extends Activity implements LayoutTestController
                    mCallback.finished();
                }
            }
        } else {
            // The test is complete but the page has not completed loading. We
            // can't continue to the next test until both the test is finished
            // and the page has stopped loading.
            mReadyForNextTest = true;
        }
    }

    public void setDefaultDumpDataType(DumpDataType defaultDumpDataType) {
@@ -445,12 +452,14 @@ public class TestShellActivity extends Activity implements LayoutTestController
        @Override
        public void onPageFinished(WebView view, String url) {
            Log.v(LOGTAG, "onPageFinished, url=" + url);
            mTestPageLoaded = true;
            super.onPageFinished(view, url);
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            Log.v(LOGTAG, "onPageStarted, url=" + url);
            mTestPageLoaded = false;
            super.onPageStarted(view, url, favicon);
        }

@@ -480,6 +489,17 @@ public class TestShellActivity extends Activity implements LayoutTestController
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress == 100) {

                if (mReadyForNextTest) {
                    // In this case, the test has completed (i.e. called
                    // layoutTestController.notifyDone) before the page finished loading. This
                    // usually happens if the test is not invoked by an onload handler, rather
                    // directly in a script tag. Now that the page has finished loading, it is
                    // safe for DRT to go to the next test.
                    finished();
                    return;
                }

                if (!mTimedOut && !mWaitUntilDone && !mRequestedWebKitData) {
                    String url = mWebView.getUrl();
                    Log.v(LOGTAG, "Finished: "+ url);
@@ -655,6 +675,8 @@ public class TestShellActivity extends Activity implements LayoutTestController
        mDumpDatabaseCallbacks = false;
        mCanOpenWindows = false;
        mEventSender.resetMouse();
        mTestPageLoaded = false;
        mReadyForNextTest = false;
    }

    private void setupWebViewForLayoutTests(WebView webview, CallbackProxy callbackProxy) {
@@ -711,6 +733,9 @@ public class TestShellActivity extends Activity implements LayoutTestController
    private StringBuffer mConsoleMessages;
    private boolean mCanOpenWindows;

    private boolean mTestPageLoaded = false;
    private boolean mReadyForNextTest = false;

    static final String TIMEOUT_STR = "**Test timeout";

    static final int MSG_TIMEOUT = 0;