Skip to content

Commit

Permalink
use a div to put tests in
Browse files Browse the repository at this point in the history
git-svn-id: https://pyjamas.svn.sourceforge.net/svnroot/pyjamas/trunk@2228 7a2bd370-bda8-463c-979e-2900ccfb811e
  • Loading branch information
lkcl committed Nov 8, 2009
1 parent e99ceda commit c66b15d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
10 changes: 4 additions & 6 deletions examples/uitest/LabelTest.py
Expand Up @@ -9,12 +9,10 @@ class LabelTest(UnitTest):

def testLabelAdd(self):
self.l = Label("Hello World (label)", StyleName='teststyle')
RootPanel().add(self.l)
ht = doc().body.innerHTML
self.write_test_output(ht, 'addlabel')
RootPanel('tests').add(self.l)
self.write_test_output('addlabel')

if not RootPanel().remove(self.l):
if not RootPanel('tests').remove(self.l):
self.fail("Label added but apparently not owned by RootPanel()")
ht = doc().body.innerHTML
self.write_test_output(ht, 'removelabel')
self.write_test_output('removelabel')

18 changes: 10 additions & 8 deletions examples/uitest/UnitTest.py
Expand Up @@ -5,6 +5,7 @@
IN_JS = sys.platform in ['mozilla', 'ie6', 'opera', 'oldmoz',
'safari', 'spidermonkey', 'pyv8']

from pyjamas import DOM
from pyjamas.Timer import Timer

from pyjamas.HTTPRequest import HTTPRequest
Expand Down Expand Up @@ -57,7 +58,12 @@ def do_test(self, output, name):
fname = "%s.txt" % self.current_test_name
HTTPRequest().asyncGet(fname, handler)

def write_test_output(self, output, name=None):
def write_test_output(self, name=None, div_id=None):
if div_id is None:
div_id = 'tests'
element = DOM.getElementById(div_id)
output = element.innerHTML

if self.test_gen_folder is None:
if self.tests_outstanding is None:
self.tests_outstanding = 0
Expand All @@ -76,6 +82,9 @@ def write_test_output(self, output, name=None):
f.write(output)
f.close()

if self.tests_outstanding is None:
self.tests_outstanding = 0

return False

def _run_test(self, test_method_name):
Expand All @@ -91,13 +100,6 @@ def _run_test(self, test_method_name):

def run(self):
self.getTestMethods()
#if not IN_BROWSER:
# for test_method_name in self.test_methods:
# self._run_test(test_method_name)
# self.displayStats()
# if hasattr(self, "start_next_test"):
# self.check_start_next_test()
# return
self.test_idx = 0
Timer(1, self)

Expand Down
2 changes: 0 additions & 2 deletions examples/uitest/public/testLabelAdd.addlabel.txt
@@ -1,3 +1 @@
<pre>Unit Tests will appear and disappear.</pre>
<script language="javascript" src="bootstrap.js"></script>
<div style="white-space: normal;" class="teststyle">Hello World (label)</div>
2 changes: 0 additions & 2 deletions examples/uitest/public/testLabelAdd.removelabel.txt
@@ -1,2 +0,0 @@
<pre>Unit Tests will appear and disappear.</pre>
<script language="javascript" src="bootstrap.js"></script>
1 change: 1 addition & 0 deletions examples/uitest/public/uitest.html
Expand Up @@ -9,5 +9,6 @@
</head>
<body bgcolor="white"><pre>Unit Tests will appear and disappear.</pre>
<script language="javascript" src="bootstrap.js"></script>
<div id='tests'></div>
</body>
</html>

0 comments on commit c66b15d

Please sign in to comment.