Example #1
0
 @Override
 protected void tearDown() throws Exception {
   // Delete the temp files
   for (File ref : mReferences.values()) {
     ref.delete();
   }
   mExecutionService.shutdown();
   // Remove the APK.
   mDevice.uninstallPackage(PACKAGE);
   super.tearDown();
 }
Example #2
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    // Get the device, this gives a handle to run commands and install APKs.
    mDevice = getDevice();
    // Remove any previously installed versions of this APK.
    mDevice.uninstallPackage(PACKAGE);
    // Get the APK from the build.
    File app = mBuild.getTestApp(APK);
    // Get the ABI flag.
    String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
    // Install the APK on the device.
    mDevice.installPackage(app, false, options);

    final String densityProp;

    if (mDevice.getSerialNumber().startsWith("emulator-")) {
      densityProp = DENSITY_PROP_EMULATOR;
    } else {
      densityProp = DENSITY_PROP_DEVICE;
    }

    final String zip =
        String.format(
            "/%s.zip", getDensityBucket(Integer.parseInt(mDevice.getProperty(densityProp))));
    Log.logAndDisplay(LogLevel.INFO, TAG, "Loading resources from " + zip);

    final InputStream zipStream = this.getClass().getResourceAsStream(zip);
    if (zipStream != null) {
      final ZipInputStream in = new ZipInputStream(zipStream);
      try {
        ZipEntry ze;
        final byte[] buffer = new byte[1024];
        while ((ze = in.getNextEntry()) != null) {
          final String name = ze.getName();
          final File tmp = File.createTempFile("ref_" + name, ".png");
          final FileOutputStream out = new FileOutputStream(tmp);
          int count;
          while ((count = in.read(buffer)) != -1) {
            out.write(buffer, 0, count);
          }
          out.flush();
          out.close();
          mReferences.put(name, tmp);
        }
      } finally {
        in.close();
      }
    }

    mExecutionService = Executors.newFixedThreadPool(2); // 2 worker threads
    mCompletionService = new ExecutorCompletionService<Boolean>(mExecutionService);
  }
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    // ensure apk path has been set before test is run
    assertNotNull("Missing --app-repository-path option", mAppRepositoryPath);

    // setup the PackageManager host tests utilities class, and get various paths we'll need...
    mPMHostUtils = new PackageManagerHostTestUtils(getDevice());
    mPMHostUtils.determinePrivateAppPath(getTestAppFilePath(INTERNAL_LOC_APK), INTERNAL_LOC_PKG);

    // Ensure the default is set to let the system decide where to install apps
    // (It's ok for individual tests to override and change this during their test, but should
    // reset it back when they're done)
    mPMHostUtils.setDevicePreferredInstallLocation(
        PackageManagerHostTestUtils.InstallLocPreference.AUTO);
  }
Example #4
0
 @Override
 protected void tearDown() throws Exception {
   mDevice.uninstallPackage(PACKAGE);
   super.tearDown();
 }
Example #5
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   mDevice = getDevice();
 }
Example #6
0
 @Override
 protected void tearDown() throws Exception {
   super.tearDown();
   mDevice.uninstallPackage(PACKAGE);
   mReport.throwReportToHost();
 }