package com.mumux.androidtesting.scenario;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import com.mumux.androidtesting.actions.Action;
import org.json.JSONException;
import org.json.JSONObject;
public class OptionalAction extends Action {
private final Action action;
public OptionalAction(Action action) {
this.action = action;
}
public String run(UiAutomatorTestCase uiAutomatorTestCase, Runtime runtime) {
return action.run(uiAutomatorTestCase, runtime);
}
public String toString() {
return "(" + action.toString() + ")";
}
public JSONObject toJson() {
JSONObject jsonObject = action.toJson();
try {
jsonObject.put("optional", true);
} catch (JSONException e) {
e.printStackTrace();
}
return jsonObject;
}
public String getName() {
return action.getName();
}
}