mobile/android/base/tests/testCheck2.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/tests/testCheck2.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +package org.mozilla.gecko.tests;
     1.5 +
     1.6 +import org.json.JSONObject;
     1.7 +
     1.8 +public class testCheck2 extends PixelTest {
     1.9 +    @Override
    1.10 +    protected Type getTestType() {
    1.11 +        return Type.TALOS;
    1.12 +    }
    1.13 +
    1.14 +    public void testCheck2() {
    1.15 +        String url = getAbsoluteUrl("/startup_test/fennecmark/cnn/cnn.com/index.html");
    1.16 +
    1.17 +        // Enable double-tap zooming
    1.18 +        JSONObject jsonPref = new JSONObject();
    1.19 +        try {
    1.20 +            jsonPref.put("name", "browser.ui.zoom.force-user-scalable");
    1.21 +            jsonPref.put("type", "bool");
    1.22 +            jsonPref.put("value", true);
    1.23 +            setPreferenceAndWaitForChange(jsonPref);
    1.24 +        } catch (Exception ex) {
    1.25 +            mAsserter.ok(false, "exception in testCheck2", ex.toString());
    1.26 +        }
    1.27 +
    1.28 +        blockForGeckoReady();
    1.29 +        loadAndPaint(url);
    1.30 +
    1.31 +        mDriver.setupScrollHandling();
    1.32 +
    1.33 +        /*
    1.34 +         * for this test, we load the timecube page, and replay a recorded sequence of events
    1.35 +         * that is a user panning/zooming around the page. specific things in the sequence
    1.36 +         * include:
    1.37 +         * - scroll on one axis followed by scroll on another axis
    1.38 +         * - pinch zoom (in and out)
    1.39 +         * - double-tap zoom (in and out)
    1.40 +         * - multi-fling panning with different velocities on each fling
    1.41 +         *
    1.42 +         * this checkerboarding metric is going to be more of a "functional" style test than
    1.43 +         * a "unit" style test; i.e. it covers a little bit of a lot of things to measure
    1.44 +         * overall performance, but doesn't really allow identifying which part is slow.
    1.45 +         */
    1.46 +
    1.47 +        MotionEventReplayer mer = new MotionEventReplayer(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop(),
    1.48 +                mDriver.getGeckoWidth(), mDriver.getGeckoHeight());
    1.49 +
    1.50 +        float completeness = 0.0f;
    1.51 +        mDriver.startCheckerboardRecording();
    1.52 +        // replay the events
    1.53 +        try {
    1.54 +            mer.replayEvents(getAsset("testcheck2-motionevents"));
    1.55 +            // give it some time to draw any final frames
    1.56 +            Thread.sleep(1000);
    1.57 +            completeness = mDriver.stopCheckerboardRecording();
    1.58 +        } catch (Exception e) {
    1.59 +            mAsserter.ok(false, "Exception while replaying events", e.toString());
    1.60 +        }
    1.61 +
    1.62 +        mAsserter.dumpLog("__start_report" + completeness + "__end_report");
    1.63 +        System.out.println("Completeness score: " + completeness);
    1.64 +        long msecs = System.currentTimeMillis();
    1.65 +        mAsserter.dumpLog("__startTimestamp" + msecs + "__endTimestamp");
    1.66 +    }
    1.67 +}

mercurial