diff options
author | Sudheer Shanka <sudheersai@google.com> | 2020-05-25 15:40:21 -0700 |
---|---|---|
committer | Sudheer Shanka <sudheersai@google.com> | 2020-05-26 15:02:00 -0700 |
commit | 90ac4a69db4abb18cb8957578cb053b2ee143ca8 (patch) | |
tree | 7c7c54e2c262fc4a4f67ede9b3e7bb9eb27f75c5 /tests/BlobStoreTestUtils | |
parent | d8d0efefe78497d5655f2c4969964c92e289a00b (diff) |
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
Diffstat (limited to 'tests/BlobStoreTestUtils')
-rw-r--r-- | tests/BlobStoreTestUtils/Android.bp | 5 | ||||
-rw-r--r-- | tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java | 21 |
2 files changed, 24 insertions, 2 deletions
diff --git a/tests/BlobStoreTestUtils/Android.bp b/tests/BlobStoreTestUtils/Android.bp index 829c883913e1..5c7c68b57ba1 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 6927e86213d8..7cf58e1682bf 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 @@ package com.android.utils.blob; 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.InputStream; 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 class Utils { 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 @@ public class Utils { 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; + } } |