Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.java

Issue 2534333002: Show 'Send Feedback' button on the sad tab page on multiple failures (Closed)
Patch Set: Updated based on twellington's comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.java
index 98802ab6ba6c7876d178e6c44e1fa263e550e7df..346e16b0990c6d3a101108840fa6de11c2589247 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.java
@@ -5,10 +5,12 @@
package org.chromium.chrome.browser.tab;
import android.test.suitebuilder.annotation.SmallTest;
+import android.widget.Button;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure;
+import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.test.ChromeActivityTestCaseBase;
@@ -67,4 +69,89 @@ public class SadTabTest extends ChromeActivityTestCaseBase<ChromeActivity> {
assertFalse(tab.isShowingSadTab());
}
+
+ /**
+ * Confirm that after a successive refresh of a failed tab we change the button from "Reload"
+ * to "Send Feedback".
+ */
+ @SmallTest
+ @Feature({"SadTab"})
+ public void testChangeSadButtonToFeedbackAfterFailedRefresh() {
+ final Tab tab = getActivity().getActivityTab();
+
+ assertFalse(tab.isShowingSadTab());
+ simulateRendererKilled(tab, true);
+ assertTrue(tab.isShowingSadTab());
+ String actualText = getSadTabButton(tab).getText().toString();
+ assertEquals("Expected the sad tab button to have the reload label",
+ getActivity().getString(R.string.sad_tab_reload_label), actualText);
+
+ reloadSadTab(tab);
+ assertTrue(tab.isShowingSadTab());
+ actualText = getSadTabButton(tab).getText().toString();
+ assertEquals(getActivity().getString(R.string.sad_tab_send_feedback_label), actualText);
+ }
+
+ /**
+ * Confirm after two failures, if we refresh a third time and it's
+ * successful, and then we crash again, we do not show the "Send Feedback"
+ * button and instead show the "Reload" tab
+ */
+ @SmallTest
+ @Feature({"SadTab"})
+ public void testSadButtonRevertsBackToReloadAfterSuccessfulLoad() {
+ final Tab tab = getActivity().getActivityTab();
+
+ simulateRendererKilled(tab, true);
+ reloadSadTab(tab);
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ tab.reload(); // Erases the sad tab page
+ tab.didFinishPageLoad(); // Resets the tab counter to 0
+ }
+ });
+ // Putting it in the same UI thread causes it to fail. Likely due to
+ // race conditions.
+ simulateRendererKilled(tab, true);
+ String actualText = getSadTabButton(tab).getText().toString();
+ assertEquals(getActivity().getString(R.string.sad_tab_reload_label), actualText);
+ }
+
+ /**
+ * Helper method that kills the renderer on a UI thread.
+ */
+ private void simulateRendererKilled(final Tab tab, final boolean wasOomProtected) {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+
+ @Override
+ public void run() {
+ tab.simulateRendererKilledForTesting(wasOomProtected);
+ }
+ });
+ }
+
+ /**
+ * Helper method that reloads a tab with a SadTabView currently displayed
+ */
+ private void reloadSadTab(final Tab tab) {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ tab.reloadSadTabForTesting();
+ }
+ });
+ }
+
+ /**
+ * If there is a SadTabView, this method will get the button for the sad tab
+ * @param tab The tab that needs to contain a SadTabView
+ * @return Returns the button that is on the SadTabView, null if SadTabView
+ * doesn't exist.
+ */
+ private Button getSadTabButton(Tab tab) {
+ return (Button) tab.getContentViewCore().getContainerView()
+ .findViewById(R.id.sad_tab_reload_button);
+ }
+
}

Powered by Google App Engine
This is Rietveld 408576698