Esempio n. 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();
  }
Esempio n. 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();
    }
  }
Esempio n. 3
0
 public static void onFailure() throws Exception {
   logger.warn("TestBase::OnFailure:: Taking screenshot");
   DebugBridge.get().getScreenShot("FAILURE.png");
   Device.storeFailurePng();
 }