-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
197 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ venv/ | |
.buildozer/ | ||
.pytest_cache/ | ||
.tox/ | ||
htmlcov/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Android | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: docker pull kivy/buildozer | ||
- run: make docker/run/buildozer | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
path: bin/xcamera-*-armeabi-v7a-debug.apk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: PyPI release | ||
on: [push] | ||
|
||
jobs: | ||
pypi: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
config: | ||
- {setup_file: setup.py, secret_key: pypi_password_xcamera} | ||
- {setup_file: setup_meta.py, secret_key: pypi_password_kivy_garden_xcamera} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
- run: python -m pip install --user --upgrade setuptools wheel kivy | ||
- run: python setup.py sdist bdist_wheel | ||
- name: Publish package | ||
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') | ||
uses: pypa/[email protected] | ||
with: | ||
user: __token__ | ||
password: ${{ secrets[matrix.secret_key] }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Tests | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
DISPLAY: ':99.0' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: make docker/pull | ||
- run: make docker/build | ||
- run: | | ||
sudo apt install xvfb libxkbcommon-x11-0 | ||
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & | ||
- run: make docker/run/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Kivy==1.11.1 | ||
opencv-python==4.1.1.26 | ||
Kivy==2.0.0rc2 | ||
opencv-python==4.1.2.30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '2019.0928' | ||
__version__ = '2020.0613' |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from threading import Thread | ||
from time import sleep | ||
from unittest import mock | ||
|
||
from kivy.app import App | ||
from kivy.clock import Clock | ||
|
||
from kivy_garden.xcamera.main import CameraApp, main | ||
from tests.test_main import camera_release_workaround, patch_core_camera | ||
|
||
|
||
def patch_picture_taken(): | ||
return mock.patch('kivy_garden.xcamera.main.CameraApp.picture_taken') | ||
|
||
|
||
class TestMain: | ||
""" | ||
Tests the `main` module. | ||
""" | ||
|
||
def test_picture_taken(self): | ||
""" | ||
Checks the `picture_taken()` listener gets called on the running app. | ||
""" | ||
app_thread = Thread(target=main) | ||
app_thread.start() | ||
app = App.get_running_app() | ||
filename = mock.sentinel | ||
Clock.schedule_once( | ||
lambda dt: app.root.ids.xcamera.dispatch( | ||
'on_picture_taken', filename)) | ||
with patch_picture_taken() as m_picture_taken, patch_core_camera(): | ||
sleep(0.5) # FIXME: nondeterministic approach | ||
# makes sure app thread is gracefully stopped before asserting | ||
app.stop() | ||
app_thread.join() | ||
camera_release_workaround(app) | ||
assert type(app) == CameraApp | ||
assert m_picture_taken.mock_calls == [ | ||
mock.call(app.root.ids.xcamera, filename)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,52 @@ | ||
import os | ||
from threading import Thread | ||
from unittest import mock | ||
|
||
from kivy.app import App | ||
|
||
from kivy_garden.xcamera.main import CameraApp | ||
from main import main | ||
|
||
|
||
def camera_release_workaround(app): | ||
""" | ||
Upstream bug workaround, refs: | ||
https://github.com/kivy-garden/xcamera/issues/14 | ||
""" | ||
app.root.ids.xcamera._camera._device.release() | ||
|
||
|
||
def get_camera_class(): | ||
""" | ||
Continuous integration providers don't have a camera available. | ||
""" | ||
if os.environ.get('CI', False): | ||
Camera = None | ||
else: | ||
from kivy.core.camera import Camera | ||
return Camera | ||
|
||
|
||
def patch_core_camera(): | ||
Camera = get_camera_class() | ||
return mock.patch('kivy.uix.camera.CoreCamera', wraps=Camera) | ||
|
||
|
||
class TestMain: | ||
""" | ||
Tests the `main` module. | ||
""" | ||
|
||
def test_main(self): | ||
with mock.patch('kivy_garden.xcamera.main.CameraApp.run') as m_play: | ||
main() | ||
assert m_play.mock_calls == [mock.call()] | ||
""" | ||
Checks the main starts the app properly. | ||
""" | ||
app_thread = Thread(target=main) | ||
app_thread.start() | ||
app = App.get_running_app() | ||
# makes sure app thread is gracefully stopped before asserting | ||
app.stop() | ||
with patch_core_camera(): | ||
app_thread.join() | ||
camera_release_workaround(app) | ||
assert type(app) == CameraApp |
Oops, something went wrong.