<commit_before>package nl.hsac.fitnesse.fixture.slim.mobile;

import io.appium.java_client.*;

import io.appium.java_client.android.AndroidDriver;
import nl.hsac.fitnesse.fixture.slim.SlimFixtureException;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;

import nl.hsac.fitnesse.fixture.slim.web.BrowserTest;
import nl.hsac.fitnesse.fixture.slim.web.annotation.TimeoutPolicy;
import nl.hsac.fitnesse.fixture.slim.web.annotation.WaitUntil;

import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;

/**
 * Android App fixture for use with an android driver. Aimed at effortlessly testing native apps
 */

public class AndroidAppTest extends BrowserTest {
    private int SWIPESPEED = 1000;
    private int WAITAFTERSWIPE = 0;

    public AndroidAppTest() {
        super("X");
        setImplicitWaitForAngularTo(false);
    }

    public void setImplicitWaitInSeconds(long stepDelay){
        getSeleniumHelper().androidDriver().manage().timeouts().implicitlyWait(stepDelay, TimeUnit.SECONDS);
    }

    public void setSwipeSpeedInMilliseconds(int swipeSpeed){
        this.SWIPESPEED = swipeSpeed;
    }

    public void setWaitAfterSwipe(int waitAfterSwipe){
        this.WAITAFTERSWIPE = waitAfterSwipe;
    }

    @WaitUntil(TimeoutPolicy.RETURN_FALSE)
    public boolean tap(String locator){

        boolean result = false;
        MobileElement element = getMobileElement(locator);

        if(element != null){
            TouchAction tap = new TouchAction(getSeleniumHelper().androidDriver()).tap(element);
            tap.perform();

            result = true;
        }

        return result;
    }

    @WaitUntil(TimeoutPolicy.RETURN_FALSE)
    public boolean enterAs(String value, String locator) {
        boolean result = false;
        MobileElement element = getMobileElement(locator);

        if(element != null){
            element.sendKeys(value);
            getSeleniumHelper().androidDriver().hideKeyboard();
            result = true;
        }

        return result;
    }

    @WaitUntil(TimeoutPolicy.RETURN_NULL)
    public String valueOf(String locator){
        MobileElement el = getMobileElement(locator);
        return el.getText();
    }

    @WaitUntil(TimeoutPolicy.RETURN_FALSE)
    public Boolean elementDisplayed(String locator){
        return(getMobileElement(locator).isDisplayed());
    }

    public void swipeUp() {

        Dimension size = getSeleniumHelper().androidDriver().manage().window().getSize();
        int startX = size.width / 2;
        int startY = (int) (size.height * 0.8);
        int endY = (int) (size.height * 0.2);

        swipe(startX, startY, startX, endY, SWIPESPEED, WAITAFTERSWIPE);
    }

    public void swipeDown() {

        Dimension size = getSeleniumHelper().androidDriver().manage().window().getSize();
        int startX = size.width / 2;
        int startY = (int) (size.height * 0.2);
        int endY = (int) (size.height * 0.8);

        swipe(startX, startY, startX, endY, SWIPESPEED, WAITAFTERSWIPE);
    }

    public void swipeLeft() {

        Dimension size = getSeleniumHelper().androidDriver().manage().window().getSize();
        int startX = (int) (size.width * 0.8);
        int endX = (int) (size.width * 0.2);
        int startY = size.height / 2;

        swipe(startX, startY, endX, startY, SWIPESPEED, WAITAFTERSWIPE);
    }

    public void swipeRight() {

        Dimension size = getSeleniumHelper().androidDriver().manage().window().getSize();
        int startX = (int) (size.width * 0.2);
        int endX = (int) (size.width * 0.8);
        int startY = size.height / 2;

        swipe(startX, startY, endX, startY, SWIPESPEED, WAITAFTERSWIPE);
    }

    public boolean swipeFrom(String direction, String locator){
        boolean result = false;
        MobileElement element = null;
        if(getMobileElement(locator) != null) {
            element = getMobileElement(locator);
        }
        if(element != null){
            Dimension size = getSeleniumHelper().androidDriver().manage().window().getSize();
            Point elementLocation = element.getLocation();
            int startX = elementLocation.getX();
            int startY = elementLocation.getY();
            int endX;
            int endY;

            switch (direction.toLowerCase().charAt(0)){
                case 'u':
                    endX = startX;
                    endY = 0;
                    break;
                case 'd':
                    endX = startX;
                    endY = size.getHeight();
                    break;
                case 'l':
                    endX = 0;
                    endY = startY;
                    break;
                case 'r':
                    endX = size.getWidth();
                    endY = startY;
                    break;
                default:
                   System.err.print("ERROR: " + direction + " is not a valid swipe direction.");
                   return false;
            }
            swipe(startX, startY, endX, endY, SWIPESPEED, WAITAFTERSWIPE);
            result = true;
        }
        else{<commit_msg>Use standard Java convention for field name, and cleanup imports<commit_after>package nl.hsac.fitnesse.fixture.slim.mobile;

import io.appium.java_client.*;

import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.*;

import nl.hsac.fitnesse.fixture.slim.web.BrowserTest;
import nl.hsac.fitnesse.fixture.slim.web.annotation.TimeoutPolicy;
import nl.hsac.fitnesse.fixture.slim.web.annotation.WaitUntil;

import java.util.concurrent.TimeUnit;

/**
 * Android App fixture for use with an android driver. Aimed at effortlessly testing native apps
 */

public class AndroidAppTest extends BrowserTest {
    private int swipeSpeed = 1000;
    private int waitAfterSwipe = 0;

    public AndroidAppTest() {
        super("X");
        setImplicitWaitForAngularTo(false);
    }

    public void setImplicitWaitInSeconds(long stepDelay){
        getSeleniumHelper().androidDriver().manage().timeouts().implicitlyWait(stepDelay, TimeUnit.SECONDS);
    }

    public void setSwipeSpeedInMilliseconds(int swipeSpeed){
        this.swipeSpeed = swipeSpeed;
    }

    public void setWaitAfterSwipe(int waitAfterSwipe){
        this.waitAfterSwipe = waitAfterSwipe;
    }

    @WaitUntil(TimeoutPolicy.RETURN_FALSE)
    public boolean tap(String locator){

        boolean result = false;
        MobileElement element = getMobileElement(locator);

        if(element != null){
            TouchAction tap = new TouchAction(getSeleniumHelper().androidDriver()).tap(element);
            tap.perform();

            result = true;
        }

        return result;
    }

    @WaitUntil(TimeoutPolicy.RETURN_FALSE)
    public boolean enterAs(String value, String locator) {
        boolean result = false;
        MobileElement element = getMobileElement(locator);

        if(element != null){
            element.sendKeys(value);
            getSeleniumHelper().androidDriver().hideKeyboard();
            result = true;
        }

        return result;
    }

    @WaitUntil(TimeoutPolicy.RETURN_NULL)
    public String valueOf(String locator){
        MobileElement el = getMobileElement(locator);
        return el.getText();
    }

    @WaitUntil(TimeoutPolicy.RETURN_FALSE)
    public Boolean elementDisplayed(String locator){
        return(getMobileElement(locator).isDisplayed());
    }

    public void swipeUp() {

        Dimension size = getSeleniumHelper().androidDriver().manage().window().getSize();
        int startX = size.width / 2;
        int startY = (int) (size.height * 0.8);
        int endY = (int) (size.height * 0.2);

        swipe(startX, startY, startX, endY, swipeSpeed, waitAfterSwipe);
    }

    public void swipeDown() {

        Dimension size = getSeleniumHelper().androidDriver().manage().window().getSize();
        int startX = size.width / 2;
        int startY = (int) (size.height * 0.2);
        int endY = (int) (size.height * 0.8);

        swipe(startX, startY, startX, endY, swipeSpeed, waitAfterSwipe);
    }

    public void swipeLeft() {

        Dimension size = getSeleniumHelper().androidDriver().manage().window().getSize();
        int startX = (int) (size.width * 0.8);
        int endX = (int) (size.width * 0.2);
        int startY = size.height / 2;

        swipe(startX, startY, endX, startY, swipeSpeed, waitAfterSwipe);
    }

    public void swipeRight() {

        Dimension size = getSeleniumHelper().androidDriver().manage().window().getSize();
        int startX = (int) (size.width * 0.2);
        int endX = (int) (size.width * 0.8);
        int startY = size.height / 2;

        swipe(startX, startY, endX, startY, swipeSpeed, waitAfterSwipe);
    }

    public boolean swipeFrom(String direction, String locator){
        boolean result = false;
        MobileElement element = null;
        if(getMobileElement(locator) != null) {
            element = getMobileElement(locator);
        }
        if(element != null){
            Dimension size = getSeleniumHelper().androidDriver().manage().window().getSize();
            Point elementLocation = element.getLocation();
            int startX = elementLocation.getX();
            int startY = elementLocation.getY();
            int endX;
            int endY;

            switch (direction.toLowerCase().charAt(0)){
                case 'u':
                    endX = startX;
                    endY = 0;
                    break;
                case 'd':
                    endX = startX;
                    endY = size.getHeight();
                    break;
                case 'l':
                    endX = 0;
                    endY = startY;
                    break;
                case 'r':
                    endX = size.getWidth();
                    endY = startY;
                    break;
                default:
                   System.err.print("ERROR: " + direction + " is not a valid swipe direction.");
                   return false;
            }
            swipe(startX, startY, endX, endY, swipeSpeed, waitAfterSwipe);
            result = true;
        }
        else{
{'fraction_non_alphanumeric': 0.10946089304658116, 'fraction_numerical': 0.0054007136657344005, 'mean_word_length': 2.1917513080947986, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4941418', 'n_tokens_mistral': 3089, 'n_tokens_neox': 2942, 'n_words': 646}