# Path: wdom/tag.py
# H1 = NewTagClass('H1')
# 
# Path: wdom/document.py
# def get_document() -> Document:
#     """Get current root document object.
# 
#     :rtype: Document
#     """
#     return rootDocument
# 
# def set_app(app: Tag) -> None:
#     """Set ``Tag`` as applicaion to the current root document.
# 
#     Equivalent to ``get_document().body.prepend(app)``.
#     """
#     document = get_document()
#     document.body.prepend(app)
# 
# Path: wdom/util.py
# def suppress_logging() -> None:
#     """Suppress log output to stdout.
# 
#     This function is intended to be used in test's setup. This function removes
#     log handler of ``wdom`` logger and set NullHandler to suppress log.
#     """
#     from wdom import options
#     options.root_logger.removeHandler(options._log_handler)
#     options.root_logger.addHandler(logging.NullHandler())
# 
# Path: tests/base.py
# class TestCase(unittest.TestCase):
#     """Base class for testing wdom modules.
# 
#     This class is a sub class of the ``unittest.TestCase``. After all test
#     methods, reset wdom's global objects like document, application, and
#     elements. If you use ``tearDown`` method, do not forget to call
#     ``super().tearDown()``.
#     """
# 
#     def setUp(self) -> None:
#         """Reset WDOM states."""
#         super().setUp()
#         reset()
# 
#     def tearDown(self) -> None:
#         """Reset WDOM states."""
#         reset()
#         super().tearDown()
# 
#     def assertIsTrue(self, bl: bool) -> None:
#         """Check arg is exactly True, not truthy."""
#         self.assertIs(bl, True)
# 
#     def assertIsFalse(self, bl: bool) -> None:
#         """Check arg is exactly False, not falsy."""
#         self.assertIs(bl, False)
# 
# Path: tests/test_selenium/base.py
# class WebDriverTestCase:
#     """Base class for testing UI on browser.
# 
#     This class starts up an HTTP server on a new subprocess.
# 
#     Subclasses should call ``start`` method after seting up your document.
#     After ``start`` method called, the web server is running on the other
#     process so you cannot make change on the document. If you need to change
#     document after server started, please use ``RemoteBrowserTestCase`` class
#     instead.
#     """
# 
#     #: seconds to wait for by ``wait`` method.
#     wait_time = 0.01
#     #: secondes for deault timeout for ``wait_until`` method
#     timeout = 1.0
# 
#     @classmethod
#     def setUpClass(cls) -> None:  # noqa: D102
#         reset()
# 
#     @classmethod
#     def tearDownClass(cls) -> None:  # noqa: D102
#         reset()
# 
#     def start(self) -> None:
#         """Start server and web driver."""
#         self.wd = get_webdriver()
# 
#         def start_server(port: int) -> None:
#             from wdom import server
#             server.start(port=port)
# 
#         self.address = 'localhost'
#         self.port = free_port()
#         self.url = 'http://{0}:{1}/'.format(self.address, self.port)
# 
#         self.server = Process(
#             target=start_server,
#             args=(self.port, )
#         )
#         self.server.start()
#         self.wait(times=10)
#         self.wd.get(self.url)
# 
#     def tearDown(self) -> None:
#         """Terminate server subprocess."""
#         self.server.terminate()
#         sys.stdout.flush()
#         sys.stderr.flush()
#         self.wait(times=10)
#         super().tearDown()  # type: ignore
# 
#     def wait(self, timeout: float = None, times: int = 1) -> None:
#         """Wait for ``timeout`` or ``self.wait_time``."""
#         loop = asyncio.get_event_loop()
#         for i in range(times):
#             loop.run_until_complete(asyncio.sleep(timeout or self.wait_time))
# 
#     def wait_until(self, func: Callable[[], Any],
#                    timeout: float = None) -> None:
#         """Wait until ``func`` returns True or exceeds timeout.
# 
#         ``func`` is called with no argument. Unit of ``timeout`` is second, and
#         its default value is RemoteBrowserTestCase.timeout class variable
#         (default: 1.0).
#         """
#         st = time.perf_counter()
#         timeout = timeout or self.timeout
#         while (time.perf_counter() - st) < timeout:
#             if func():
#                 return
#             self.wait()
#         raise TimeoutError('{} did not return True until timeout'.format(func))
# 
#     def send_keys(self, element: Element, keys: str) -> None:
#         """Send ``keys`` to ``element`` one-by-one.
# 
#         Safer than using ``element.send_keys`` method.
#         """
#         for k in keys:
#             element.send_keys(k)
# 
# def close_webdriver() -> None:
#     """Close WebDriver."""
#     global local_webdriver
#     if local_webdriver is not None:
#         local_webdriver.close()
#         local_webdriver = None


from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.color import Color
from wdom.tag import H1
from wdom.document import get_document, set_app
from wdom.util import suppress_logging
from ..base import TestCase
from .base import WebDriverTestCase, close_webdriver
        from wdom.examples.data_binding import sample_app
        from wdom.examples.drag import sample_app
        from wdom.examples.global_events import sample_page, set_app
        from wdom.examples.rev_text import sample_app
        from wdom.examples.timer import sample_app
#!/usr/bin/env python3
# -*- coding: utf-8 -*-





def setUpModule():
    suppress_logging()


def tearDownModule():
    close_webdriver()


class SimpleTestCase(WebDriverTestCase, TestCase):
    def setUp(self):
        super().setUp()
        document = get_document()

# Path: wdom/tag.py
# H1 = NewTagClass('H1')
# 
# Path: wdom/document.py
# def get_document() -> Document:
#     """Get current root document object.
# 
#     :rtype: Document
#     """
#     return rootDocument
# 
# def set_app(app: Tag) -> None:
#     """Set ``Tag`` as applicaion to the current root document.
# 
#     Equivalent to ``get_document().body.prepend(app)``.
#     """
#     document = get_document()
#     document.body.prepend(app)
# 
# Path: wdom/util.py
# def suppress_logging() -> None:
#     """Suppress log output to stdout.
# 
#     This function is intended to be used in test's setup. This function removes
#     log handler of ``wdom`` logger and set NullHandler to suppress log.
#     """
#     from wdom import options
#     options.root_logger.removeHandler(options._log_handler)
#     options.root_logger.addHandler(logging.NullHandler())
# 
# Path: tests/base.py
# class TestCase(unittest.TestCase):
#     """Base class for testing wdom modules.
# 
#     This class is a sub class of the ``unittest.TestCase``. After all test
#     methods, reset wdom's global objects like document, application, and
#     elements. If you use ``tearDown`` method, do not forget to call
#     ``super().tearDown()``.
#     """
# 
#     def setUp(self) -> None:
#         """Reset WDOM states."""
#         super().setUp()
#         reset()
# 
#     def tearDown(self) -> None:
#         """Reset WDOM states."""
#         reset()
#         super().tearDown()
# 
#     def assertIsTrue(self, bl: bool) -> None:
#         """Check arg is exactly True, not truthy."""
#         self.assertIs(bl, True)
# 
#     def assertIsFalse(self, bl: bool) -> None:
#         """Check arg is exactly False, not falsy."""
#         self.assertIs(bl, False)
# 
# Path: tests/test_selenium/base.py
# class WebDriverTestCase:
#     """Base class for testing UI on browser.
# 
#     This class starts up an HTTP server on a new subprocess.
# 
#     Subclasses should call ``start`` method after seting up your document.
#     After ``start`` method called, the web server is running on the other
#     process so you cannot make change on the document. If you need to change
#     document after server started, please use ``RemoteBrowserTestCase`` class
#     instead.
#     """
# 
#     #: seconds to wait for by ``wait`` method.
#     wait_time = 0.01
#     #: secondes for deault timeout for ``wait_until`` method
#     timeout = 1.0
# 
#     @classmethod
#     def setUpClass(cls) -> None:  # noqa: D102
#         reset()
# 
#     @classmethod
#     def tearDownClass(cls) -> None:  # noqa: D102
#         reset()
# 
#     def start(self) -> None:
#         """Start server and web driver."""
#         self.wd = get_webdriver()
# 
#         def start_server(port: int) -> None:
#             from wdom import server
#             server.start(port=port)
# 
#         self.address = 'localhost'
#         self.port = free_port()
#         self.url = 'http://{0}:{1}/'.format(self.address, self.port)
# 
#         self.server = Process(
#             target=start_server,
#             args=(self.port, )
#         )
#         self.server.start()
#         self.wait(times=10)
#         self.wd.get(self.url)
# 
#     def tearDown(self) -> None:
#         """Terminate server subprocess."""
#         self.server.terminate()
#         sys.stdout.flush()
#         sys.stderr.flush()
#         self.wait(times=10)
#         super().tearDown()  # type: ignore
# 
#     def wait(self, timeout: float = None, times: int = 1) -> None:
#         """Wait for ``timeout`` or ``self.wait_time``."""
#         loop = asyncio.get_event_loop()
#         for i in range(times):
#             loop.run_until_complete(asyncio.sleep(timeout or self.wait_time))
# 
#     def wait_until(self, func: Callable[[], Any],
#                    timeout: float = None) -> None:
#         """Wait until ``func`` returns True or exceeds timeout.
# 
#         ``func`` is called with no argument. Unit of ``timeout`` is second, and
#         its default value is RemoteBrowserTestCase.timeout class variable
#         (default: 1.0).
#         """
#         st = time.perf_counter()
#         timeout = timeout or self.timeout
#         while (time.perf_counter() - st) < timeout:
#             if func():
#                 return
#             self.wait()
#         raise TimeoutError('{} did not return True until timeout'.format(func))
# 
#     def send_keys(self, element: Element, keys: str) -> None:
#         """Send ``keys`` to ``element`` one-by-one.
# 
#         Safer than using ``element.send_keys`` method.
#         """
#         for k in keys:
#             element.send_keys(k)
# 
# def close_webdriver() -> None:
#     """Close WebDriver."""
#     global local_webdriver
#     if local_webdriver is not None:
#         local_webdriver.close()
#         local_webdriver = None


# Path: tests/test_selenium/test_examples.py
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.color import Color
from wdom.tag import H1
from wdom.document import get_document, set_app
from wdom.util import suppress_logging
from ..base import TestCase
from .base import WebDriverTestCase, close_webdriver
        from wdom.examples.data_binding import sample_app
        from wdom.examples.drag import sample_app
        from wdom.examples.global_events import sample_page, set_app
        from wdom.examples.rev_text import sample_app
        from wdom.examples.timer import sample_app

#!/usr/bin/env python3
# -*- coding: utf-8 -*-





def setUpModule():
    suppress_logging()


def tearDownModule():
    close_webdriver()


class SimpleTestCase(WebDriverTestCase, TestCase):
    def setUp(self):
        super().setUp()
        document = get_document()

        self.h1 = H1()