Skip to content

Commit

Permalink
Stop running Robolectric tests on APIs < 19.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 549688177
  • Loading branch information
Material Design Team authored and pekingme committed Jul 20, 2023
1 parent db9a641 commit 0a6a8a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import android.app.Activity;
Expand Down Expand Up @@ -88,27 +87,8 @@ public void hugeRevealInfoRadiusIsModified() {
}

@Test
@Config(sdk = VERSION_CODES.JELLY_BEAN)
public void jbUsesBitmapShaderStrategy() {
helper = new CircularRevealHelper(delegate);
helper.setRevealInfo(smallRevealInfo);

helper.buildCircularRevealCache();
helper.draw(canvas);
helper.destroyCircularRevealCache();

verify(canvas)
.drawCircle(
eq(smallRevealInfo.centerX),
eq(smallRevealInfo.centerY),
eq(smallRevealInfo.radius),
ArgumentMatchers.<Paint>any());
verify(canvas, never()).clipPath(ArgumentMatchers.<Path>any());
}

@Test
@Config(sdk = VERSION_CODES.JELLY_BEAN_MR2)
public void jbMr2UsesClipPathStrategy() {
@Config(sdk = 19)
public void oldSdkUsesClipPathStrategy() {
helper = new CircularRevealHelper(delegate);
helper.setRevealInfo(smallRevealInfo);

Expand All @@ -133,29 +113,8 @@ public void lUsesRevealAnimatorStrategy() {
}

@Test
@Config(sdk = VERSION_CODES.JELLY_BEAN)
public void jbDrawsScrim() {
helper = new CircularRevealHelper(delegate);
helper.setCircularRevealScrimColor(Color.RED);

helper.setRevealInfo(smallRevealInfo);

helper.buildCircularRevealCache();
helper.draw(canvas);
helper.destroyCircularRevealCache();

// Once for the BitmapShader, once for the scrim.
verify(canvas, times(2))
.drawCircle(
eq(smallRevealInfo.centerX),
eq(smallRevealInfo.centerY),
eq(smallRevealInfo.radius),
ArgumentMatchers.<Paint>any());
}

@Test
@Config(sdk = VERSION_CODES.JELLY_BEAN_MR2)
public void jbMr2DrawsScrim() {
@Config(sdk = 19)
public void oldSdkDrawsScrim() {
helper = new CircularRevealHelper(delegate);
helper.setCircularRevealScrimColor(Color.RED);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

import com.google.android.material.test.R;

import static android.os.Looper.getMainLooper;
import static com.google.android.material.slider.SliderHelper.touchSliderAtValue;
import static com.google.common.truth.Truth.assertThat;
import static org.robolectric.annotation.LooperMode.Mode.LEGACY;
import static org.robolectric.Shadows.shadowOf;

import androidx.appcompat.app.AppCompatActivity;
import android.view.MotionEvent;
Expand All @@ -30,10 +31,8 @@
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.LooperMode;

/** Tests for floating point rounding error handling of {@link Slider} */
@LooperMode(LEGACY)
@RunWith(RobolectricTestRunner.class)
public class SliderRoundingErrorTest {

Expand All @@ -58,8 +57,10 @@ public void createSlider() {
@Test
public void testKnownValues_snapTouchToValue_NoRoundingError() {
touchSliderAtValue(slider, 0f, MotionEvent.ACTION_DOWN);
shadowOf(getMainLooper()).idle();
for (float i = 100f; i < 10000f; i += 100) {
touchSliderAtValue(slider, i, MotionEvent.ACTION_MOVE);
shadowOf(getMainLooper()).idle();
assertThat(slider.getValue()).isEqualTo(i);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.android.material.test.R;

import static android.os.Build.VERSION_CODES.JELLY_BEAN;
import static com.google.common.truth.Truth.assertThat;

import android.content.Context;
Expand All @@ -33,16 +32,14 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode;
import org.robolectric.annotation.internal.DoNotInstrument;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowAccessibilityManager;

@LooperMode(LooperMode.Mode.LEGACY)
/** Tests for {@link com.google.android.material.snackbar.Snackbar}. */
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@Config(sdk = JELLY_BEAN)
@Config(sdk = Config.OLDEST_SDK)
public class SnackbarTest {

private Snackbar snackbar;
Expand Down

0 comments on commit 0a6a8a9

Please sign in to comment.