Skip to content

Commit

Permalink
Renaming missspelled exception type. Removing blank log lines
Browse files Browse the repository at this point in the history
  • Loading branch information
vidstige committed Sep 5, 2013
1 parent fe59e88 commit dbc45bf
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 62 deletions.
22 changes: 13 additions & 9 deletions src/se/vidstige/android/uimutilator/UiAutomatorRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public UiAutomatorRunner(Adb adb, String jarfile) {
this.adb = adb;
}

public String run(String classname, String methodname, Map<String, String> parameters) throws UiMutilator {
public String run(String classname, String methodname, Map<String, String> parameters) throws UiMutilatorException {
try
{
ArrayList<String> arguments = new ArrayList<String>(Arrays.asList("shell", "uiautomator", "runtest", jarfile,
Expand All @@ -47,21 +47,25 @@ public String run(String classname, String methodname, Map<String, String> param
return result;
}
catch (UnsupportedEncodingException e) {
throw new UiMutilator("Could not run test on device", e);
throw new UiMutilatorException("Could not run test on device", e);
} catch (AdbException e) {
throw new UiMutilator("Could not run test on device", e);
throw new UiMutilatorException("Could not run test on device", e);
} catch (IOException e) {
throw new UiMutilator("Could not run test on device", e);
throw new UiMutilatorException("Could not run test on device", e);
}
}

private String parseTests(BufferedReader input, String classname, String methodname) throws IOException, UiMutilator {
private String parseTests(BufferedReader input, String classname, String methodname) throws IOException, UiMutilatorException {
String line;
String lastExceptionMessage = null;
String response = null;

int n = 0;
while ((line = input.readLine()) != null)
{
System.out.println("line: " + line);
if (n++ % 2 == 1) continue;

System.out.println(line);

if (line.startsWith(INSTRUMENTATION_STATUS))
{
Expand All @@ -70,7 +74,7 @@ private String parseTests(BufferedReader input, String classname, String methodn
{
String classname2 = rest.substring("class=".length());
if (!classname2.equals(classname)) {
throw new UiMutilator("Expected class " + classname + " to be run, but " + classname2 + " was run");
throw new UiMutilatorException("Expected class " + classname + " to be run, but " + classname2 + " was run");
}
}
int idx = rest.indexOf("UiObjectNotFoundException: ");
Expand All @@ -87,9 +91,9 @@ private String parseTests(BufferedReader input, String classname, String methodn
if ("FAILURES!!!".equals(line))
{
if (lastExceptionMessage == null)
throw new UiMutilator("Could not execute " + classname + "#" + methodname + " on device");
throw new UiMutilatorException("Could not execute " + classname + "#" + methodname + " on device");
else
throw new UiMutilator("UiObject not found: " + lastExceptionMessage);
throw new UiMutilatorException("UiObject not found: " + lastExceptionMessage);
}
}
return response;
Expand Down
48 changes: 24 additions & 24 deletions src/se/vidstige/android/uimutilator/UiDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class UiDevice {
private final Adb adb;
private final UiAutomatorRunner runner;

UiDevice(AdbDevice device) throws UiMutilator {
UiDevice(AdbDevice device) throws UiMutilatorException {
try
{
adb = new Adb(device);
Expand All @@ -43,13 +43,13 @@ public class UiDevice {
adb.push(deluxJar, "/data/local/tmp/command-tests.jar");
}
catch (IOException e) {
throw new UiMutilator("Could not create UiDevice", e);
throw new UiMutilatorException("Could not create UiDevice", e);
} catch (AdbException e) {
throw new UiMutilator("Could not create UiDevice", e);
throw new UiMutilatorException("Could not create UiDevice", e);
}
}

public void takeScreenshot(File destination) throws UiMutilator
public void takeScreenshot(File destination) throws UiMutilatorException
{
try
{
Expand All @@ -60,7 +60,7 @@ public void takeScreenshot(File destination) throws UiMutilator
}
catch (AdbException e)
{
throw new UiMutilator("Could save take screenshot to " + destination.getPath(), e);
throw new UiMutilatorException("Could save take screenshot to " + destination.getPath(), e);
}
}

Expand All @@ -72,87 +72,87 @@ public UiScrollable newUiScrollable(UiSelector selector) {
return new UiScrollable(runner, selector);
}

public void pressHome() throws UiMutilator {
public void pressHome() throws UiMutilatorException {
runTest("testPressHome");
}

public void pressMenu() throws UiMutilator {
public void pressMenu() throws UiMutilatorException {
runTest("testPressMenu");
}

public void click(int x, int y) throws UiMutilator {
public void click(int x, int y) throws UiMutilatorException {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("x", Integer.toString(x));
parameters.put("y", Integer.toString(y));
runTest("testClick", parameters);
}

public void freezeRotation() throws UiMutilator {
public void freezeRotation() throws UiMutilatorException {
runTest("testFreezeRotation");
}

public void unfreezeRotation() throws UiMutilator
public void unfreezeRotation() throws UiMutilatorException
{
runTest("testUnfreezeRotation");
}

public int getDisplayHeight() throws UiMutilator {
public int getDisplayHeight() throws UiMutilatorException {
String result = runTest("testGetDisplayHeight", new HashMap<String, String>(0));
return Integer.parseInt(result);
}

public int getDisplayWidth() throws UiMutilator {
public int getDisplayWidth() throws UiMutilatorException {
String result = runTest("testGetDisplayWidth", new HashMap<String, String>(0));
return Integer.parseInt(result);
}

public int getDisplayRotation() throws UiMutilator
public int getDisplayRotation() throws UiMutilatorException
{
String result = runTest("testGetDisplayRotation", new HashMap<String, String>(0));
return Integer.parseInt(result);
}

public String getLastTraversedText() throws UiMutilator
public String getLastTraversedText() throws UiMutilatorException
{
String result = runTest("testGetLastTraversedText", new HashMap<String, String>(0));
return result;
}

public boolean isScreenOn() throws UiMutilator
public boolean isScreenOn() throws UiMutilatorException
{
String result = runTest("testIsScreenOn", new HashMap<String, String>(0));
return Boolean.parseBoolean(result);
}

public void pressBack() throws UiMutilator {
public void pressBack() throws UiMutilatorException {
runTest("testPressBack");
}

public void pressSearch() throws UiMutilator {
public void pressSearch() throws UiMutilatorException {
runTest("testPressSearch");
}

public void sleep() throws UiMutilator {
public void sleep() throws UiMutilatorException {
runTest("testSleep");
}

public void wakeUp() throws UiMutilator {
public void wakeUp() throws UiMutilatorException {
runTest("testWakeUp");
}

public void waitForIdle() throws UiMutilator
public void waitForIdle() throws UiMutilatorException
{
runTest("testWaitForIdle");
}

public void waitForIdle(int timeout) throws UiMutilator
public void waitForIdle(int timeout) throws UiMutilatorException
{
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("timeout", Integer.toString(timeout));
runTest("testWaitForIdleTimeout", parameters);
}

public void swipe(int startX, int startY, int endX, int endY, int steps) throws UiMutilator {
public void swipe(int startX, int startY, int endX, int endY, int steps) throws UiMutilatorException {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("startX", Integer.toString(startX));
parameters.put("startY", Integer.toString(startY));
Expand All @@ -162,11 +162,11 @@ public void swipe(int startX, int startY, int endX, int endY, int steps) throws
runTest("testSwipe", parameters);
}

private String runTest(String methodname, Map<String, String> parameters) throws UiMutilator {
private String runTest(String methodname, Map<String, String> parameters) throws UiMutilatorException {
return runner.run("se.vidstige.android.uimutilator.commandtests.UiDeviceCommands", methodname, parameters);
}

private void runTest(String methodname) throws UiMutilator {
private void runTest(String methodname) throws UiMutilatorException {
runner.run("se.vidstige.android.uimutilator.commandtests.UiDeviceCommands", methodname, new HashMap<String, String>(0));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package se.vidstige.android.uimutilator;


public class UiMutilator extends Exception {
public class UiMutilatorException extends Exception {

private static final long serialVersionUID = 6954101221203802578L;

public UiMutilator(String message, Throwable inner) {
public UiMutilatorException(String message, Throwable inner) {
super(message, inner);
}

public UiMutilator(String message) {
public UiMutilatorException(String message) {
super(message);
}
}
16 changes: 8 additions & 8 deletions src/se/vidstige/android/uimutilator/UiMutilatorTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,43 @@

public class UiMutilatorTestCase {

protected UiDeviceFluentBuilder getUiDevice() throws UiMutilator {
protected UiDeviceFluentBuilder getUiDevice() throws UiMutilatorException {
return new UiDeviceFluentBuilder();
}

public static class UiDeviceFluentBuilder
{
public UiDevice any() throws UiMutilator
public UiDevice any() throws UiMutilatorException
{
return new UiDevice(AdbDevice.any());
}

public UiDevice number(int n) throws UiMutilator
public UiDevice number(int n) throws UiMutilatorException
{
try
{
if (n < 0) throw new IllegalArgumentException("n must be >= 0");
List<AdbDevice> devices = new Adb().getDevices();
if (n >= devices.size())
throw new UiMutilator("Could not connect to device " + n + ", only " + devices.size() + " connected");
throw new UiMutilatorException("Could not connect to device " + n + ", only " + devices.size() + " connected");
return new UiDevice(devices.get(n));
}
catch (AdbException e)
{
throw new UiMutilator("Could not get devices", e);
throw new UiMutilatorException("Could not get devices", e);
}
}

public UiDevice withSerial(String serial) throws UiMutilator
public UiDevice withSerial(String serial) throws UiMutilatorException
{
return new UiDevice(new AdbDevice(serial));
}

public UiDevice first() throws UiMutilator {
public UiDevice first() throws UiMutilatorException {
return number(0);
}

public UiDevice second() throws UiMutilator
public UiDevice second() throws UiMutilatorException
{
return number(1);
}
Expand Down
24 changes: 12 additions & 12 deletions src/se/vidstige/android/uimutilator/UiObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,46 @@ public class UiObject {
this.selector = selector;
}

private String run(String methodname) throws UiMutilator {
private String run(String methodname) throws UiMutilatorException {
Map<String, String> parameters = new HashMap<String, String>();
selector.serializeTo(parameters, "s0_");
return runner.run("se.vidstige.android.uimutilator.commandtests.UiObjectCommands", methodname, parameters);
}

private boolean runBool(String methodname) throws UiMutilator {
private boolean runBool(String methodname) throws UiMutilatorException {
String result = run(methodname);
return Boolean.parseBoolean(result);
}

public void click() throws UiMutilator {
public void click() throws UiMutilatorException {
run("testClick");
}

public void testLongClick() throws UiMutilator {
public void testLongClick() throws UiMutilatorException {
run("testLongClick");
}

public String getContentDescription() throws UiMutilator {
public String getContentDescription() throws UiMutilatorException {
return run("testGetContentDescription");
}

public boolean isChecked() throws UiMutilator {
public boolean isChecked() throws UiMutilatorException {
return runBool("testIsChecked");
}

public boolean isEnabled() throws UiMutilator {
public boolean isEnabled() throws UiMutilatorException {
return runBool("testIsEnabled");
}

public void clickAndWaitForNewWindow() throws UiMutilator {
public void clickAndWaitForNewWindow() throws UiMutilatorException {
run("testClickAndWaitForNewWindow");
}

public String getText() throws UiMutilator {
public String getText() throws UiMutilatorException {
return run("testGetText");
}

public void setText(String text) throws UiMutilator {
public void setText(String text) throws UiMutilatorException {
Map<String, String> parameters = new HashMap<String, String>();
selector.serializeTo(parameters, "s0_");

Expand All @@ -63,11 +63,11 @@ public void setText(String text) throws UiMutilator {
parameters);
}

public void clearTextField() throws UiMutilator {
public void clearTextField() throws UiMutilatorException {
run("testClearTextField");
}

public boolean exists() throws UiMutilator {
public boolean exists() throws UiMutilatorException {
return runBool("testExists");
}
}
2 changes: 1 addition & 1 deletion src/se/vidstige/android/uimutilator/UiScrollable.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class UiScrollable {
this.selector = selector;
}

public void scrollIntoView(UiSelector selector) throws UiMutilator {
public void scrollIntoView(UiSelector selector) throws UiMutilatorException {
Map<String, String> parameters = new HashMap<String, String>();
this.selector.serializeTo(parameters, "s0_");
selector.serializeTo(parameters, "s1_");
Expand Down
Loading

0 comments on commit dbc45bf

Please sign in to comment.