зеркало из https://github.com/mozilla/gecko-dev.git
Bug 960359: (4/4) Update HomeBanner test for new implementation. r=margaret
This commit is contained in:
Родитель
47251984bd
Коммит
8aea92c4e5
|
@ -483,12 +483,12 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void verifyHomePagerHidden() {
|
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() {
|
boolean rc = waitForCondition(new Condition() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isSatisfied() {
|
public boolean isSatisfied() {
|
||||||
return homePagerView.getVisibility() != View.VISIBLE;
|
return homePagerContainer.getVisibility() != View.VISIBLE;
|
||||||
}
|
}
|
||||||
}, MAX_WAIT_HOME_PAGER_HIDDEN_MS);
|
}, MAX_WAIT_HOME_PAGER_HIDDEN_MS);
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@ public class AboutHomeComponent extends BaseComponent {
|
||||||
super(testContext);
|
super(testContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private View getHomePagerContainer() {
|
||||||
|
return mSolo.getView(R.id.home_pager_container);
|
||||||
|
}
|
||||||
|
|
||||||
private ViewPager getHomePagerView() {
|
private ViewPager getHomePagerView() {
|
||||||
return (ViewPager) mSolo.getView(R.id.home_pager);
|
return (ViewPager) mSolo.getView(R.id.home_pager);
|
||||||
}
|
}
|
||||||
|
@ -77,26 +81,32 @@ public class AboutHomeComponent extends BaseComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AboutHomeComponent assertNotVisible() {
|
public AboutHomeComponent assertNotVisible() {
|
||||||
assertFalse("The HomePager is not visible",
|
assertTrue("The HomePager is not visible",
|
||||||
getHomePagerView().getVisibility() == View.VISIBLE);
|
getHomePagerContainer().getVisibility() != View.VISIBLE ||
|
||||||
|
getHomePagerView().getVisibility() != View.VISIBLE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AboutHomeComponent assertVisible() {
|
public AboutHomeComponent assertVisible() {
|
||||||
assertEquals("The HomePager is visible",
|
assertTrue("The HomePager is visible",
|
||||||
View.VISIBLE, getHomePagerView().getVisibility());
|
getHomePagerContainer().getVisibility() == View.VISIBLE &&
|
||||||
|
getHomePagerView().getVisibility() == View.VISIBLE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AboutHomeComponent assertBannerNotVisible() {
|
public AboutHomeComponent assertBannerNotVisible() {
|
||||||
assertFalse("The HomeBanner is not visible",
|
View banner = getHomeBannerView();
|
||||||
getHomeBannerView().getVisibility() == View.VISIBLE);
|
assertTrue("The HomeBanner is not visible",
|
||||||
|
getHomePagerContainer().getVisibility() != View.VISIBLE ||
|
||||||
|
banner.getVisibility() != View.VISIBLE ||
|
||||||
|
banner.getTranslationY() == banner.getHeight());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AboutHomeComponent assertBannerVisible() {
|
public AboutHomeComponent assertBannerVisible() {
|
||||||
assertEquals("The HomeBanner is visible",
|
assertTrue("The HomeBanner is visible",
|
||||||
View.VISIBLE, getHomeBannerView().getVisibility());
|
getHomePagerContainer().getVisibility() == View.VISIBLE &&
|
||||||
|
getHomeBannerView().getVisibility() == View.VISIBLE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,9 @@ public class testHomeBanner extends UITest {
|
||||||
|
|
||||||
// These test methods depend on being run in this order.
|
// These test methods depend on being run in this order.
|
||||||
addBannerTest();
|
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
|
// Make sure to test dismissing the banner after everything else, since dismissing
|
||||||
// the banner will prevent it from showing up again.
|
// 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.
|
// Load about:home again, and make sure the onshown handler is called.
|
||||||
Actions.EventExpecter eventExpecter = getActions().expectGeckoEvent("TestHomeBanner:MessageShown");
|
Actions.EventExpecter eventExpecter = getActions().expectGeckoEvent("TestHomeBanner:MessageShown");
|
||||||
NavigationHelper.enterAndLoadUrl("about:home");
|
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.
|
// Verify that the banner is visible with the correct text.
|
||||||
mAboutHome.assertBannerText(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.
|
// Verify that the banner isn't visible after navigating away from about:home.
|
||||||
NavigationHelper.enterAndLoadUrl("about:firefox");
|
NavigationHelper.enterAndLoadUrl("about:firefox");
|
||||||
|
|
||||||
// AboutHomeComponent calls mSolo.getView, which will fail an assertion if the
|
mAboutHome.assertBannerNotVisible();
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче