Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static androidx.test.espresso.intent.Intents.intending;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
Expand All @@ -28,6 +29,7 @@
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasExtra;
import static org.hamcrest.Matchers.allOf;
import androidx.test.espresso.intent.Intents;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;

Expand Down Expand Up @@ -389,6 +391,26 @@ public void thelogButtonIsNotOfferedBeforeAnythingHasFailed() {
onView(withId(R.id.login_error_export_logs)).check(matches(not(isDisplayed())));
}

/**
* <b>The empty error box takes no room.</b>
*
* <p>It started as {@code invisible}, which hides a view but keeps its height, so before any
* failure there was a blank band between the title and the fields - one that grew when the
* Export logs button went inside the box, which is when somebody noticed. Asserted as
* {@code GONE} specifically, because {@code not(isDisplayed())} is equally true of an
* invisible view and would have passed against the gap.
*/
@Test
public void theemptyErrorBoxTakesNoRoomBeforeAnythingHasFailed() {
this.apple = FakeAppleAuthService.rejectsTheSignIn("Bad password");
AppDependencies.replaceAuthService(this.apple);

launch();

onView(withId(R.id.login_error_container))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
}

/** A rejected code says so, and gives the boxes back rather than stranding them. */
@Test
public void aWrongCodeIsReportedAndTheBoxesComeBack() {
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/res/layout/activity_apple_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,22 @@
android:visibility="gone"
tools:visibility="gone">

<!--
**`gone` until something fails, never `invisible`.** An invisible view still
takes its full height, so the empty box sat between the title and the fields
as a blank band - and grew when the Export logs button went inside it. The code
only ever sets VISIBLE on a failure and GONE on success, so gone is also the
state it was always meant to start in.
-->
<FrameLayout
android:id="@+id/login_error_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/layout_rounded_less"
android:backgroundTint="?attr/colorErrorContainer"
android:visibility="invisible"
android:visibility="gone"
tools:visibility="visible">

<LinearLayout
Expand Down
Loading