Skip to content

Commit

Permalink
Merge pull request #2597 from dbnicholson/webview-testapp-jnius
Browse files Browse the repository at this point in the history
Fix webview testapp jnius usage
  • Loading branch information
AndreMiras authored May 20, 2022
2 parents 4d45f99 + d6321c2 commit eeea8a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
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

0 comments on commit eeea8a1

Please sign in to comment.