Commit ee9b7a2a authored by Vincent Boisselle's avatar Vincent Boisselle Committed by Chromium LUCI CQ

Remove unused feed-related control functions in NewTabPageController

The NTP feed-related tests are in FeedV2NewTabPageTest, which has its own control functions.

Bug: 1167893, 1091640
Change-Id: I9498d1ce753d0a95ed357ea9f5f707022df8ad29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2635346Reviewed-by: default avatarDan H <harringtond@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Vincent Boisselle <vincb@google.com>
Cr-Commit-Position: refs/heads/master@{#845155}
parent 89f60aeb
......@@ -22,10 +22,6 @@ public class NewTabPageController extends PageController {
// becomes common.
private static final int MAX_SCROLL_SWIPES = 50;
private static final String TEXT_HEADER_STATUS_HIDE = "Hide";
private static final String TEXT_HEADER_STATUS_SHOW = "Show";
private static final String REGEX_TEXT_HEADER_STATUS = "^Hide|Show$";
private static final IUi2Locator LOCATOR_SEARCH_BOX_TEXT =
Ui2Locators.withAnyResEntry(R.id.search_box_text);
private static final IUi2Locator LOCATOR_URL_BAR = Ui2Locators.withAnyResEntry(R.id.url_bar);
......@@ -37,9 +33,6 @@ public class NewTabPageController extends PageController {
Ui2Locators.withAnyResEntry(R.id.menu_button);
private static final IUi2Locator LOCATOR_FEED_STREAM_RECYCLER_VIEW =
Ui2Locators.withAnyResEntry(R.id.feed_stream_recycler_view);
private static final IUi2Locator LOCATOR_HEADER_STATUS =
Ui2Locators.withPath(Ui2Locators.withAnyResEntry(R.id.header_status),
Ui2Locators.withTextRegex(REGEX_TEXT_HEADER_STATUS));
private static final IUi2Locator LOCATOR_TAB_SWITCHER =
Ui2Locators.withAnyResEntry(R.id.tab_switcher_button);
......@@ -53,37 +46,6 @@ public class NewTabPageController extends PageController {
return sInstance;
}
/**
* Hide articles if shown, and vice-versa. This will cause page to scroll to where the
* show/hide articles button is visible.
*/
public void toggleHideArticles() {
scrollToTop();
mUtils.swipeUpVerticallyUntilFound(LOCATOR_HEADER_STATUS, LOCATOR_MORE_BUTTON);
mUtils.click(LOCATOR_HEADER_STATUS);
}
/**
* This will cause page to scroll to where the show/hide articles button is visible.
* @return True if articles are currently hidden as indicated by the presence of the
* show/hide articles button, else false.
*/
public boolean areArticlesHidden() {
scrollToTop();
String status_text = mLocatorHelper.getOneText(LOCATOR_HEADER_STATUS);
// The ariticles are hidden if "Show" is displayed, appears to be reversed but makes UI
// sense since the user can click on "Show" to unhide them.
if (status_text.equals(TEXT_HEADER_STATUS_HIDE)) {
return false;
} else if (status_text.equals(TEXT_HEADER_STATUS_SHOW)) {
return true;
} else {
throw new IllegalStateException("Bad status text: " + status_text);
}
}
public void scrollTowardsTop(float screenHeightPercentage) {
mUtils.swipeDownVertically(screenHeightPercentage);
}
......@@ -92,32 +54,11 @@ public class NewTabPageController extends PageController {
mUtils.swipeUpVertically(screenHeightPercentage);
}
public boolean hasScrolledToBottom() {
// If TEXT_HEADER_STATUS_SHOW is displayed, it means articles are hidden.
IUi2Locator locator = Ui2Locators.withPath(
LOCATOR_HEADER_STATUS, Ui2Locators.withTextRegex(TEXT_HEADER_STATUS_SHOW));
if (mLocatorHelper.isOnScreen(locator)) {
return true;
} else {
return mLocatorHelper.isOnScreen(LOCATOR_MORE_BUTTON);
}
}
public boolean hasScrolledToTop() {
return mLocatorHelper.isOnScreen(LOCATOR_SEARCH_PROVIDER_LOGO);
}
public void scrollToBottom() {
scrollToBottom(MAX_SCROLL_SWIPES);
}
public void scrollToBottom(int maxSwipes) {
int swipes = 0;
while (swipes++ < maxSwipes && !hasScrolledToBottom()) {
scrollTowardsBottom(SCROLL_SWIPE_FRACTION);
}
}
public void scrollToTop() {
scrollToTop(MAX_SCROLL_SWIPES);
}
......
......@@ -4,7 +4,6 @@
package org.chromium.chrome.test.pagecontroller.tests;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import android.os.Build.VERSION_CODES;
......@@ -22,7 +21,6 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.DisableIf;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.chrome.test.pagecontroller.controllers.ntp.ChromeMenu;
import org.chromium.chrome.test.pagecontroller.controllers.ntp.NewTabPageController;
import org.chromium.chrome.test.pagecontroller.controllers.urlpage.UrlPage;
......@@ -57,14 +55,6 @@ public class NewTabPageControllerTest {
Assert.assertTrue(mController.isCurrentPageThis());
}
@Test
@DisabledTest(message = "https://crbug.com/1091640")
public void testHideArticles() {
boolean isHidden = mController.areArticlesHidden();
mController.toggleHideArticles();
assertNotEquals(isHidden, mController.areArticlesHidden());
}
@LargeTest
@Test
@DisableIf.
......@@ -72,8 +62,6 @@ public class NewTabPageControllerTest {
public void testScrollPage() {
mController.scrollToTop();
assertTrue(mController.hasScrolledToTop());
mController.scrollToBottom();
assertTrue(mController.hasScrolledToBottom());
}
@Test
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment