Sha256: 1b56d4e852f5a9f705039b44344b48da89911a69abc9feb4fdd35e481ee3f9b9

Contents?: true

Size: 1.13 KB

Versions: 97

Compression:

Stored size: 1.13 KB

Contents

package sh.calaba.instrumentationbackend.actions.view;

import sh.calaba.instrumentationbackend.InstrumentationBackend;
import sh.calaba.instrumentationbackend.Result;
import sh.calaba.instrumentationbackend.actions.Action;
import android.app.Activity;

/**
 * This action checks that the current activity under test has the focus.
 * 
 * This is useful to run tests across different applications (for example,
 * your application launching the browser). Since the instrumentation can
 * only work with the application under test, then all we can assert is that
 * said application has lost the focus.
 * 
 * @author Gianpiero Puleo (gianpi@ustwo.co.uk)
 * @author Juan Delgado (juan@ustwo.co.uk)
 */
@SuppressWarnings("deprecation")
public class IsCurrentActivityFocused implements Action {

	@Override
	public Result execute(String... args) {
		
		Activity currentActivity = InstrumentationBackend.solo.getCurrentActivity();
		
		String hasFocus = "false";
		
		if (currentActivity.hasWindowFocus()) {
			hasFocus = "true";
		}
		
		return new Result(true, hasFocus);	
	}

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

Version data entries

97 entries across 97 versions & 2 rubygems

Version Path
calabash-android-0.4.0.pre5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.4.0.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.4.0.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
testautoa-0.4.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.4.0.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.4.0.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.3.pre5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.3.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.3.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.3.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java
calabash-android-0.3.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsCurrentActivityFocused.java