Bug 1135111 - Add test to ensure that the toolbar in reader mode displays the original page url. r=mcomella

This commit is contained in:
Sebastian Kaspari 2015-03-08 12:15:00 -04:00
parent 39eb363d02
commit 4891d539e2
4 changed files with 65 additions and 0 deletions

View File

@ -113,6 +113,7 @@ public class StringHelper {
public static final String ROBOCOP_TEXT_PAGE_URL = "/robocop/robocop_text_page.html";
public static final String ROBOCOP_ADOBE_FLASH_URL = "/robocop/robocop_adobe_flash.html";
public static final String ROBOCOP_INPUT_URL = "/robocop/robocop_input.html";
public static final String ROBOCOP_READER_MODE_BASIC_ARTICLE = "/robocop/reader_mode_pages/basic_article.html";
private static final String ROBOCOP_JS_HARNESS_URL = "/robocop/robocop_javascript.html";
@ -269,4 +270,7 @@ public class StringHelper {
public static final String POPUP_MESSAGE = "prevented this site from opening";
public static final String POPUP_ALLOW = "Show";
public static final String POPUP_DENY = "Don't show";
// Strings used as content description, e.g. for ImageButtons
public static final String CONTENT_DESCRIPTION_READER_MODE_BUTTON = "Enter Reader View";
}

View File

@ -16,6 +16,7 @@ import org.mozilla.gecko.tests.UITestContext;
import org.mozilla.gecko.tests.helpers.DeviceHelper;
import org.mozilla.gecko.tests.helpers.NavigationHelper;
import org.mozilla.gecko.tests.helpers.WaitHelper;
import org.mozilla.gecko.toolbar.PageActionLayout;
import android.view.View;
import android.widget.EditText;
@ -32,6 +33,10 @@ public class ToolbarComponent extends BaseComponent {
private static final String URL_HTTP_PREFIX = "http://";
// We are waiting up to 30 seconds instead of the default waiting time
// because reader mode parsing can take quite some time on slower devices
private static final int READER_MODE_WAIT_MS = 30000;
public ToolbarComponent(final UITestContext testContext) {
super(testContext);
}
@ -113,6 +118,25 @@ public class ToolbarComponent extends BaseComponent {
DeviceHelper.assertIsTablet();
return (ImageButton) getToolbarView().findViewById(R.id.reload);
}
private PageActionLayout getPageActionLayout() {
return (PageActionLayout) getToolbarView().findViewById(R.id.page_action_layout);
}
private ImageButton getReaderModeButton() {
final PageActionLayout pageActionLayout = getPageActionLayout();
final int count = pageActionLayout.getChildCount();
for (int i = 0; i < count; i++) {
final View view = pageActionLayout.getChildAt(i);
if (StringHelper.CONTENT_DESCRIPTION_READER_MODE_BUTTON.equals(view.getContentDescription())) {
return (ImageButton) view;
}
}
return null;
}
/**
* Returns the View for the edit cancel button in the browser toolbar.
*/
@ -224,6 +248,13 @@ public class ToolbarComponent extends BaseComponent {
return pressButton(reloadButton, "reload");
}
public ToolbarComponent pressReaderModeButton() {
final ImageButton readerModeButton = waitForReaderModeButton();
pressButton(readerModeButton, "reader mode");
return this;
}
private ToolbarComponent pressButton(final View view, final String buttonName) {
fAssertNotNull("The " + buttonName + " button View is not null", view);
fAssertTrue("The " + buttonName + " button is enabled", view.isEnabled());
@ -259,6 +290,19 @@ public class ToolbarComponent extends BaseComponent {
});
}
private ImageButton waitForReaderModeButton() {
final ImageButton[] readerModeButton = new ImageButton[1];
WaitHelper.waitFor("the Reader mode button to be visible", new Condition() {
@Override
public boolean isSatisfied() {
return (readerModeButton[0] = getReaderModeButton()) != null;
}
}, READER_MODE_WAIT_MS);
return readerModeButton[0];
}
private boolean isUrlEditTextSelected() {
return getUrlEditText().isSelected();
}

View File

@ -141,6 +141,7 @@ skip-if = android_version == "10"
skip-if = android_version == "10"
[testJavascriptBridge]
[testNativeCrypto]
[testReaderModeTitle]
[testSessionHistory]
# testSelectionHandler disabled on Android 2.3 by trailing skip-if, due to bug 980074

View File

@ -0,0 +1,16 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.tests.helpers.NavigationHelper;
/**
* This tests ensures that the toolbar in reader mode displays the original page url.
*/
public class testReaderModeTitle extends UITest {
public void testReaderModeTitle() {
NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_READER_MODE_BASIC_ARTICLE);
mToolbar.pressReaderModeButton();
mToolbar.assertTitle(StringHelper.ROBOCOP_READER_MODE_BASIC_ARTICLE);
}
}