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

Commit 12077e11 authored by Steve Block's avatar Steve Block
Browse files

Adds to DumpRenderTree the ability to look for Android-specific results

These Android-specific results will be added to
external/webkit/LayoutTests/platform/android-<js-engine> and are used in
preference to the generic expected results.

The JavaScript engine to use is read from the JS_ENGINE environment variable
used by the build system or can be overridden on the command line. If neither
is set, it defaults to JSC.

Change-Id: Ia8d107ced3968a5c061fd6f0f57451419bab6b27
parent 2ec30697
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@
    --time-out-ms (default is 8000 millis) for each test
    --time-out-ms (default is 8000 millis) for each test
    --adb-options="-e" passes option string to adb
    --adb-options="-e" passes option string to adb
    --results-directory=..., (default is ./layout-test-results) directory name under which results are stored.
    --results-directory=..., (default is ./layout-test-results) directory name under which results are stored.
    --js-engine the JavaScript engine currently in use, determines which set of Android-specific expected results we should use, should be 'jsc' or 'v8'
"""
"""


import logging
import logging
@@ -186,6 +187,16 @@ def main(options, args):
  run_layout_test_cmd_postfix = " -e path \"" + path + "\" -e timeout " + timeout_ms
  run_layout_test_cmd_postfix = " -e path \"" + path + "\" -e timeout " + timeout_ms
  if options.rebaseline:
  if options.rebaseline:
    run_layout_test_cmd_postfix += " -e rebaseline true"
    run_layout_test_cmd_postfix += " -e rebaseline true"

  # If the JS engine is not specified on the command line, try reading the
  # JS_ENGINE environment  variable, which is used by the build system in
  # external/webkit/Android.mk.
  js_engine = options.js_engine
  if not js_engine:
    js_engine = os.environ['JS_ENGINE']
  if js_engine:
    run_layout_test_cmd_postfix += " -e jsengine " + js_engine

  run_layout_test_cmd_postfix += " -w com.android.dumprendertree/.LayoutTestsAutoRunner"
  run_layout_test_cmd_postfix += " -w com.android.dumprendertree/.LayoutTestsAutoRunner"


  # Call LayoutTestsAutoTest::startLayoutTests.
  # Call LayoutTestsAutoTest::startLayoutTests.
@@ -297,6 +308,9 @@ if '__main__' == __name__:
                           default=None,
                           default=None,
                           dest="ref_directory",
                           dest="ref_directory",
                           help="directory where reference results are stored.")
                           help="directory where reference results are stored.")
  option_parser.add_option("", "--js-engine",
                           default=None,
                           help="The JavaScript engine currently in use, which determines which set of Android-specific expected results we should use. Should be 'jsc' or 'v8'.");


  options, args = option_parser.parse_args();
  options, args = option_parser.parse_args();
  main(options, args)
  main(options, args)
+10 −7
Original line number Original line Diff line number Diff line
@@ -79,14 +79,17 @@ public class LayoutTestsAutoRunner extends InstrumentationTestRunner {


        mSaveImagePath = (String) icicle.get("saveimage");
        mSaveImagePath = (String) icicle.get("saveimage");


        mJsEngine = (String) icicle.get("jsengine");

        super.onCreate(icicle);
        super.onCreate(icicle);
    }
    }
    
    
    public String mTestPath = null;
    public String mTestPath;
    public String mSaveImagePath = null;
    public String mSaveImagePath;
    public int mTimeoutInMillis = 0;
    public int mTimeoutInMillis;
    public int mDelay = 0;
    public int mDelay;
    public boolean mRebaseline = false;
    public boolean mRebaseline;
    public boolean mLogtime = false;
    public boolean mLogtime;
    public boolean mGetDrawTime = false;
    public boolean mGetDrawTime;
    public String mJsEngine;
}
}
+22 −7
Original line number Original line Diff line number Diff line
@@ -147,6 +147,9 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
    private MyTestRecorder mResultRecorder;
    private MyTestRecorder mResultRecorder;
    private Vector<String> mTestList;
    private Vector<String> mTestList;
    private boolean mRebaselineResults;
    private boolean mRebaselineResults;
    // The JavaScript engine currently in use. This determines which set of Android-specific
    // expected test results we use.
    private String mJsEngine;
    private String mTestPathPrefix;
    private String mTestPathPrefix;
    private boolean mFinished;
    private boolean mFinished;


@@ -214,14 +217,24 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
        return shortName.replaceFirst(LAYOUT_TESTS_ROOT, LAYOUT_TESTS_RESULT_DIR) + "-result.txt";
        return shortName.replaceFirst(LAYOUT_TESTS_ROOT, LAYOUT_TESTS_RESULT_DIR) + "-result.txt";
    }
    }


    // Gets the file which contains WebKit's expected results for this test.
    private String getExpectedResultFile(String test) {
    private String getExpectedResultFile(String test) {
        // The generic result is at <path>/<name>-expected.txt
        // First try the Android-specific result at
        // platform/android-<js-engine>/<path>/<name>-expected.txt
        int pos = test.lastIndexOf('.');
        int pos = test.lastIndexOf('.');
        if (pos == -1)
        if (pos == -1)
            return null;
            return null;
        String shortName = test.substring(0, pos);
        String genericExpectedResult = test.substring(0, pos) + "-expected.txt";
        return shortName + "-expected.txt";
        String androidExpectedResultsDir = "platform/android-" + mJsEngine + "/";
        String androidExpectedResult =
            genericExpectedResult.replaceFirst(LAYOUT_TESTS_ROOT, LAYOUT_TESTS_ROOT + androidExpectedResultsDir);
        File f = new File(androidExpectedResult);
        return f.exists() ? androidExpectedResult : genericExpectedResult;
    }
    }


    // Gets the file which contains the actual results of running the test on
    // Android, generated by a previous run which set a new baseline.
    private String getAndroidExpectedResultFile(String expectedResultFile) {
    private String getAndroidExpectedResultFile(String expectedResultFile) {
        return expectedResultFile.replaceFirst(LAYOUT_TESTS_ROOT, ANDROID_EXPECTED_RESULT_DIR);
        return expectedResultFile.replaceFirst(LAYOUT_TESTS_ROOT, ANDROID_EXPECTED_RESULT_DIR);
    }
    }
@@ -283,7 +296,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh


        String resultFile = getResultFile(test);
        String resultFile = getResultFile(test);
        if (resultFile == null) {
        if (resultFile == null) {
            //simply ignore this test
            // Simply ignore this test.
            return;
            return;
        }
        }
        if (mRebaselineResults) {
        if (mRebaselineResults) {
@@ -339,8 +352,10 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
        this.mTestList = new Vector<String>();
        this.mTestList = new Vector<String>();


        // Read settings
        // Read settings
        this.mTestPathPrefix = (new File(LAYOUT_TESTS_ROOT + runner.mTestPath)).getAbsolutePath();
        mTestPathPrefix = (new File(LAYOUT_TESTS_ROOT + runner.mTestPath)).getAbsolutePath();
        this.mRebaselineResults = runner.mRebaseline;
        mRebaselineResults = runner.mRebaseline;
        // JSC is the default JavaScript engine.
        mJsEngine = runner.mJsEngine == null ? "jsc" : runner.mJsEngine;


        int timeout = runner.mTimeoutInMillis;
        int timeout = runner.mTimeoutInMillis;
        if (timeout <= 0) {
        if (timeout <= 0) {