예제 #1
0
 public static String[] getCurrentToggleButtons() throws Exception {
   ArrayList<String> abar =
       Utils.jsonArrayToStringList(
           Client.getInstance()
               .map(Constants.ROBOTIUM_SOLO, "getCurrentViews", "android.widget.ToggleButton"));
   return abar.toArray(new String[0]);
 }
예제 #2
0
 public static String[] getCurrentViews(String classToFilterBy, String parent) throws Exception {
   ArrayList<String> abar =
       Utils.jsonArrayToStringList(
           Client.getInstance()
               .map(Constants.ROBOTIUM_SOLO, "getCurrentViews", classToFilterBy, parent));
   return abar.toArray(new String[0]);
 }
예제 #3
0
 public static String[] clickLongInList(int line, int index, int time) throws Exception {
   ArrayList<String> abar =
       Utils.jsonArrayToStringList(
           Client.getInstance()
               .map(Constants.ROBOTIUM_SOLO, "clickLongInList", line, index, time));
   return abar.toArray(new String[0]);
 }
예제 #4
0
  public static void setAppEnvironmentVariables() throws Exception {
    // get environment variables
    app_package = Utils.getEnv("ROBO_APP_PACKAGE", app_package);
    if (app_package == null) {
      throw new Exception("ROBO_APP_PACKAGE is not set");
    }

    test_class = Utils.getEnv("ROBO_TEST_CLASS", test_class);
    if (test_class == null) {
      throw new Exception("ROBO_TEST_CLASS is not set");
    }

    test_runner = Utils.getEnv("ROBO_TEST_RUNNER", test_runner);
    if (test_runner == null) {
      throw new Exception("ROBO_TEST_RUNNER is not set");
    }
  }
예제 #5
0
  // This is called in the failure method override above
  public void tearDown() throws Exception {
    try {
      EmSingleton.get().close();
      killApp();

      // clear stale ADB ports
      Utils.clearStaleADBTunnels("ROBO");

      // stop logcat
      TestLogger.get().info("Stopping logcat");
      logcatLogger.stopLogListener();
      logcatLogger = null;

      // store logs
      Device.storeLogs("adb_robo.log", "robo.log");

      // stop EventManager
      EmSingleton.release();
    } catch (Exception e) {

    } finally {
      DebugBridge.destroy();
    }
  }
예제 #6
0
 public static String[] getVisibleText() throws Exception {
   ArrayList<String> abar =
       Utils.jsonArrayToStringList(
           Client.getInstance().map(Constants.ROBOTIUM_SOLO, "getVisibleText"));
   return abar.toArray(new String[0]);
 }
예제 #7
0
 /**
  * Returns a string array of all of the text contained within a view
  *
  * @param viewName
  * @return
  */
 public static String[] getTextFromView(String viewName) throws Exception {
   ArrayList<String> abar =
       Utils.jsonArrayToStringList(
           Client.getInstance().map(Constants.ROBOTIUM_SOLO, "getTextFromView", viewName));
   return abar.toArray(new String[0]);
 }
예제 #8
0
 public static String[] getAllOpenedActivities() throws Exception {
   ArrayList<String> abar =
       Utils.jsonArrayToStringList(
           Client.getInstance().map(Constants.ROBOTIUM_SOLO, "getAllOpenedActivities"));
   return abar.toArray(new String[0]);
 }
예제 #9
0
  /**
   * This is the generic test setup function
   *
   * @param relaunch - true if this is an app relaunch
   * @param clearAppData - true if you want app data cleared, false otherwise
   */
  public void setUp(String testName, Boolean relaunch, Boolean clearAppData) throws Exception {
    if (!relaunch) {
      logger.info("Starting test {}", testName);
      Device.setupLogDirectories(testName);

      // clear stale ports
      Utils.clearStaleADBTunnels("ROBO");

      // find a useable port
      PortSingleton.getInstance().setPort(Utils.getFreePort());

      // create adb tunnel
      Utils.addADBTunnelWithPIDFile("ROBO", PortSingleton.getInstance().getPort());
    }

    // see if a server is already listening
    boolean clientWasListening = false;
    if (Client.getInstance().isListening()) {
      clientWasListening = true;
    }

    if (clearAppData) {
      // clear app data - this has the side effect of killing a running app
      // TODO: this only works on 2.3+.. need a solution for 2.1+
      Device.clearAppData(app_package);
    }

    // wait for the client to stop listening if it was previously listening
    if (clientWasListening) {
      // wait for the server to be dead
      for (int x = 0; x < 10; x++) {
        // try to make a query.. if it doesnt work then sleep
        TestLogger.get().info("Trying to see if server is still available..");

        if (!Client.getInstance().isListening()) break;

        if (x == 9) throw new Exception("Server is still available, but should not be");

        Thread.sleep(2000);
      }
    }

    if (!relaunch) {
      TestLogger.get().info("Starting logcat");
      if (logcatLogger == null) {
        logcatLogger =
            new LogcatLogger(
                System.getProperty("java.io.tmpdir") + File.separator + "adb_robo.log");
      }
      logcatLogger.startLogListener();

      // set up event manager
      EmSingleton.get().clearEvents();
    }

    // starting test runner
    TestLogger.get().info("Starting RC Runner");

    // start app
    startApp();
  }