summaryrefslogtreecommitdiff
path: root/tests/shared
diff options
context:
space:
mode:
author Govinda Wasserman <gwasserman@google.com> 2024-05-16 16:36:56 -0400
committer Govinda Wasserman <gwasserman@google.com> 2024-05-21 14:32:32 -0400
commit97492540d111a1164c74a306b4d98aea11e543f3 (patch)
tree78b7f40c89e8fb74f8edcc6488d68dffeaf1c304 /tests/shared
parent25c04565081fd8643e04f88e004fc09ac1c73ff3 (diff)
Add ImageLoader with improved caching and cancelling
BUG: 339261453 FIX: 339261453 Test: atest CachingImagePreviewImageLoaderTest Test: atest IntentResolver-tests-activity Test: manual test using ShareTest Change-Id: I316a9f683a26f2f6d8599e0da4a45ca3f4e740ab
Diffstat (limited to 'tests/shared')
-rw-r--r--tests/shared/src/com/android/intentresolver/contentpreview/FakeThumbnailLoader.kt36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/shared/src/com/android/intentresolver/contentpreview/FakeThumbnailLoader.kt b/tests/shared/src/com/android/intentresolver/contentpreview/FakeThumbnailLoader.kt
new file mode 100644
index 00000000..d3fdf17d
--- /dev/null
+++ b/tests/shared/src/com/android/intentresolver/contentpreview/FakeThumbnailLoader.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.intentresolver.contentpreview
+
+import android.graphics.Bitmap
+import android.net.Uri
+
+/** Fake implementation of [ThumbnailLoader] for use in testing. */
+class FakeThumbnailLoader : ThumbnailLoader {
+
+ val fakeInvoke = mutableMapOf<Uri, suspend () -> Bitmap?>()
+ val invokeCalls = mutableListOf<Uri>()
+ var unfinishedInvokeCount = 0
+
+ override suspend fun invoke(uri: Uri): Bitmap? {
+ invokeCalls.add(uri)
+ unfinishedInvokeCount++
+ val result = fakeInvoke[uri]?.invoke()
+ unfinishedInvokeCount--
+ return result
+ }
+}