Skip to content

Commit

Permalink
[AW][Dev-UI] UI Espresso tests for hide crash button
Browse files Browse the repository at this point in the history
1. add checks for hide crash button to be displayed in every
showingCrashTest
2. testHideCrashButton: checks if hide crash button removes the crash
from the view

Bug: 1059944
Test: run_webview_instrumentation_test_apk -f *CrashesListFragmentTest*
Change-Id: Iec4d623802468d4d7269384e0ad722a224b1b8e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2405573
Reviewed-by: Hazem Ashmawy <hazems@chromium.org>
Commit-Queue: Azhara Assanova <azharaa@google.com>
Auto-Submit: Azhara Assanova <azharaa@google.com>
Cr-Commit-Position: refs/heads/master@{#806679}
  • Loading branch information
Azhara Assanova authored and Commit Bot committed Sep 14, 2020
1 parent 1162b1a commit e354374
Showing 1 changed file with 90 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ public void testShowingSingleCrashReport_uploaded() throws Throwable {
.check(matches(withText(CRASH_REPORT_BUTTON_TEXT)));
bodyDataInteraction.onChildView(withId(R.id.crash_upload_button))
.check(matches(not(isDisplayed())));
bodyDataInteraction.onChildView(withId(R.id.crash_hide_button))
.check(matches(isDisplayed()))
.check(matches(isEnabled()))
.check(matches(withDrawable(R.drawable.ic_delete)));
}

@Test
Expand Down Expand Up @@ -336,6 +340,10 @@ public void testShowingSingleCrashReport_pending() throws Throwable {
.check(matches(isDisplayed()))
.check(matches(withText(CRASH_UPLOAD_BUTTON_TEXT)))
.check(matches(isEnabled()));
bodyDataInteraction.onChildView(withId(R.id.crash_hide_button))
.check(matches(isDisplayed()))
.check(matches(isEnabled()))
.check(matches(withDrawable(R.drawable.ic_delete)));
}

@Test
Expand Down Expand Up @@ -370,6 +378,10 @@ public void testShowingSingleCrashReport_pendingUserRequest() throws Throwable {
.perform(click());
bodyDataInteraction.onChildView(withId(R.id.crash_upload_button))
.check(matches(not(isDisplayed())));
bodyDataInteraction.onChildView(withId(R.id.crash_hide_button))
.check(matches(isDisplayed()))
.check(matches(isEnabled()))
.check(matches(withDrawable(R.drawable.ic_delete)));
}

@Test
Expand Down Expand Up @@ -405,6 +417,10 @@ public void testShowingSingleCrashReport_skipped() throws Throwable {
.check(matches(isDisplayed()))
.check(matches(withText(CRASH_UPLOAD_BUTTON_TEXT)))
.check(matches(isEnabled()));
bodyDataInteraction.onChildView(withId(R.id.crash_hide_button))
.check(matches(isDisplayed()))
.check(matches(isEnabled()))
.check(matches(withDrawable(R.drawable.ic_delete)));
}

@Test
Expand Down Expand Up @@ -503,4 +519,78 @@ public void testMaxNumberOfCrashes() throws Throwable {
onData(anything()).atPosition(i), crashInfo[crashReportsNum - i - 1]);
}
}

@Test
@Feature({"AndroidWebView"})
public void testHideCrashButton_uploaded() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo("123456", systemTime, "0abcde123456",
systemTime + 1000, FAKE_APP_PACKAGE_NAME, UploadState.UPLOADED);

assertThat("temp json log file should exist", writeJsonLogFile(crashInfo).exists());
assertThat("upload log file should exist", appendUploadedEntryToLog(crashInfo).exists());

CallbackHelper helper = getCrashListLoadedListener();
int crashListLoadInitCount = helper.getCallCount();
launchCrashesFragment();
helper.waitForCallback(crashListLoadInitCount, 1);

onView(withId(R.id.crashes_list)).check(matches(withCount(1)));

// Check crash item header
checkUnknownPackageCrashItemHeader(onData(anything()).atPosition(0), crashInfo)
.perform(click()); // click to expand it
// The body is considered item#2 in the list view after expansion
onView(withId(R.id.crashes_list)).check(matches(withCount(2)));
DataInteraction bodyDataInteraction = onData(anything()).atPosition(1);

crashListLoadInitCount = helper.getCallCount();

bodyDataInteraction.onChildView(withId(R.id.crash_hide_button))
.check(matches(isDisplayed()))
.check(matches(isEnabled()))
.check(matches(withDrawable(R.drawable.ic_delete)))
.perform(click());

helper.waitForCallback(crashListLoadInitCount, 1);

onView(withId(R.id.crashes_list)).check(matches(withCount(0)));
}

@Test
@Feature({"AndroidWebView"})
public void testHideCrashButton_pending() throws Throwable {
final long systemTime = System.currentTimeMillis();
CrashInfo crashInfo = createCrashInfo(
"123456", systemTime, null, -1, FAKE_APP_PACKAGE_NAME, UploadState.PENDING);

assertThat("temp minidump file should exist", createMinidumpFile(crashInfo).exists());
assertThat("temp json log file should exist", writeJsonLogFile(crashInfo).exists());

CallbackHelper helper = getCrashListLoadedListener();
int crashListLoadInitCount = helper.getCallCount();
launchCrashesFragment();
helper.waitForCallback(crashListLoadInitCount, 1);

onView(withId(R.id.crashes_list)).check(matches(withCount(1)));

// Check crash item header
checkUnknownPackageCrashItemHeader(onData(anything()).atPosition(0), crashInfo)
.perform(click()); // click to expand it
// The body is considered item#2 in the list view after expansion
onView(withId(R.id.crashes_list)).check(matches(withCount(2)));
DataInteraction bodyDataInteraction = onData(anything()).atPosition(1);

crashListLoadInitCount = helper.getCallCount();

bodyDataInteraction.onChildView(withId(R.id.crash_hide_button))
.check(matches(isDisplayed()))
.check(matches(isEnabled()))
.check(matches(withDrawable(R.drawable.ic_delete)))
.perform(click());

helper.waitForCallback(crashListLoadInitCount, 1);

onView(withId(R.id.crashes_list)).check(matches(withCount(0)));
}
}

0 comments on commit e354374

Please sign in to comment.