[Test Week] Add ViewPoolTest

Number of new tested methods: 3

Bug: 353303621
Test: This is the unit test
Flag: NONE - unit test
Change-Id: I13f1a7bad41c07368cff3d544120d1f41c92b603
This commit is contained in:
Fengjiang Li
2024-07-18 14:54:10 -07:00
parent 300ca3422f
commit 5ad7a20e90
2 changed files with 103 additions and 1 deletions
+9 -1
View File
@@ -24,6 +24,7 @@ import android.view.ViewGroup;
import androidx.annotation.AnyThread;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.util.ViewPool.Reusable;
@@ -43,9 +44,16 @@ public class ViewPool<T extends View & Reusable> {
public ViewPool(Context context, @Nullable ViewGroup parent,
int layoutId, int maxSize, int initialSize) {
this(LayoutInflater.from(context).cloneInContext(context),
parent, layoutId, maxSize, initialSize);
}
@VisibleForTesting
ViewPool(LayoutInflater inflater, @Nullable ViewGroup parent,
int layoutId, int maxSize, int initialSize) {
mLayoutId = layoutId;
mParent = parent;
mInflater = LayoutInflater.from(context);
mInflater = inflater;
mPool = new Object[maxSize];
if (initialSize > 0) {