333f2504a7c55dd940c87f2e509db8feb8b3ad40
[platform/framework/web/crosswalk.git] / src / ui / webui / resources / js / cr / ui / menu_test.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js">
5 </script>
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>
12 <script>
13
14 goog.require('goog.testing.jsunit');
15
16 </script>
17
18 </head>
19 <body>
20
21 <script>
22
23 /**
24  * Tests that if the command attributes are spacified, they are copied to the
25  * corresponding menuitem.
26  */
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);
35
36   var menuItem = new cr.ui.MenuItem();
37   menuItem.command = '#the-command';
38
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);
44
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);
51
52   var menuItem2 = new cr.ui.MenuItem();
53   menuItem2.label = 'MenuLabel';
54   menuItem2.command = '#the-command2';
55
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);
61 }
62
63 </script>
64
65 </body>
66 </html>