Sha256: 58fbcf7959a843cc7e33f990d84c11c5476383b18f9b4d8c548dec98ad78dae9

Contents?: true

Size: 1.43 KB

Versions: 14

Compression:

Stored size: 1.43 KB

Contents

package com.amplify.honeydew_server.actions;

import android.util.Log;
import com.amplify.honeydew_server.Action;
import com.amplify.honeydew_server.Result;
import com.android.uiautomator.core.UiCollection;
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;

import java.util.Map;

public abstract class AbstractChildCountAction extends Action {
    public AbstractChildCountAction(UiDevice uiDevice) {
        super(uiDevice);
    }

    protected abstract boolean isTrue(int childCount, int count);

    @Override
    public final Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
        Log.d(TAG, "Entering " + TAG);
        String parentDescription = (String) arguments.get("parent_description");
        String childDescription = (String) arguments.get("child_description");
        int expectedCount = ((Double) arguments.get("child_count")).intValue();

        UiCollection parentElement = new UiCollection(new UiSelector().description(parentDescription));
        int actualCount = parentElement.getChildCount(new UiSelector().description(childDescription));
        Log.d(TAG, "Actual count was: " + actualCount + " when " + expectedCount + " was expected");
        return new Result(isTrue(expectedCount, actualCount), "Actual count was: " + actualCount + " when " + expectedCount + " was expected");

    }
}

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
honeydew-0.29.1 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.29.0 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.28.0 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.27.4 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.27.3 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.27.2 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.27.1 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.27.0 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.25.0 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.24.1 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.24.0 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.23.0 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.22.0 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java
honeydew-0.21.0 server/src/main/java/com/amplify/honeydew_server/actions/AbstractChildCountAction.java