4 <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js">
6 <script src="../../cr.js"></script>
7 <script src="../event_target.js"></script>
8 <script src="../ui.js"></script>
9 <script src="command.js"></script>
10 <script src="menu.js"></script>
11 <script src="menu_item.js"></script>
14 goog.require('goog.testing.jsunit');
24 * Tests that if the command attributes are spacified, they are copied to the
25 * corresponding menuitem.
27 function testCommandMenuItem() {
28 // Test 1: The case that the comamnd label is set.
29 var command = new cr.ui.Command();
30 command.id = 'the-command';
31 command.label = 'CommandLabel';
32 command.disabled = false;
33 command.hidden = false;
34 document.body.appendChild(command);
36 var menuItem = new cr.ui.MenuItem();
37 menuItem.command = '#the-command';
39 // Confirms the label is copied from the command.
40 assertEquals('CommandLabel', menuItem.label);
41 // Confirms the attributes are copied from the command.
42 assertEquals(false, menuItem.disabled);
43 assertEquals(false, menuItem.hidden);
45 // Test 2: The case that the comamnd label is not set.
46 var command2 = new cr.ui.Command();
47 command2.id = 'the-command2';
48 command2.disabled = false;
49 command2.hidden = false;
50 document.body.appendChild(command2);
52 var menuItem2 = new cr.ui.MenuItem();
53 menuItem2.label = 'MenuLabel';
54 menuItem2.command = '#the-command2';
56 // Confirms the label is not copied, keeping the original label.
57 assertEquals('MenuLabel', menuItem2.label);
58 // Confirms the attributes are copied from the command.
59 assertEquals(false, menuItem2.disabled);
60 assertEquals(false, menuItem2.hidden);