Migrate Sonar Android tests (#1045)
Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/1045 Reviewed By: passy Differential Revision: D21181354 fbshipit-source-id: ddc329f8bafd5890b7428642d32f7f62e1d499ad
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b605f1140c
commit
e6b7c9a346
@@ -9,6 +9,7 @@ package com.facebook.flipper.plugins.inspector;
|
|||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
@@ -40,7 +41,7 @@ public class ApplicationWrapperTest {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.when(app)
|
.when(app)
|
||||||
.registerActivityLifecycleCallbacks(Mockito.any(ActivityLifecycleCallbacks.class));
|
.registerActivityLifecycleCallbacks(any(ActivityLifecycleCallbacks.class));
|
||||||
|
|
||||||
mWrapper = new ApplicationWrapper(app);
|
mWrapper = new ApplicationWrapper(app);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import static com.facebook.flipper.plugins.inspector.ThrowableMessageMatcher.has
|
|||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.CoreMatchers.hasItem;
|
import static org.hamcrest.CoreMatchers.hasItem;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
@@ -288,12 +289,12 @@ public class InspectorFlipperPluginTest {
|
|||||||
plugin.mSetSearchActive.onReceive(
|
plugin.mSetSearchActive.onReceive(
|
||||||
new FlipperObject.Builder().put("active", true).build(), responder);
|
new FlipperObject.Builder().put("active", true).build(), responder);
|
||||||
|
|
||||||
Mockito.verify(decorView, Mockito.times(1)).addView(Mockito.any(TouchOverlayView.class));
|
Mockito.verify(decorView, Mockito.times(1)).addView(any(TouchOverlayView.class));
|
||||||
|
|
||||||
plugin.mSetSearchActive.onReceive(
|
plugin.mSetSearchActive.onReceive(
|
||||||
new FlipperObject.Builder().put("active", false).build(), responder);
|
new FlipperObject.Builder().put("active", false).build(), responder);
|
||||||
|
|
||||||
Mockito.verify(decorView, Mockito.times(1)).removeView(Mockito.any(TouchOverlayView.class));
|
Mockito.verify(decorView, Mockito.times(1)).removeView(any(TouchOverlayView.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package com.facebook.flipper.plugins.inspector.descriptors;
|
|||||||
|
|
||||||
import static android.view.View.MeasureSpec.EXACTLY;
|
import static android.view.View.MeasureSpec.EXACTLY;
|
||||||
import static android.view.View.MeasureSpec.makeMeasureSpec;
|
import static android.view.View.MeasureSpec.makeMeasureSpec;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -36,8 +36,7 @@ public class ViewGroupDescriptorTest {
|
|||||||
root.layout(0, 0, 100, 100);
|
root.layout(0, 0, 100, 100);
|
||||||
|
|
||||||
final Touch touch = Mockito.mock(Touch.class);
|
final Touch touch = Mockito.mock(Touch.class);
|
||||||
Mockito.when(touch.containedIn(any(int.class), any(int.class), any(int.class), any(int.class)))
|
Mockito.when(touch.containedIn(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(true);
|
||||||
.thenReturn(true);
|
|
||||||
descriptor.hitTest(root, touch);
|
descriptor.hitTest(root, touch);
|
||||||
Mockito.verify(touch, Mockito.times(1)).continueWithOffset(0, 0, 0);
|
Mockito.verify(touch, Mockito.times(1)).continueWithOffset(0, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -55,8 +54,7 @@ public class ViewGroupDescriptorTest {
|
|||||||
root.layout(0, 0, 100, 100);
|
root.layout(0, 0, 100, 100);
|
||||||
|
|
||||||
final Touch touch = Mockito.mock(Touch.class);
|
final Touch touch = Mockito.mock(Touch.class);
|
||||||
Mockito.when(touch.containedIn(any(int.class), any(int.class), any(int.class), any(int.class)))
|
Mockito.when(touch.containedIn(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(true);
|
||||||
.thenReturn(true);
|
|
||||||
descriptor.hitTest(root, touch);
|
descriptor.hitTest(root, touch);
|
||||||
Mockito.verify(touch, Mockito.times(1)).finish();
|
Mockito.verify(touch, Mockito.times(1)).finish();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ ext.deps = [
|
|||||||
lithoTesting : "com.facebook.litho:litho-testing:$LITHO_VERSION",
|
lithoTesting : "com.facebook.litho:litho-testing:$LITHO_VERSION",
|
||||||
// Debugging and testing
|
// Debugging and testing
|
||||||
guava : 'com.google.guava:guava:20.0',
|
guava : 'com.google.guava:guava:20.0',
|
||||||
robolectric : 'org.robolectric:robolectric:3.3',
|
robolectric : 'org.robolectric:robolectric:4.3.1',
|
||||||
junit : 'junit:junit:4.12',
|
junit : 'junit:junit:4.12',
|
||||||
hamcrest : 'org.hamcrest:hamcrest-library:1.3',
|
hamcrest : 'org.hamcrest:hamcrest-library:1.3',
|
||||||
mockito : 'org.mockito:mockito-core:1.9.5',
|
mockito : 'org.mockito:mockito-core:2.26.0',
|
||||||
okhttp3 : 'com.squareup.okhttp3:okhttp:3.14.1',
|
okhttp3 : 'com.squareup.okhttp3:okhttp:3.14.1',
|
||||||
leakcanary : 'com.squareup.leakcanary:leakcanary-android:1.6.3',
|
leakcanary : 'com.squareup.leakcanary:leakcanary-android:1.6.3',
|
||||||
testCore : 'androidx.test:core:1.1.0',
|
testCore : 'androidx.test:core:1.1.0',
|
||||||
|
|||||||
Reference in New Issue
Block a user