Esempio n. 1
0
async def test_examples(native_app, path):
    example = path[:-6].replace("/", ".")  # Remove example/ and .enaml

    if "thermostat" in example:
        return pytest.skip("thermostat example needs updated")

    app = AndroidApplication(debug=True)
    with enaml.imports():
        try:
            ContentView = locate(f"{example}.ContentView")
        except ErrorDuringImport as e:
            msg = f"{e}"
            if iconify is None and "iconify" in msg:
                return pytest.skip("enaml-native-icons is not installed")
            if googlemaps is None and "googlemaps" in msg:
                return pytest.skip("enaml-native-maps is not installed")
            if charts is None and "charts" in msg:
                return pytest.skip("enaml-native-charts is not installed")
            raise

    app.activity = ExampleActivity(example=ContentView())
    f = nativehooks.shown = app.create_future()

    def on_error(event):
        f.set_exception(event["value"])

    app.observe("error_occurred", on_error)

    # f.add_done_callback(lambda f: app.stop())
    # Add fail timeout
    app.timed_call(5 * 1000, lambda: f.set_result(False))
    app.deferred_call(app.activity.start)
    assert await f
Esempio n. 2
0
def main():
    # Make sure instance is cleared
    from enaml.application import Application
    Application._instance = None

    from enamlnative.android.app import AndroidApplication
    app = AndroidApplication(
        debug=True,
        dev='remote',  # "10.0.2.2" # or 'server'
        load_view=load_view)
    app.timed_call(5000, run_gestures, app)
    app.start()