Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(816)

Side by Side Diff: remoting/webapp/unittests/menu_button_unittest.js

Issue 339613003: Remove the blue tool-bar for apps v2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added New Connection to options menu. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 var menuButton = null; 9 var menuButton = null;
10 var menuShown = false; 10 var onShow = sinon.spy();
11 var onHide = sinon.spy();
kelvinp 2014/07/23 18:49:08 To avoid side-effect. We should var onShow = null;
Jamie 2014/07/23 20:00:38 Good catch! Done.
11 12
12 module('MenuButton', { 13 module('MenuButton', {
13 setup: function() { 14 setup: function() {
14 var fixture = document.getElementById('qunit-fixture'); 15 var fixture = document.getElementById('qunit-fixture');
15 fixture.innerHTML = 16 fixture.innerHTML =
16 '<span class="menu-button" id="menu-button-container">' + 17 '<span class="menu-button" id="menu-button-container">' +
17 '<button class="menu-button-activator">Click me</button>' + 18 '<button class="menu-button-activator">Click me</button>' +
18 '<ul>' + 19 '<ul>' +
19 '<li id="menu-option-1">Option 1</li>' + 20 '<li id="menu-option-1">Option 1</li>' +
20 '</ul>' + 21 '</ul>' +
21 '</span>'; 22 '</span>';
22 menuButton = new remoting.MenuButton( 23 menuButton = new remoting.MenuButton(
23 document.getElementById('menu-button-container'), 24 document.getElementById('menu-button-container'),
24 function() { menuShown = true; }); 25 onShow, onHide);
25 menuShown = false;
26 }, 26 },
27 teardown: function() { 27 teardown: function() {
28 } 28 }
29 }); 29 });
30 30
31 test('should display on click', function() { 31 test('should display on click', function() {
32 var menu = menuButton.menu(); 32 var menu = menuButton.menu();
33 ok(menu.offsetWidth == 0 && menu.offsetHeight == 0); 33 ok(menu.offsetWidth == 0 && menu.offsetHeight == 0);
34 menuButton.button().click(); 34 menuButton.button().click();
35 ok(menu.offsetWidth != 0 && menu.offsetHeight != 0); 35 ok(menu.offsetWidth != 0 && menu.offsetHeight != 0);
(...skipping 14 matching lines...) Expand all
50 }); 50 });
51 51
52 test('should dismiss when menu item is clicked', function() { 52 test('should dismiss when menu item is clicked', function() {
53 var menu = menuButton.menu(); 53 var menu = menuButton.menu();
54 menuButton.button().click(); 54 menuButton.button().click();
55 var element = document.getElementById('menu-option-1'); 55 var element = document.getElementById('menu-option-1');
56 element.click(); 56 element.click();
57 ok(menu.offsetWidth == 0 && menu.offsetHeight == 0); 57 ok(menu.offsetWidth == 0 && menu.offsetHeight == 0);
58 }); 58 });
59 59
60 test('should invoke callback', function() { 60 test('should invoke callbacks', function() {
61 ok(!menuShown); 61 ok(!onShow.called);
62 menuButton.button().click(); 62 menuButton.button().click();
63 ok(menuShown); 63 ok(onShow.called);
64 ok(!onHide.called);
65 document.body.click();
66 ok(onHide.called);
64 }); 67 });
65 68
66 test('select method should set/unset background image', function() { 69 test('select method should set/unset background image', function() {
67 var element = document.getElementById('menu-option-1'); 70 var element = document.getElementById('menu-option-1');
68 var style = window.getComputedStyle(element); 71 var style = window.getComputedStyle(element);
69 ok(style.backgroundImage == 'none'); 72 ok(style.backgroundImage == 'none');
70 remoting.MenuButton.select(element, true); 73 remoting.MenuButton.select(element, true);
71 style = window.getComputedStyle(element); 74 style = window.getComputedStyle(element);
72 ok(style.backgroundImage != 'none'); 75 ok(style.backgroundImage != 'none');
73 remoting.MenuButton.select(element, false); 76 remoting.MenuButton.select(element, false);
74 style = window.getComputedStyle(element); 77 style = window.getComputedStyle(element);
75 ok(style.backgroundImage == 'none'); 78 ok(style.backgroundImage == 'none');
76 }); 79 });
77 80
78 }()); 81 }());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698