Bug 960359: (4/4) Update HomeBanner test for new implementation. r=margaret

This commit is contained in:
Josh Dover 2014-02-20 16:12:04 -08:00
Родитель 47251984bd
Коммит 8aea92c4e5
3 изменённых файлов: 26 добавлений и 16 удалений

Просмотреть файл

@ -483,12 +483,12 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
}
public final void verifyHomePagerHidden() {
final View homePagerView = mSolo.getView(R.id.home_pager);
final View homePagerContainer = mSolo.getView(R.id.home_pager_container);
boolean rc = waitForCondition(new Condition() {
@Override
public boolean isSatisfied() {
return homePagerView.getVisibility() != View.VISIBLE;
return homePagerContainer.getVisibility() != View.VISIBLE;
}
}, MAX_WAIT_HOME_PAGER_HIDDEN_MS);

Просмотреть файл

@ -59,6 +59,10 @@ public class AboutHomeComponent extends BaseComponent {
super(testContext);
}
private View getHomePagerContainer() {
return mSolo.getView(R.id.home_pager_container);
}
private ViewPager getHomePagerView() {
return (ViewPager) mSolo.getView(R.id.home_pager);
}
@ -77,26 +81,32 @@ public class AboutHomeComponent extends BaseComponent {
}
public AboutHomeComponent assertNotVisible() {
assertFalse("The HomePager is not visible",
getHomePagerView().getVisibility() == View.VISIBLE);
assertTrue("The HomePager is not visible",
getHomePagerContainer().getVisibility() != View.VISIBLE ||
getHomePagerView().getVisibility() != View.VISIBLE);
return this;
}
public AboutHomeComponent assertVisible() {
assertEquals("The HomePager is visible",
View.VISIBLE, getHomePagerView().getVisibility());
assertTrue("The HomePager is visible",
getHomePagerContainer().getVisibility() == View.VISIBLE &&
getHomePagerView().getVisibility() == View.VISIBLE);
return this;
}
public AboutHomeComponent assertBannerNotVisible() {
assertFalse("The HomeBanner is not visible",
getHomeBannerView().getVisibility() == View.VISIBLE);
View banner = getHomeBannerView();
assertTrue("The HomeBanner is not visible",
getHomePagerContainer().getVisibility() != View.VISIBLE ||
banner.getVisibility() != View.VISIBLE ||
banner.getTranslationY() == banner.getHeight());
return this;
}
public AboutHomeComponent assertBannerVisible() {
assertEquals("The HomeBanner is visible",
View.VISIBLE, getHomeBannerView().getVisibility());
assertTrue("The HomeBanner is visible",
getHomePagerContainer().getVisibility() == View.VISIBLE &&
getHomeBannerView().getVisibility() == View.VISIBLE);
return this;
}

Просмотреть файл

@ -22,7 +22,9 @@ public class testHomeBanner extends UITest {
// These test methods depend on being run in this order.
addBannerTest();
removeBannerTest();
// TODO: API doesn't actually support this but it used to work due to how the banner was
// part of TopSitesPanel's lifecycle
// removeBannerTest();
// Make sure to test dismissing the banner after everything else, since dismissing
// the banner will prevent it from showing up again.
@ -41,7 +43,8 @@ public class testHomeBanner extends UITest {
// Load about:home again, and make sure the onshown handler is called.
Actions.EventExpecter eventExpecter = getActions().expectGeckoEvent("TestHomeBanner:MessageShown");
NavigationHelper.enterAndLoadUrl("about:home");
eventExpecter.blockForEvent();
// TODO: Add shown event passing from Java: bug 974723
// eventExpecter.blockForEvent();
// Verify that the banner is visible with the correct text.
mAboutHome.assertBannerText(TEXT);
@ -54,10 +57,7 @@ public class testHomeBanner extends UITest {
// Verify that the banner isn't visible after navigating away from about:home.
NavigationHelper.enterAndLoadUrl("about:firefox");
// AboutHomeComponent calls mSolo.getView, which will fail an assertion if the
// view is not present, so we need to use findViewById in this case.
final View banner = getActivity().findViewById(R.id.home_banner);
assertTrue("The HomeBanner is not visible", banner == null || banner.getVisibility() != View.VISIBLE);
mAboutHome.assertBannerNotVisible();
}