| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.tab; | 5 package org.chromium.chrome.browser.tab; |
| 6 | 6 |
| 7 import android.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
| 8 import android.widget.Button; | 8 import android.widget.Button; |
| 9 | 9 |
| 10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
| 11 import org.chromium.base.test.util.DisabledTest; |
| 11 import org.chromium.base.test.util.Feature; | 12 import org.chromium.base.test.util.Feature; |
| 12 import org.chromium.base.test.util.RetryOnFailure; | 13 import org.chromium.base.test.util.RetryOnFailure; |
| 13 import org.chromium.chrome.R; | 14 import org.chromium.chrome.R; |
| 14 import org.chromium.chrome.browser.ChromeActivity; | 15 import org.chromium.chrome.browser.ChromeActivity; |
| 15 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 16 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * Tests related to the sad tab logic. | 19 * Tests related to the sad tab logic. |
| 19 */ | 20 */ |
| 20 @RetryOnFailure | 21 @RetryOnFailure |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 simulateRendererKilled(tab, false); | 56 simulateRendererKilled(tab, false); |
| 56 assertFalse(tab.isShowingSadTab()); | 57 assertFalse(tab.isShowingSadTab()); |
| 57 } | 58 } |
| 58 | 59 |
| 59 /** | 60 /** |
| 60 * Confirm that after a successive refresh of a failed tab that failed to lo
ad, change the | 61 * Confirm that after a successive refresh of a failed tab that failed to lo
ad, change the |
| 61 * button from "Reload" to "Send Feedback". | 62 * button from "Reload" to "Send Feedback". |
| 62 */ | 63 */ |
| 63 @SmallTest | 64 @SmallTest |
| 64 @Feature({"SadTab"}) | 65 @Feature({"SadTab"}) |
| 66 @DisabledTest(message = "crbug.com/670920") |
| 65 public void testChangeSadButtonToFeedbackAfterFailedRefresh() { | 67 public void testChangeSadButtonToFeedbackAfterFailedRefresh() { |
| 66 final Tab tab = getActivity().getActivityTab(); | 68 final Tab tab = getActivity().getActivityTab(); |
| 67 | 69 |
| 68 assertFalse(tab.isShowingSadTab()); | 70 assertFalse(tab.isShowingSadTab()); |
| 69 simulateRendererKilled(tab, true); | 71 simulateRendererKilled(tab, true); |
| 70 assertTrue(tab.isShowingSadTab()); | 72 assertTrue(tab.isShowingSadTab()); |
| 71 String actualText = getSadTabButton(tab).getText().toString(); | 73 String actualText = getSadTabButton(tab).getText().toString(); |
| 72 assertEquals("Expected the sad tab button to have the reload label", | 74 assertEquals("Expected the sad tab button to have the reload label", |
| 73 getActivity().getString(R.string.sad_tab_reload_label), actualTe
xt); | 75 getActivity().getString(R.string.sad_tab_reload_label), actualTe
xt); |
| 74 | 76 |
| 75 reloadSadTab(tab); | 77 reloadSadTab(tab); |
| 76 assertTrue(tab.isShowingSadTab()); | 78 assertTrue(tab.isShowingSadTab()); |
| 77 actualText = getSadTabButton(tab).getText().toString(); | 79 actualText = getSadTabButton(tab).getText().toString(); |
| 78 assertEquals( | 80 assertEquals( |
| 79 "Expected the sad tab button to have the feedback label after th
e tab button " | 81 "Expected the sad tab button to have the feedback label after th
e tab button " |
| 80 + "crashes twice in a row.", | 82 + "crashes twice in a row.", |
| 81 getActivity().getString(R.string.sad_tab_send_feedback_label), a
ctualText); | 83 getActivity().getString(R.string.sad_tab_send_feedback_label), a
ctualText); |
| 82 } | 84 } |
| 83 | 85 |
| 84 /** | 86 /** |
| 85 * Confirm after two failures, if we refresh a third time and it's successfu
l, and then we | 87 * Confirm after two failures, if we refresh a third time and it's successfu
l, and then we |
| 86 * crash again, we do not show the "Send Feedback" button and instead show t
he "Reload" tab. | 88 * crash again, we do not show the "Send Feedback" button and instead show t
he "Reload" tab. |
| 87 */ | 89 */ |
| 88 @SmallTest | 90 @SmallTest |
| 89 @Feature({"SadTab"}) | 91 @Feature({"SadTab"}) |
| 92 @DisabledTest(message = "crbug.com/670920") |
| 90 public void testSadButtonRevertsBackToReloadAfterSuccessfulLoad() { | 93 public void testSadButtonRevertsBackToReloadAfterSuccessfulLoad() { |
| 91 final Tab tab = getActivity().getActivityTab(); | 94 final Tab tab = getActivity().getActivityTab(); |
| 92 | 95 |
| 93 simulateRendererKilled(tab, true); | 96 simulateRendererKilled(tab, true); |
| 94 reloadSadTab(tab); | 97 reloadSadTab(tab); |
| 95 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 98 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 96 @Override | 99 @Override |
| 97 public void run() { | 100 public void run() { |
| 98 tab.reload(); // Erases the sad tab page | 101 tab.reload(); // Erases the sad tab page |
| 99 tab.didFinishPageLoad(); // Resets the tab counter to 0 | 102 tab.didFinishPageLoad(); // Resets the tab counter to 0 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 * @param tab The tab that needs to contain a SadTabView. | 136 * @param tab The tab that needs to contain a SadTabView. |
| 134 * @return Returns the button that is on the SadTabView, null if SadTabView. | 137 * @return Returns the button that is on the SadTabView, null if SadTabView. |
| 135 * doesn't exist. | 138 * doesn't exist. |
| 136 */ | 139 */ |
| 137 private Button getSadTabButton(Tab tab) { | 140 private Button getSadTabButton(Tab tab) { |
| 138 return (Button) tab.getContentViewCore().getContainerView() | 141 return (Button) tab.getContentViewCore().getContainerView() |
| 139 .findViewById(R.id.sad_tab_reload_button); | 142 .findViewById(R.id.sad_tab_reload_button); |
| 140 } | 143 } |
| 141 | 144 |
| 142 } | 145 } |
| OLD | NEW |