Sha256: 5d99a4a0f1d8909c6180e0c25c82b6485070c13a4ba7163b41fa178b07ea02b8

Contents?: true

Size: 1.58 KB

Versions: 38

Compression:

Stored size: 1.58 KB

Contents

package sh.calaba.instrumentationbackend.actions.wait;

import sh.calaba.instrumentationbackend.InstrumentationBackend;
import sh.calaba.instrumentationbackend.Result;
import sh.calaba.instrumentationbackend.actions.Action;

public class WaitForScreen implements Action {

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

        final int DEFAULT_TIMEOUT = 5 * 1000;

        switch (args.length) {
        case 0:
            return new Result(false, "Cannot check for correct screen. No Activity name supplied!");
        case 1: {
            if (InstrumentationBackend.solo.waitForActivity(args[0], DEFAULT_TIMEOUT)) {
                return Result.successResult();
            } else {
                return new Result(false, "Screen " + args[0] + " not found");
            }
        }
        case 2: { // 1st arg is Activity name, 2nd arg is timeout
            int timeout = DEFAULT_TIMEOUT;
            
            try {
                timeout = Integer.parseInt(args[1]);
            } catch (NumberFormatException e) {
                return new Result(false, "Invalid timeout supplied. Should be an integer!"); 
            }
            
            if (InstrumentationBackend.solo.waitForActivity(args[0], timeout)) {
                return Result.successResult();
            } else {
                return new Result(false, "Screen " + args[0] + " not found");
            }
        }
        default:
            return new Result(false, "Too many argument supplied to wait_for_screen!");
        }
    }

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

}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
calabash-android-0.0.19 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.18 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.17 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.16 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.15 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.14 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.13 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.12 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.11 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.0.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java