Test: - adb shell am instrument -w -e class com.android.mediaframeworktest.unit.MediaInserterTest com.android.mediaframeworktest/android.support.test.runner.AndroidJUnitRunner
- atest com.android.settingslib.users.AppRestrictionsHelperTest
- atest com.android.server.NetworkScorerAppManagerTest com.android.server.accessibility.MotionEventInjectorTest com.android.server.webkit.WebViewUpdateServiceTest
Change-Id: I6d4c543541d3bebcd65e5aa9e3f4d9a0152d5583
package com.android.mediaframeworktest.integration;
+import static android.hardware.camera2.CameraDevice.TEMPLATE_PREVIEW;
+
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyLong;
+import static org.mockito.Mockito.argThat;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.verify;
+
import android.graphics.ImageFormat;
import android.graphics.SurfaceTexture;
import android.hardware.ICameraService;
-import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CaptureRequest;
import android.util.Log;
import android.view.Surface;
-import static android.hardware.camera2.CameraDevice.TEMPLATE_PREVIEW;
-
import com.android.mediaframeworktest.MediaFrameworkIntegrationTestRunner;
import org.mockito.ArgumentCaptor;
-import org.mockito.compat.ArgumentMatcher;
-import static org.mockito.Mockito.*;
+import org.mockito.ArgumentMatcher;
public class CameraDeviceBinderTest extends AndroidTestCase {
private static String TAG = "CameraDeviceBinderTest";
}
}
- class IsMetadataNotEmpty extends ArgumentMatcher<CameraMetadataNative> {
+ class IsMetadataNotEmpty implements ArgumentMatcher<CameraMetadataNative> {
@Override
- public boolean matchesObject(Object obj) {
- return !((CameraMetadataNative) obj).isEmpty();
+ public boolean matches(CameraMetadataNative obj) {
+ return !obj.isEmpty();
}
}
package com.android.mediaframeworktest.unit;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
import android.content.ContentProviderClient;
import android.content.ContentValues;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
-import org.hamcrest.Description;
+import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.mockito.compat.ArgumentMatcher;
public class MediaInserterTest extends InstrumentationTestCase {
private static final Uri sImagesUri = Images.Media.getContentUri(sVolumeName);
private static final Uri sFilesUri = Files.getContentUri(sVolumeName);
- private static class MediaUriMatcher extends ArgumentMatcher<Uri> {
+ private static class MediaUriMatcher implements ArgumentMatcher<Uri> {
private final Uri mUri;
private MediaUriMatcher(Uri uri) {
}
@Override
- public boolean matchesObject(Object argument) {
- if (!(argument instanceof Uri)) {
- return false;
- }
-
- Uri actualUri = (Uri) argument;
- if (actualUri == mUri)
- return true;
- return false;
+ public boolean matches(Uri actualUri) {
+ return actualUri == mUri;
}
@Override
import android.view.inputmethod.InputMethodInfo;
import com.android.settingslib.BaseTest;
+import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.mockito.compat.ArgumentMatcher;
import java.util.ArrayList;
import java.util.List;
return ri;
}
- private class IntentMatcher extends ArgumentMatcher<Intent> {
+ private class IntentMatcher implements ArgumentMatcher<Intent> {
private final Intent mIntent;
IntentMatcher(Intent intent) {
}
@Override
- public boolean matchesObject(Object argument) {
- if (argument instanceof Intent) {
- return ((Intent) argument).filterEquals(mIntent);
- }
- return false;
+ public boolean matches(Intent argument) {
+ return argument != null && argument.filterEquals(mIntent);
}
@Override
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.mockito.compat.ArgumentMatcher;
import java.util.ArrayList;
import java.util.List;
MockitoAnnotations.initMocks(this);
mAvailableServices = new ArrayList<>();
when(mMockContext.getPackageManager()).thenReturn(mMockPm);
- when(mMockPm.queryIntentServices(Mockito.argThat(new ArgumentMatcher<Intent>() {
- @Override
- public boolean matchesObject(Object object) {
- Intent intent = (Intent) object;
- return NetworkScoreManager.ACTION_RECOMMEND_NETWORKS.equals(intent.getAction());
- }
- }), eq(PackageManager.GET_META_DATA))).thenReturn(mAvailableServices);
+ when(mMockPm.queryIntentServices(Mockito.argThat(
+ intent -> NetworkScoreManager.ACTION_RECOMMEND_NETWORKS.equals(intent.getAction())),
+ eq(PackageManager.GET_META_DATA))).thenReturn(mAvailableServices);
when(mMockContext.getResources()).thenReturn(mResources);
when(mMockContext.getSystemService(Context.APP_OPS_SERVICE)).thenReturn(mAppOpsManager);
final int flags = PackageManager.GET_META_DATA;
when(mMockPm.resolveService(
- Mockito.argThat(new ArgumentMatcher<Intent>() {
- @Override
- public boolean matchesObject(Object object) {
- Intent intent = (Intent) object;
- return NetworkScoreManager.ACTION_RECOMMEND_NETWORKS
- .equals(intent.getAction())
- && compName.getPackageName().equals(intent.getPackage());
- }
- }), Mockito.eq(flags))).thenReturn(serviceInfo);
+ Mockito.argThat(intent -> NetworkScoreManager.ACTION_RECOMMEND_NETWORKS
+ .equals(intent.getAction())
+ && compName.getPackageName().equals(intent.getPackage())),
+ Mockito.eq(flags))).thenReturn(serviceInfo);
mAvailableServices.add(serviceInfo);
}
final int flags = 0;
when(mMockPm.resolveActivity(
- Mockito.argThat(new ArgumentMatcher<Intent>() {
- @Override
- public boolean matchesObject(Object object) {
- Intent intent = (Intent) object;
- return NetworkScoreManager.ACTION_CUSTOM_ENABLE.equals(intent.getAction())
- && useOpenWifiComp.getPackageName().equals(intent.getPackage());
- }
- }), Mockito.eq(flags))).thenReturn(resolveActivityInfo);
+ Mockito.argThat(intent ->
+ NetworkScoreManager.ACTION_CUSTOM_ENABLE.equals(intent.getAction())
+ && useOpenWifiComp.getPackageName().equals(intent.getPackage())),
+ Mockito.eq(flags))).thenReturn(resolveActivityInfo);
}
}
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
-import org.mockito.compat.ArgumentMatcher;
/**
* Tests for MotionEventInjector
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatcher;
import org.mockito.Mockito;
import org.mockito.Matchers;
-import org.mockito.compat.ArgumentMatcher;
import java.lang.Integer;
import java.util.concurrent.CountDownLatch;
}
// For matching the package name of a PackageInfo
- private class IsPackageInfoWithName extends ArgumentMatcher<PackageInfo> {
+ private class IsPackageInfoWithName implements ArgumentMatcher<PackageInfo> {
private final String mPackageName;
IsPackageInfoWithName(String name) {
}
@Override
- public boolean matchesObject(Object p) {
- return ((PackageInfo) p).packageName.equals(mPackageName);
+ public boolean matches(PackageInfo p) {
+ return p.packageName.equals(mPackageName);
}
@Override