PageRenderTime 15ms CodeModel.GetById 8ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/toolkit/content/tests/chrome/test_deck.xul

http://github.com/zpao/v8monkey
Unknown | 58 lines | 48 code | 10 blank | 0 comment | 0 complexity | d81cc0b72df7456d282f966d0a91590f MD5 | raw file
 1<?xml version="1.0"?>
 2<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 3<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 4<!--
 5  XUL Widget Test for deck
 6  -->
 7<window title="Deck Test"
 8        onload="setTimeout(test_deck, 0);"
 9        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
10  <script type="application/javascript"
11          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
12  <script type="application/javascript"
13          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>      
14
15<deck id="deck1" style="padding-top: 5px; padding-bottom: 12px;">
16  <button id="d1b1" label="Button One"/>
17  <button id="d1b2" label="Button Two is larger" height="80" style="margin: 1px;"/>
18</deck>
19<deck id="deck2" selectedIndex="1">
20  <button id="d2b1" label="Button One"/>
21  <button id="d2b2" label="Button Two"/>
22</deck>
23
24  <!-- test results are displayed in the html:body -->
25  <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
26
27  <!-- test code goes here -->
28  <script type="application/javascript"><![CDATA[
29
30SimpleTest.waitForExplicitFinish();
31
32function test_deck()
33{
34  var deck = $("deck1");
35  ok(deck.selectedIndex === '0', "deck one selectedIndex");
36  // this size is the button height, 80, plus the button padding of 1px on each side,
37  // plus the deck's 5px top padding and the 12px bottom padding.
38  var rect = deck.getBoundingClientRect();
39  is(Math.round(rect.bottom) - Math.round(rect.top), 99, "deck size of largest child");
40  synthesizeMouseExpectEvent(deck, 12, 12, { }, $("d1b1"), "click", "mouse on deck one");
41
42  // change the selected page of the deck and ensure that the mouse click goes
43  // to the button on that page
44  deck.selectedIndex = 1;
45  ok(deck.selectedIndex === '1', "deck one selectedIndex after change");
46  synthesizeMouseExpectEvent(deck, 9, 9, { }, $("d1b2"), "click", "mouse on deck one after change");
47
48  deck = $("deck2");
49  ok(deck.selectedIndex === '1', "deck two selectedIndex");
50  synthesizeMouseExpectEvent(deck, 9, 9, { }, $("d2b2"), "click", "mouse on deck two");
51
52  SimpleTest.finish();
53}
54
55]]>
56</script>
57
58</window>