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

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: Made unit-tests side-effect-free. 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
« no previous file with comments | « remoting/webapp/toolbar.js ('k') | remoting/webapp/window_frame.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 onShow = null;
10 var onHide = null;
9 var menuButton = null; 11 var menuButton = null;
10 var menuShown = false;
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>';
23 onShow = sinon.spy();
24 onHide = sinon.spy();
22 menuButton = new remoting.MenuButton( 25 menuButton = new remoting.MenuButton(
23 document.getElementById('menu-button-container'), 26 document.getElementById('menu-button-container'),
24 function() { menuShown = true; }); 27 onShow, onHide);
25 menuShown = false;
26 }, 28 },
27 teardown: function() { 29 teardown: function() {
30 onShow = null;
31 onHide = null;
32 menuButton = null;
28 } 33 }
29 }); 34 });
30 35
31 test('should display on click', function() { 36 test('should display on click', function() {
32 var menu = menuButton.menu(); 37 var menu = menuButton.menu();
33 ok(menu.offsetWidth == 0 && menu.offsetHeight == 0); 38 ok(menu.offsetWidth == 0 && menu.offsetHeight == 0);
34 menuButton.button().click(); 39 menuButton.button().click();
35 ok(menu.offsetWidth != 0 && menu.offsetHeight != 0); 40 ok(menu.offsetWidth != 0 && menu.offsetHeight != 0);
36 }); 41 });
37 42
(...skipping 12 matching lines...) Expand all
50 }); 55 });
51 56
52 test('should dismiss when menu item is clicked', function() { 57 test('should dismiss when menu item is clicked', function() {
53 var menu = menuButton.menu(); 58 var menu = menuButton.menu();
54 menuButton.button().click(); 59 menuButton.button().click();
55 var element = document.getElementById('menu-option-1'); 60 var element = document.getElementById('menu-option-1');
56 element.click(); 61 element.click();
57 ok(menu.offsetWidth == 0 && menu.offsetHeight == 0); 62 ok(menu.offsetWidth == 0 && menu.offsetHeight == 0);
58 }); 63 });
59 64
60 test('should invoke callback', function() { 65 test('should invoke callbacks', function() {
61 ok(!menuShown); 66 ok(!onShow.called);
62 menuButton.button().click(); 67 menuButton.button().click();
63 ok(menuShown); 68 ok(onShow.called);
69 ok(!onHide.called);
70 document.body.click();
71 ok(onHide.called);
64 }); 72 });
65 73
66 test('select method should set/unset background image', function() { 74 test('select method should set/unset background image', function() {
67 var element = document.getElementById('menu-option-1'); 75 var element = document.getElementById('menu-option-1');
68 var style = window.getComputedStyle(element); 76 var style = window.getComputedStyle(element);
69 ok(style.backgroundImage == 'none'); 77 ok(style.backgroundImage == 'none');
70 remoting.MenuButton.select(element, true); 78 remoting.MenuButton.select(element, true);
71 style = window.getComputedStyle(element); 79 style = window.getComputedStyle(element);
72 ok(style.backgroundImage != 'none'); 80 ok(style.backgroundImage != 'none');
73 remoting.MenuButton.select(element, false); 81 remoting.MenuButton.select(element, false);
74 style = window.getComputedStyle(element); 82 style = window.getComputedStyle(element);
75 ok(style.backgroundImage == 'none'); 83 ok(style.backgroundImage == 'none');
76 }); 84 });
77 85
78 }()); 86 }());
OLDNEW
« no previous file with comments | « remoting/webapp/toolbar.js ('k') | remoting/webapp/window_frame.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698