예제 #1
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 static void setUp(String testName, Boolean relaunch, Boolean clearAppData)
      throws Exception {
    if (!relaunch) {
      logger.info("Starting test {}", testName);
      Utils.setTestName(testName);
      Device.setupLogDirectories();

      // create adb tunnel
      DebugBridge.get().createTunnel(8080, 8080);
    }

    // see if a server is already listening
    boolean clientWasListening = false;
    if (Client.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();
    }

    // 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.isListening()) break;

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

        Thread.sleep(2000);
      }
    }

    if (!relaunch) {
      // start log listener
      TestLogger.get().info("Clearing logcat");
      DebugBridge.get().clearLogCat();

      TestLogger.get().info("Starting logcat");
      DebugBridge.get().startLogListener("/tmp/adb_robo.log");

      // set up logger
      EmSingleton.intialize();

      EmSingleton.get().clearEvents();
    }

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

    // start app
    Device.startApp();
  }
예제 #2
0
  // This is called in the failure method override above
  public void tearDown() throws Exception {
    try {
      EmSingleton.get().close();
      Device.killApp();

      // stop logcat
      TestLogger.get().info("Stopping logcat");
      DebugBridge.get().stopLogListener();

      // store logs
      Device.storeLogs();
    } catch (Exception e) {

    } finally {
      DebugBridge.get().close();
    }
  }
예제 #3
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();
    }
  }
예제 #4
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();
  }