mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 974723 - Send shown event when banner message is displayed. r=margaret
This commit is contained in:
parent
e3bc227f97
commit
1bd84e14ee
@ -138,6 +138,7 @@ public class HomeBanner extends LinearLayout
|
||||
public void run() {
|
||||
mTextView.setText(text);
|
||||
setVisibility(VISIBLE);
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("HomeBanner:Shown", (String) getTag()));
|
||||
|
||||
// Animate the banner if it is currently active.
|
||||
if (mActive) {
|
||||
|
@ -42,13 +42,11 @@ public class testHomeBanner extends UITest {
|
||||
* Note: This test does not remove the message after it is done.
|
||||
*/
|
||||
private void addBannerTest() {
|
||||
addBannerMessage();
|
||||
|
||||
// Load about:home again, and make sure the onshown handler is called.
|
||||
// Load about:home and make sure the onshown handler is called.
|
||||
Actions.EventExpecter eventExpecter = getActions().expectGeckoEvent("TestHomeBanner:MessageShown");
|
||||
addBannerMessage();
|
||||
NavigationHelper.enterAndLoadUrl("about:home");
|
||||
// TODO: Add shown event passing from Java: bug 974723
|
||||
// eventExpecter.blockForEvent();
|
||||
eventExpecter.blockForEvent();
|
||||
|
||||
// Verify that the banner is visible with the correct text.
|
||||
mAboutHome.assertBannerText(TEXT);
|
||||
|
@ -69,7 +69,10 @@ let HomeBanner = (function () {
|
||||
text: message.text,
|
||||
iconURI: message.iconURI
|
||||
});
|
||||
};
|
||||
|
||||
let _handleShown = function(id) {
|
||||
let message = _messages[id];
|
||||
if (message.onshown)
|
||||
message.onshown();
|
||||
};
|
||||
@ -93,13 +96,17 @@ let HomeBanner = (function () {
|
||||
_handleGet();
|
||||
break;
|
||||
|
||||
case "HomeBanner:Shown":
|
||||
_handleShown(data);
|
||||
break;
|
||||
|
||||
case "HomeBanner:Click":
|
||||
_handleClick(data);
|
||||
break;
|
||||
|
||||
case "HomeBanner:Dismiss":
|
||||
_handleDismiss(data);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -119,6 +126,7 @@ let HomeBanner = (function () {
|
||||
// observers to listen for requests from the Java UI.
|
||||
if (Object.keys(_messages).length == 1) {
|
||||
Services.obs.addObserver(this, "HomeBanner:Get", false);
|
||||
Services.obs.addObserver(this, "HomeBanner:Shown", false);
|
||||
Services.obs.addObserver(this, "HomeBanner:Click", false);
|
||||
Services.obs.addObserver(this, "HomeBanner:Dismiss", false);
|
||||
|
||||
@ -149,6 +157,7 @@ let HomeBanner = (function () {
|
||||
// If there are no more messages, remove the observers.
|
||||
if (Object.keys(_messages).length == 0) {
|
||||
Services.obs.removeObserver(this, "HomeBanner:Get");
|
||||
Services.obs.removeObserver(this, "HomeBanner:Shown");
|
||||
Services.obs.removeObserver(this, "HomeBanner:Click");
|
||||
Services.obs.removeObserver(this, "HomeBanner:Dismiss");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user