Git Product home page Git Product logo

ats.dslcc's Introduction

DSL Transpiler

To generate java file, use : gradle generateJavaFile

AiC DSL

Example : test_file_example.aic

Feature: "Example feature"

    Scenario: "Scenario 1"
        Click on “Sensor”
        Scroll from "Picture" to "Photometer"
        Scroll from "Photometer" to "Gyroscope
        Click on "Proximity Sensor"
        Type "Value is going to change..." into "R.id.input_exemple"
        Set sensor "TYPE_PROXIMITY" at 18
        Replace "It's working !" into "R.id.input_exemple"
        Click on "Proximity Sensor"
        Scroll from "Proximity Sensor" to "Bluetooth"
        Click on "Ambient Thermometer"
    End
    
    Scenario: "Scenario 2"
        Set battery level at 5
        Check if "Low battery" exists
    End
    
End

Features

You can only write one feature per file. Set name with double quote. Finished with keyword End

Scenarios

You could write as many scenario as you want into a feature. Like features, set name with double quote and finished with keyword End. It contains DSL instructions.

Instructions

  • Set sensor SENSOR_TYPE at SENSOR_VALUE(Integer)
  • Set battery level at BATTERY_LEVEL(Integer)
  • Set Gps position at LATITUDE_VALUE(Float), LONGITUDE_VALUE(Float), ALTITUDE_VALUE(Float)
  • Take a screenshot
  • Start recording
  • Stop recording

Sensor Type

  • TYPE_ACCELEROMETER
  • TYPE_LINEAR_ACCELERATION
  • TYPE_PRESSURE
  • TYPE_LIGHT
  • TYPE_TEMPERATURE
  • TYPE_AMBIENT_TEMPERATURE
  • TYPE_PROXIMITY
  • TYPE_GRAVITY
  • TYPE_MAGNETIC_FIELD
  • TYPE_GYROSCOPE
  • TYPE_ROTATION_VECTOR

Recording

You have the abilitie to record your test set, by taking screenshot and/or taking video from the virtual machine screen.

Write test with UiAutomator

You have to include AiC Test Framework into your Android project. Then create new testing source file in your project. You can write "classic" UiAutomator tests, and/or include AiC special instructions like setting sensors or location.

Example :

import .....;

import com.zenika.aic.core.libs.sensor.Device;

@RunWith(AndroidJUnit4.class)
public class Testing extends InstrumentationTestCase {

	private Device device;
	private String appName = "Sensor";


    @Before
    public void init() {
        device = new Device(appName, InstrumentationRegistry.getInstrumentation());
	}

	@Test
	public void test_one() {
		device.getBatteryInstance().setLevel(100, 100);
		device.takeScreenshot();
		device.startRecording();
		device.waitForUpdate();
	}

	@Test
	public void test_two() {
		device.getBatteryInstance().setLevel(25, 100);
		try {
			selectSensor("Photometer", "Sensor");
		} catch (UiObjectNotFoundException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		device.waitForUpdate();
		device.takeScreenshot();
		device.setValuesForSensor(new float[]{42}, Sensor.TYPE_LIGHT);
		device.waitForUpdate();
		device.takeScreenshot();
		try {
			selectSensor("Home", "Photometer");
		} catch (UiObjectNotFoundException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		device.waitForUpdate();
		device.stopRecording();
	}
	
    public void selectSensor(String sensor, String from) throws UiObjectNotFoundException, RemoteException {
		UiObject2 navigationDrawerButton = device.getUiDevice().findObject(By.text(from));
		assertTrue("Navigation drawer button not found", navigationDrawerButton != null);
		navigationDrawerButton.click();

		device.getUiDevice().waitForWindowUpdate("", 1000);

		UiObject2 item = device.getUiDevice().findObject(By.text(sensor));
		assertTrue(sensor + " item not found", navigationDrawerButton != null);
		item.click();
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.