Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix webview testapp jnius usage #2597

Merged
merged 2 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions testapps/on_device_unit_tests/test_app/app_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def loadUrl():
print('asked to open url', args['url'])
activity = get_android_python_activity()
activity.loadUrl(args['url'])
return ('', 204)


@app.route('/vibrate')
Expand All @@ -122,7 +123,8 @@ def vibrate():
if 'time' not in args:
print('ERROR: asked to vibrate but without time argument')
print('asked to vibrate', args['time'])
return vibrate_with_pyjnius(int(float(args['time']) * 1000))
vibrate_with_pyjnius(int(float(args['time']) * 1000))
return ('', 204)


@app.route('/orientation')
Expand All @@ -135,4 +137,5 @@ def orientation():
print('ERROR: asked to orient but no dir specified')
return 'No direction specified '
direction = args['dir']
return set_device_orientation(direction)
set_device_orientation(direction)
return ('', 204)
13 changes: 9 additions & 4 deletions testapps/on_device_unit_tests/test_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,15 @@
app_flask.TESTS_TO_PERFORM = tests_to_perform

print('Current directory is ', realpath(curdir))
if realpath(curdir).startswith('/data'):
app_flask.app.run(debug=False)
else:
app_flask.app.run(debug=True)
flask_debug = not realpath(curdir).startswith('/data')

# Flask is run non-threaded since it tries to resolve app classes
# through pyjnius from request handlers. That doesn't work since the
# JNI ends up using the Java system class loader in new native
# threads.
#
# https://github.com/kivy/python-for-android/issues/2533
app_flask.app.run(threaded=False, debug=flask_debug)
else:
# we don't have kivy or flask in our
# requirements, so we run unittests in terminal
Expand Down