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.2.9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.0.pre10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.0.pre9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.0.pre8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.0.pre7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.0.pre6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.0.pre5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.0.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.0.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.2.0.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java
calabash-android-0.1.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForScreen.java