Sha256: 2aff18577cdd74375395499afb3dd0987e783952cada0aa4cbeb9ebd8d43b040

Contents?: true

Size: 1.49 KB

Versions: 124

Compression:

Stored size: 1.49 KB

Contents

package sh.calaba.instrumentationbackend.actions.wait;


import sh.calaba.instrumentationbackend.InstrumentationBackend;
import sh.calaba.instrumentationbackend.Result;
import sh.calaba.instrumentationbackend.actions.Action;
import android.view.View;
import android.widget.ProgressBar;


public class WaitForProgress implements Action {

    @Override
    public Result execute(String... args) {
        int timeout = 60000;
        long waitUntil = System.currentTimeMillis() + timeout;

        while (numberOfVisibleProgressBars() > 0) {
            if (System.currentTimeMillis() > waitUntil) {
                return new Result(false, "Timedout waiting for no visible progressbars (" + numberOfVisibleProgressBars() +" still visible).");
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        return Result.successResult();
    }

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

    private int numberOfVisibleProgressBars() {
        int visibleProgressBars = 0;
        for (ProgressBar v : InstrumentationBackend.solo.getCurrentProgressBars()) {
            if (v != null & v.getVisibility() != View.GONE && v.getVisibility() != View.INVISIBLE) {
                visibleProgressBars++;
                System.out.println("Found visible progressbar number:" + visibleProgressBars);
            }
        }
        return visibleProgressBars;
    }

}

Version data entries

124 entries across 124 versions & 2 rubygems

Version Path
calabash-android-0.4.3.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.3.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
testautoa-0.4.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre18 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
testautoa-0.4.0.pre19 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
testautoa-0.4.0.pre18 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
testautoa-0.4.0.pre16 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre17 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre16 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre15 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre11 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
calabash-android-0.4.0.pre5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java