Improve suppressLayout test
Fix the issue that asserting in the suppressLayout method can crash an entire test instrumentation
run. This does not necessarily fix the test flakiness itself.
Bug: 147887771
Test: ./gradlew :transition:transition:connectedCheck
Change-Id: I1a201b0889b42706f7f99b212cd2c43453052b6a
diff --git a/transition/transition/src/androidTest/java/androidx/transition/ChangeBoundsTest.java b/transition/transition/src/androidTest/java/androidx/transition/ChangeBoundsTest.java
index 8aba64f..7e7f751 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/ChangeBoundsTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/ChangeBoundsTest.java
@@ -19,7 +19,6 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import android.content.Context;
@@ -116,7 +115,8 @@
private class TestSuppressLayout extends FrameLayout {
- private Boolean mExpectedSuppressLayout;
+ private boolean mExpectedSuppressLayout;
+ private Boolean mActualSuppressLayout;
private TestSuppressLayout(@NonNull Context context) {
super(context);
@@ -127,14 +127,14 @@
}
void ensureExpectedValueApplied() {
- assertNull(mExpectedSuppressLayout);
+ assertNotNull(mActualSuppressLayout);
+ assertEquals(mExpectedSuppressLayout, mActualSuppressLayout);
+ mActualSuppressLayout = null;
}
// Called via reflection
public void suppressLayout(boolean suppress) {
- assertNotNull(mExpectedSuppressLayout);
- assertEquals(mExpectedSuppressLayout, suppress);
- mExpectedSuppressLayout = null;
+ mActualSuppressLayout = suppress;
}
}