Sha256: 01a3e7182c61f4826c69fdca0db0e75542450f7d3dad3b2db5407a71b39f1969

Contents?: true

Size: 1.34 KB

Versions: 54

Compression:

Stored size: 1.34 KB

Contents

package sh.calaba.instrumentationbackend.actions.webview;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import sh.calaba.instrumentationbackend.InstrumentationBackend;
import sh.calaba.instrumentationbackend.Result;
import sh.calaba.instrumentationbackend.actions.Action;
import sh.calaba.org.codehaus.jackson.map.ObjectMapper;
import sh.calaba.org.codehaus.jackson.type.TypeReference;


public class Touch implements Action {

    @Override
    public Result execute(String... args) {

        try {
            String queryResult = QueryHelper.executeJavascriptInWebview("calabash.js", args[1], args[0]);
            List<HashMap<String,Object>> p = new ObjectMapper().readValue(queryResult, new TypeReference<List<HashMap<String,Object>>>(){});

            if (p.isEmpty()) {
                throw new RuntimeException("No element found");
            }

            Map<String, Object> firstRect = QueryHelper.findFirstVisibleRectangle(p);

            float[] screenCoordinates = QueryHelper.getScreenCoordinatesForCenter(firstRect);

            InstrumentationBackend.solo.clickOnScreen(screenCoordinates[0], screenCoordinates[1]);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        return new Result(true, "");
    }

    @Override
    public String key() {
        return "touch";
    }
}

Version data entries

54 entries across 54 versions & 2 rubygems

Version Path
calabash-android-0.3.2.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.2.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.2.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0.pre10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0.pre9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0.pre8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0.pre7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0.pre6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0.pre5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.3.0.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.2.22 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.2.21 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.2.20 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.2.19 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java
calabash-android-0.2.18 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java