PageRenderTime 23ms CodeModel.GetById 9ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/testability-explorer/src/test/java/com/google/test/metric/report/testability_test.html

http://testability-explorer.googlecode.com/
HTML | 94 lines | 80 code | 14 blank | 0 comment | 0 complexity | 7dca81cbc57fe59ecbff3b4a87d7e652 MD5 | raw file
 1<html>
 2<head>
 3<title>Testability test</title>
 4
 5<script type='text/javascript' src='../../../../../../lib/jsunit/app/jsUnitCore.js'></script>
 6<script type='text/javascript' src='../../../../../../src/com/google/test/metric/report/report.js'></script>
 7</head>
 8
 9<body>
10   <script type='text/javascript'>
11   
12   function setUp() {
13      var div = document.createElement('div');
14      div.id = 'id';
15      document.body.appendChild(div);
16      var spanElem = document.createElement('span');
17      spanElem.className = 'expand';
18      spanElem.id = 'spanElem';
19      spanElem.innerHTML = '[+]';
20      div.appendChild(spanElem);
21      var childDiv1 = document.createElement('div');
22      childDiv1.id = 'cDiv1';
23      childDiv1.style.display = 'none';
24      div.appendChild(childDiv1);
25      var childDiv2 = document.createElement('div');
26      childDiv2.id = 'cDiv2';
27      childDiv2.style.display = 'none';
28      childDiv2.className = 'Line';
29      childDiv1.appendChild(childDiv2);
30   }   
31   
32   function tearDown() {
33      var div = document.getElementById('id');
34      document.body.removeChild(div);
35   }
36   
37   function testToggleEmptyToBlock() {
38      var div = document.getElementById('id');
39      assertEquals('', div.style.display);
40      toggle(div);
41      assertEquals('block', div.style.display);
42   }
43   
44   function testToggleNoneToBlock() {
45      var div = document.getElementById('id');
46      div.style.display = 'none';
47      toggle(div);
48      assertEquals('block', div.style.display);
49   }
50   
51   function testToggleBlockToNone() {
52      var div = document.getElementById('id');
53      div.style.display = 'block';
54      toggle(div);
55      assertEquals('none', div.style.display);
56   }
57   
58   function testClickHandlerShowChild() {
59      var div = document.getElementById('id');
60      var event = {target: div};
61      clickHandler(event);
62      var chld = document.getElementById('cDiv1');
63      assertEquals('block', chld.style.display);
64      
65      var span = document.getElementById('spanElem');
66      assertEquals('[-]', span.innerHTML);
67   }
68   
69   function testClickHandlerHideChild() {
70      var div = document.getElementById('id');
71      var event = {target: div};
72      var chld = document.getElementById('cDiv1');
73      var span = document.getElementById('spanElem');
74      span.innerHTML = '[-]';
75      chld.style.display = 'block';
76      clickHandler(event);
77      assertEquals('none', chld.style.display);
78      
79      assertEquals('[+]', span.innerHTML);
80   }
81   
82   function testToggleExpandSign() {
83      var span = document.getElementById('spanElem');
84      var event = {target: span};
85      clickHandler(event);
86      assertEquals('[-]', span.innerHTML);
87      clickHandler(event);
88      assertEquals('[+]', span.innerHTML);
89   }
90   
91
92   </script>
93</body>
94</html>