Switch to inline mockito for a bunch of tests
So we can mock final stuff
Test: The tests
Change-Id: Ia3a47c6655c4b0b9af0aea0ee6f8f6cb9ebaab09
diff --git a/packages/SystemUI/tests/Android.mk b/packages/SystemUI/tests/Android.mk
index 59a7da6..552784a 100644
--- a/packages/SystemUI/tests/Android.mk
+++ b/packages/SystemUI/tests/Android.mk
@@ -56,12 +56,19 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
metrics-helper-lib \
android-support-test \
- mockito-target-minus-junit4 \
+ mockito-target-inline-minus-junit4 \
SystemUI-proto \
SystemUI-tags \
testables \
truth-prebuilt \
+LOCAL_MULTILIB := both
+
+LOCAL_JNI_SHARED_LIBRARIES := \
+ libdexmakerjvmtiagent \
+ libmultiplejvmtiagentsinterferenceagent
+
+
LOCAL_JAVA_LIBRARIES := \
android.test.runner \
telephony-common \
diff --git a/packages/SystemUI/tests/AndroidManifest.xml b/packages/SystemUI/tests/AndroidManifest.xml
index f5e079c..767a24a 100644
--- a/packages/SystemUI/tests/AndroidManifest.xml
+++ b/packages/SystemUI/tests/AndroidManifest.xml
@@ -48,8 +48,9 @@
<uses-permission android:name="android.permission.REAL_GET_TASKS" />
<uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" />
<uses-permission android:name="android.permission.NETWORK_SETTINGS" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <application>
+ <application android:debuggable="true">
<uses-library android:name="android.test.runner" />
<activity android:name="com.android.systemui.screenshot.ScreenshotStubActivity" />
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/SlashImageViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/SlashImageViewTest.java
index 98ca1b4..e2159d2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/SlashImageViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/SlashImageViewTest.java
@@ -27,8 +27,14 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
@SmallTest
@@ -80,13 +86,12 @@
public void testSetImageDrawableUsesDrawableLevel() {
SlashImageView iv = new SlashImageView(mContext);
Drawable mockDrawable = mock(Drawable.class);
- mockDrawable.setLevel(2);
- assertTrue(mockDrawable.getLevel() == 2);
+ when(mockDrawable.getLevel()).thenReturn(2);
iv.setImageDrawable(mockDrawable);
// Make sure setting the drawable didn't reset its level to 0
- assertTrue(mockDrawable.getLevel() == 2);
+ verify(mockDrawable).setLevel(eq(2));
}
// Expose getSlashDrawable
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java
index 4cc83f6..17df800 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java
@@ -27,6 +27,7 @@
import com.android.systemui.Dependency;
+import com.android.systemui.OverviewProxyService;
import com.android.systemui.SysuiBaseFragmentTest;
import com.android.systemui.recents.Recents;
import com.android.systemui.stackdivider.Divider;
@@ -61,6 +62,7 @@
mSysuiContext.putComponent(Recents.class, mock(Recents.class));
mSysuiContext.putComponent(Divider.class, mock(Divider.class));
injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES);
+ mDependency.injectMockDependency(OverviewProxyService.class);
WindowManager windowManager = mock(WindowManager.class);
Display defaultDisplay = mContext.getSystemService(WindowManager.class).getDefaultDisplay();
when(windowManager.getDefaultDisplay()).thenReturn(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/tuner/TunablePaddingTest.java b/packages/SystemUI/tests/src/com/android/systemui/tuner/TunablePaddingTest.java
index 9fd8cc3..3bfefe7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/tuner/TunablePaddingTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/tuner/TunablePaddingTest.java
@@ -45,7 +45,8 @@
@Before
public void setup() {
injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES);
- mView = mock(View.class, withSettings().spiedInstance(new View(mContext)));
+ mView = mock(View.class);
+ when(mView.getContext()).thenReturn(mContext);
mTunerService = mDependency.injectMockDependency(TunerService.class);
Tracker tracker = mLeakCheck.getTracker("tuner");