package edu.wm.translationengine.uiautomator;



import edu.wm.translationengine.classes.StepTestCase;
import edu.wm.translationengine.trans.Functions;
import edu.wm.translationengine.trans.GenericFunctions;

public class UiAutomatorFunctions implements Functions{

	
	public void uiautomator_switcher(String action, StepTestCase s) throws Exception{
		
		if(action.equals("CLICK")){
			tap(s);
		}
		if(action.equals("LONG_CLICK")){
			longTap(s);
		}
		if(action.equals("TYPE")){

		}
	}
	
	public boolean tap(StepTestCase testCase) throws Exception {
		String uiautomator_command = new String();		
		uiautomator_command += "\t\tnew UiObject(new UiSelector().resourceId(\"" + testCase.getComponent().getId() + "\")).click();\n";
		UiAutomatorTranslator.toWrite.add(uiautomator_command);
		return true;
	}

	public boolean longTap(StepTestCase testCase) throws Exception {
		String uiautomator_command = new String();		
		uiautomator_command += "\t\tnew UiObject(new UiSelector().resourceId(\"" + testCase.getComponent().getId() + "\")).longClick();\n";
		UiAutomatorTranslator.toWrite.add(uiautomator_command);
		return true;
	}

	public boolean type(StepTestCase testCase) throws Exception{
		
		//asoifjowjfej[pijf
		
		return true;
	}
	public boolean pressKey(StepTestCase testCase) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean swipe(StepTestCase testCase) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean flick(StepTestCase testCase) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean pinch(StepTestCase testCase) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean scrollTo(StepTestCase testCase) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean launchApp(StepTestCase testCase) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean closeApp(StepTestCase testCase) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean pressMenuKey(StepTestCase testCase) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean hideKeyboard(StepTestCase testCase) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

}

@@ -96,16 +96,77 @@
 stCase;%0A
+import edu.wm.translationengine.espresso.EspressoTranslator;%0A
 import e
@@ -536,16 +536,27 @@
 YPE%22))%7B%0A
+%09%09%09type(s);
 %0A%09%09%7D%0A%09%7D%0A
@@ -656,34 +656,380 @@
 = new String();%09
-%09
 %0A
+%09%09if(testCase.getComponent().getType().equals(%22android.widget.CheckedTextView%22))%7B%0A%09%09%09uiautomator_command += %22%5Ct%5Ctnew UiObject(new UiSelector().className(%5C%22android.widget.ListView%5C%22)).getChild(new UiSelector().text(%5C%22%22 + testCase.getComponent().getText() + %22%5C%22)).click();%5Cn%22;%0A%09%09%09UiAutomatorTranslator.toWrite.add(uiautomator_command);%0A%09%09%7D%0A%09%09else%7B%0A%09
 %09%09uiautomator_co
@@ -1134,32 +1134,33 @@
 )).click();%5Cn%22;%0A
+%09
 %09%09UiAutomatorTra
@@ -1193,32 +1193,39 @@
 mator_command);%0A
+%09%09%7D%0A%09%09%0A
 %09%09return true;%0A%09
@@ -1340,16 +1340,366 @@
 ng();%09%09%0A
+%09%09if(testCase.getComponent().getType().equals(%22android.widget.CheckedTextView%22))%7B%0A%09%09%09uiautomator_command += %22%5Ct%5Ctnew UiObject(new UiSelector().className(%5C%22android.widget.ListView%5C%22)).getChild(new UiSelector().text(%5C%22%22 + testCase.getComponent().getText() + %22%5C%22)).longClick();%5Cn%22;%0A%09%09%09UiAutomatorTranslator.toWrite.add(uiautomator_command);%0A%09%09%7D%0A%09%09else%7B%0A
 %09%09uiauto
@@ -1882,16 +1882,20 @@
 mmand);%0A
+%09%09%7D%0A
 %09%09return
@@ -1973,33 +1973,283 @@
 %7B%0A%09%09
-%0A%09%09//asoifjowjfej%5Bpijf%0A%09%09
+String uiautomator_command = new String();%09%09%0A%09%09uiautomator_command += %22%5Ct%5Ctnew UiObject(new UiSelector().resourceId(%5C%22%22 + testCase.getComponent().getId() + %22%5C%22)).setText(%22 + testCase.getComponent().getText() + %22);%5Cn%22;%0A%09%09UiAutomatorTranslator.toWrite.add(uiautomator_command);
 %0A%09%09r

Update UiAutomatorFunctions.java