Bug 963561 - Test case for new home banner dismiss handler. r=mcomella

This commit is contained in:
Margaret Leibovic 2014-02-14 16:51:44 -08:00
parent a2b224a6ae
commit 3ed0707047
3 changed files with 24 additions and 0 deletions

View File

@ -117,6 +117,14 @@ public class AboutHomeComponent extends BaseComponent {
return this;
}
public AboutHomeComponent dismissBanner() {
assertBannerVisible();
mTestContext.dumpLog(LOGTAG, "Clicking on HomeBanner close button.");
mSolo.clickOnView(getHomeBannerView().findViewById(R.id.close));
return this;
}
public AboutHomeComponent swipeToPanelOnRight() {
mTestContext.dumpLog(LOGTAG, "Swiping to the panel on the right.");
swipeToPanel(Solo.RIGHT);

View File

@ -25,6 +25,9 @@ function addMessage() {
},
onshown: function() {
sendMessageToJava({ type: "TestHomeBanner:MessageShown" });
},
ondismiss: function() {
sendMessageToJava({ type: "TestHomeBanner:MessageDismissed" });
}
});
sendMessageToJava({ type: "TestHomeBanner:MessageAdded" });

View File

@ -49,6 +49,19 @@ public class testHomeBanner extends UITest {
NavigationHelper.enterAndLoadUrl("about:home");
mAboutHome.assertVisible()
.assertBannerNotVisible();
// Add back the banner message to test the dismiss functionality.
addBannerMessage();
NavigationHelper.enterAndLoadUrl("about:home");
mAboutHome.assertVisible();
// Test to make sure the ondismiss handler is called when the close button is clicked.
eventExpecter = getActions().expectGeckoEvent("TestHomeBanner:MessageDismissed");
mAboutHome.dismissBanner();
eventExpecter.blockForEvent();
mAboutHome.assertBannerNotVisible();
}
/**