OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function() { | 5 (function() { |
6 | 6 |
7 'use strict'; | 7 'use strict'; |
8 | 8 |
| 9 /** @type {(sinon.Spy|function():void)} */ |
9 var onShow = null; | 10 var onShow = null; |
| 11 /** @type {(sinon.Spy|function():void)} */ |
10 var onHide = null; | 12 var onHide = null; |
| 13 /** @type {remoting.MenuButton} */ |
11 var menuButton = null; | 14 var menuButton = null; |
12 | 15 |
13 module('MenuButton', { | 16 module('MenuButton', { |
14 setup: function() { | 17 setup: function() { |
15 var fixture = document.getElementById('qunit-fixture'); | 18 var fixture = document.getElementById('qunit-fixture'); |
16 fixture.innerHTML = | 19 fixture.innerHTML = |
17 '<span class="menu-button" id="menu-button-container">' + | 20 '<span class="menu-button" id="menu-button-container">' + |
18 '<button class="menu-button-activator">Click me</button>' + | 21 '<button class="menu-button-activator">Click me</button>' + |
19 '<ul>' + | 22 '<ul>' + |
20 '<li id="menu-option-1">Option 1</li>' + | 23 '<li id="menu-option-1">Option 1</li>' + |
21 '</ul>' + | 24 '</ul>' + |
22 '</span>'; | 25 '</span>'; |
23 onShow = sinon.spy(); | 26 onShow = /** @type {(sinon.Spy|function():void)} */ (sinon.spy()); |
24 onHide = sinon.spy(); | 27 onHide = /** @type {(sinon.Spy|function():void)} */ (sinon.spy()); |
25 menuButton = new remoting.MenuButton( | 28 menuButton = new remoting.MenuButton( |
26 document.getElementById('menu-button-container'), | 29 document.getElementById('menu-button-container'), |
27 onShow, onHide); | 30 /** @type {function():void} */ (onShow), |
| 31 /** @type {function():void} */ (onHide)); |
28 }, | 32 }, |
29 teardown: function() { | 33 teardown: function() { |
30 onShow = null; | 34 onShow = null; |
31 onHide = null; | 35 onHide = null; |
32 menuButton = null; | 36 menuButton = null; |
33 } | 37 } |
34 }); | 38 }); |
35 | 39 |
36 test('should display on click', function() { | 40 test('should display on click', function() { |
37 var menu = menuButton.menu(); | 41 var menu = menuButton.menu(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 var style = window.getComputedStyle(element); | 84 var style = window.getComputedStyle(element); |
81 ok(style.backgroundImage == 'none'); | 85 ok(style.backgroundImage == 'none'); |
82 remoting.MenuButton.select(element, true); | 86 remoting.MenuButton.select(element, true); |
83 style = window.getComputedStyle(element); | 87 style = window.getComputedStyle(element); |
84 ok(style.backgroundImage != 'none'); | 88 ok(style.backgroundImage != 'none'); |
85 remoting.MenuButton.select(element, false); | 89 remoting.MenuButton.select(element, false); |
86 style = window.getComputedStyle(element); | 90 style = window.getComputedStyle(element); |
87 ok(style.backgroundImage == 'none'); | 91 ok(style.backgroundImage == 'none'); |
88 }); | 92 }); |
89 | 93 |
90 }()); | 94 }()); |
OLD | NEW |