Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / third_party / tvcm / tvcm / module_test_case.py
index cdb6cbe..138c9ed 100644 (file)
@@ -19,10 +19,18 @@ _currently_active_module_test_suite = None
 def _NavigateToTestCaseRunner(bc):
   bc.NavigateToPath('/tvcm/unittest/module_test_case_runner.html')
   bc.WaitForJavaScriptExpression('window.__readyToRun == true')
-  bc.WaitForJavaScriptExpression('window.tvcm !== undefined')
-  bc.WaitForJavaScriptExpression('window.tvcm.hasPanic !== undefined')
-  bc.WaitForJavaScriptExpression('window.discoverTestsInModules !== undefined')
-  bc.WaitForJavaScriptExpression('window.runTestNamed !== undefined')
+  # Sanity checks that __readyToRun is working right. If any of these pop,
+  # it implies that __readyToRun isn't working.
+  sanity_checks = [
+    'window.tvcm !== undefined',
+    'window.tvcm.GUID.allocate !== undefined',
+    'window.tvcm.hasPanic !== undefined',
+    'window.discoverTestsInModules !== undefined',
+    'window.runTestNamed !== undefined'
+  ]
+  for check in sanity_checks:
+    if not bc.EvaluateJavaScript(check):
+      raise Exception('Load failed because sanity check %s failed')
 
 
 class ModuleTestSuite(unittest.TestSuite):
@@ -43,8 +51,8 @@ class ModuleTestSuite(unittest.TestSuite):
     return self.run(*args)
 
   def run(self, result):
-    self.setUp()
     try:
+      self.setUp()
       return super(ModuleTestSuite, self).run(result)
     finally:
       self.tearDown()