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

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: Fixed code based off of 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..37b4647c86a1a7b41bd6a9effb9640b97d83e5ab 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;
@@ -36,14 +38,7 @@ public class SadTabTest extends ChromeActivityTestCaseBase<ChromeActivity> {
final Tab tab = getActivity().getActivityTab();
assertFalse(tab.isShowingSadTab());
-
- ThreadUtils.runOnUiThreadBlocking(new Runnable() {
- @Override
- public void run() {
- tab.simulateRendererKilledForTesting(true);
- }
- });
-
+ simulateRendererKilled(tab, true);
assertTrue(tab.isShowingSadTab());
}
@@ -57,14 +52,91 @@ public class SadTabTest extends ChromeActivityTestCaseBase<ChromeActivity> {
final Tab tab = getActivity().getActivityTab();
assertFalse(tab.isShowingSadTab());
+ simulateRendererKilled(tab, false);
+ assertFalse(tab.isShowingSadTab());
+ }
+
+ /**
+ * Confirm that after a successive refresh of a failed tab that failed to load, 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(
+ "Expected the sad tab button to have the feedback label after the tab button "
+ + "crashes twice in a row.",
+ 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.simulateRendererKilledForTesting(false);
+ tab.reload(); // Erases the sad tab page
+ tab.didFinishPageLoad(); // Resets the tab counter to 0
}
});
+ simulateRendererKilled(tab, true);
+ String actualText = getSadTabButton(tab).getText().toString();
+ assertEquals(getActivity().getString(R.string.sad_tab_reload_label), actualText);
+ }
- assertFalse(tab.isShowingSadTab());
+ /**
+ * 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);
+ }
+
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java ('k') | components/new_or_sad_tab_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698