Update a couple of blobstore params to be configurable.
Instead of hardcoding values for IDLE_JOB_PERIOD_MS and
SESSION_EXPIRY_TIMEOUT_MS, make them configurable.
Bug: 157503601
Test: atest --test-mapping apex/blobstore
Change-Id: I4846a98144224873444d4d73b2bedde258992ac4
diff --git a/tests/BlobStoreTestUtils/Android.bp b/tests/BlobStoreTestUtils/Android.bp
index 829c883..5c7c68b 100644
--- a/tests/BlobStoreTestUtils/Android.bp
+++ b/tests/BlobStoreTestUtils/Android.bp
@@ -15,6 +15,9 @@
java_library {
name: "BlobStoreTestUtils",
srcs: ["src/**/*.java"],
- static_libs: ["truth-prebuilt"],
+ static_libs: [
+ "truth-prebuilt",
+ "androidx.test.uiautomator_uiautomator",
+ ],
sdk_version: "test_current",
}
\ No newline at end of file
diff --git a/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java b/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java
index 6927e86..7cf58e1 100644
--- a/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java
+++ b/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java
@@ -18,12 +18,16 @@
import static com.google.common.truth.Truth.assertThat;
+import android.app.Instrumentation;
import android.app.blob.BlobHandle;
import android.app.blob.BlobStoreManager;
import android.app.blob.LeaseInfo;
import android.content.Context;
import android.content.res.Resources;
import android.os.ParcelFileDescriptor;
+import android.util.Log;
+
+import androidx.test.uiautomator.UiDevice;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -32,6 +36,8 @@
import java.io.OutputStream;
public class Utils {
+ public static final String TAG = "BlobStoreTest";
+
public static final int BUFFER_SIZE_BYTES = 16 * 1024;
public static final long KB_IN_BYTES = 1000;
@@ -68,7 +74,8 @@
public static void assertLeasedBlobs(BlobStoreManager blobStoreManager,
BlobHandle... expectedBlobHandles) throws IOException {
- assertThat(blobStoreManager.getLeasedBlobs()).containsExactly(expectedBlobHandles);
+ assertThat(blobStoreManager.getLeasedBlobs()).containsExactly(
+ (Object[]) expectedBlobHandles);
}
public static void assertNoLeasedBlobs(BlobStoreManager blobStoreManager)
@@ -141,4 +148,16 @@
assertThat(leaseInfo.getDescriptionResId()).isEqualTo(descriptionResId);
assertThat(leaseInfo.getDescription()).isEqualTo(description);
}
+
+ public static void triggerIdleMaintenance(Instrumentation instrumentation) throws IOException {
+ runShellCmd(instrumentation, "cmd blob_store idle-maintenance");
+ }
+
+ private static String runShellCmd(Instrumentation instrumentation,
+ String cmd) throws IOException {
+ final UiDevice uiDevice = UiDevice.getInstance(instrumentation);
+ final String result = uiDevice.executeShellCommand(cmd);
+ Log.i(TAG, "Output of '" + cmd + "': '" + result + "'");
+ return result;
+ }
}