From: Kevin Sawicki Date: Tue, 4 Apr 2017 20:14:56 +0000 (-0700) Subject: Add spec for interaction event with escape item X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74a3a34caa301cbe5390d00d2cc35fdcf2b97fa7;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Add spec for interaction event with escape item --- diff --git a/lib/browser/api/touch-bar.js b/lib/browser/api/touch-bar.js index 327b639..1070398 100644 --- a/lib/browser/api/touch-bar.js +++ b/lib/browser/api/touch-bar.js @@ -39,13 +39,14 @@ class TouchBar extends EventEmitter { items = [] } + this.changeListener = (item) => { + this.emit('change', item.id, item.type) + } + this.windowListeners = {} this.items = {} this.ordereredItems = [] this.escapeItem = escapeItem - this.changeListener = (item) => { - this.emit('change', item.id, item.type) - } const registerItem = (item) => { this.items[item.id] = item diff --git a/spec/api-touch-bar-spec.js b/spec/api-touch-bar-spec.js index 7080304..420ef3f 100644 --- a/spec/api-touch-bar-spec.js +++ b/spec/api-touch-bar-spec.js @@ -90,5 +90,17 @@ describe('TouchBar module', function () { window.setTouchBar(touchBar) window.emit('-touch-bar-interaction', {}, button.id) }) + + it('calls the callback on the escape item when a window interaction event fires', function (done) { + const button = new TouchBarButton({ + label: 'bar', + click: () => { + done() + } + }) + const touchBar = new TouchBar({escapeItem: button}) + window.setTouchBar(touchBar) + window.emit('-touch-bar-interaction', {}, button.id) + }) }) })