Migrate settings robolectric tests to mockito 2

- Migrated ArgumentMatcher subclasses to lambdas
- Replaced any() with nullable() where tests were failing

Test: cd tests/robotests && mma
Bug: 38456058
Change-Id: Ice8c39b435c45b87f82dbbd9860e68f235314cf8
This commit is contained in:
Maurice Lam
2017-05-23 19:51:36 -07:00
parent be39d57762
commit 046400c2c4
38 changed files with 426 additions and 481 deletions

View File

@@ -16,8 +16,14 @@
package com.android.settings.notification;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.preference.SeekBarVolumizer;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
@@ -31,13 +37,6 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class VolumeSeekBarPreferenceControllerTest {
@@ -56,7 +55,7 @@ public class VolumeSeekBarPreferenceControllerTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
when(mScreen.findPreference(nullable(String.class))).thenReturn(mPreference);
mController =
new VolumeSeekBarPreferenceControllerTestable(mContext, mCallback);
}