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

Commit 6c15f600 authored by Guang Zhu's avatar Guang Zhu
Browse files

improvements on layout test

* reduce timeout limit from 30s to 15s
* terminate a test case under some condition on uncaught JS exception
* minor fixes

Change-Id: Iabc8f214544d2c8c14139756abc049870023fea5
parent edd904fd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ def main(options, args):
  # Count crashed tests.
  crashed_tests = []

  timeout_ms = '30000'
  timeout_ms = '15000'
  if options.time_out_ms:
    timeout_ms = options.time_out_ms

+2 −14
Original line number Diff line number Diff line
@@ -18,12 +18,9 @@ package com.android.dumprendertree;

import com.android.dumprendertree.TestShellActivity.DumpDataType;
import com.android.dumprendertree.forwarder.AdbUtils;
import com.android.dumprendertree.forwarder.ForwardServer;
import com.android.dumprendertree.forwarder.ForwardService;

import android.app.Instrumentation;
import android.content.Intent;
import android.os.Bundle;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;

@@ -158,16 +155,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
    private boolean mFinished;

    public LayoutTestsAutoTest() {
      super("com.android.dumprendertree", TestShellActivity.class);
    }

    // This function writes the result of the layout test to
    // Am status so that it can be picked up from a script.
    private void passOrFailCallback(String file, boolean result) {
      Instrumentation inst = getInstrumentation();
      Bundle bundle = new Bundle();
      bundle.putBoolean(file, result);
      inst.sendStatus(0, bundle);
      super(TestShellActivity.class);
    }

    private void getTestList() {
@@ -391,7 +379,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
            resumeTestList();

        TestShellActivity activity = getActivity();
        activity.setDefaultDumpDataType(DumpDataType.DUMP_AS_TEXT);
        activity.setDefaultDumpDataType(DumpDataType.EXT_REPR);

        // Run tests.
        int addr = -1;
+20 −6
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.ViewGroup;
import android.webkit.ConsoleMessage;
import android.webkit.GeolocationPermissions;
import android.webkit.HttpAuthHandler;
import android.webkit.JsPromptResult;
@@ -675,15 +676,28 @@ public class TestShellActivity extends Activity implements LayoutTestController
        }

        @Override
        public void onConsoleMessage(String message, int lineNumber,
                String sourceID) {
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            String msg = "CONSOLE MESSAGE: line " + consoleMessage.lineNumber() + ": "
                    + consoleMessage.message() + "\n";
            if (mConsoleMessages == null) {
                mConsoleMessages = new StringBuffer();
            }
            String consoleMessage = "CONSOLE MESSAGE: line "
                    + lineNumber +": "+ message +"\n";
            mConsoleMessages.append(consoleMessage);
            Log.v(LOGTAG, "LOG: "+consoleMessage);
            mConsoleMessages.append(msg);
            Log.v(LOGTAG, "LOG: " + msg);
            // the rationale here is that if there's an error of either type, and the test was
            // waiting for "notifyDone" signal to finish, then there's no point in waiting
            // anymore because the JS execution is already terminated at this point and a
            // "notifyDone" will never come out so it's just wasting time till timeout kicks in
            if (msg.contains("Uncaught ReferenceError:") || msg.contains("Uncaught TypeError:")
                    && mWaitUntilDone) {
                Log.w(LOGTAG, "Terminating test case on uncaught ReferenceError or TypeError.");
                mHandler.postDelayed(new Runnable() {
                    public void run() {
                        notifyDone();
                    }
                }, 500);
            }
            return true;
        }

        @Override