-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from eficode/feature/tests
Fixes tests, sets up CI
- Loading branch information
Showing
42 changed files
with
317 additions
and
142 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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Tests (Python 3.x) | ||
|
||
on: | ||
push: | ||
paths: | ||
- '.github/workflows/**' | ||
- 'src/**' | ||
- 'tests/**' | ||
- 'setup.py' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/**' | ||
- 'src/**' | ||
- 'tests/**' | ||
- 'setup.py' | ||
jobs: | ||
test_using_builtin_python: | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ 'ubuntu-latest', 'windows-latest' ] | ||
python-version: [ '3.6', '3.7', '3.8' ] | ||
include: | ||
- os: ubuntu-latest | ||
set_display: export DISPLAY=:99; Xvfb :99 -screen 0 1024x768x24 -ac -noreset & sleep 3 | ||
#- os: macos-latest | ||
#set_tmpdir: export TMPDIR=/tmp | ||
- os: windows-latest | ||
set_codepage: chcp 850 | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup python ${{ matrix.python-version }} for running the tests | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
architecture: 'x64' | ||
|
||
# pyautogui does not work by default (https://github.com/asweigart/pyautogui/issues/247) | ||
# need to disable security feature (https://apple.stackexchange.com/questions/178313/change-accessibility-setting-on-mac-using-terminal) | ||
# and database is readonly (https://github.com/jacobsalmela/tccutil/issues/18) | ||
# you need to disable SIP, but for that go into recovery mode and disable it - not on CI system | ||
#- name: Install test tools to Mac | ||
#run: | | ||
#sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'UPDATE access SET allowed = "1";' | ||
#if: runner.os == 'macOS' | ||
|
||
- name: Install test tools to Linux | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get -y -q install xvfb scrot chromium-browser | ||
touch ~/.Xauthority | ||
if: contains(matrix.os, 'ubuntu') | ||
|
||
- name: Install python test dependencies | ||
run: | | ||
python --version | ||
python -m pip install mock robotframework opencv-python eel . | ||
- name: Run tests | ||
run: | | ||
${{ matrix.set_codepage }} | ||
${{ matrix.set_display }} | ||
python tests/utest/run_tests.py | ||
python tests/atest/run_tests.py | ||
- name: Archive acceptances test results | ||
uses: actions/[email protected] | ||
with: | ||
name: log-${{ matrix.python-version }}-${{ matrix.os }} | ||
path: log.html | ||
if: always() && job.status == 'failure' | ||
|
||
- name: Archive acceptances test failure screenshot on Linux | ||
uses: actions/[email protected] | ||
with: | ||
name: screenshot-${{ matrix.python-version }}-${{ matrix.os }} | ||
path: /tmp/Atest.Calculator-screenshot-1.png | ||
if: always() && job.status == 'failure' && contains(matrix.os, 'ubuntu') |
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 |
---|---|---|
|
@@ -6,4 +6,7 @@ log.html | |
*-screenshot-*.png | ||
*\$py.class | ||
*.swp | ||
*__pycache__ | ||
*__pycache__ | ||
/bin | ||
/include | ||
/lib |
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
*** Settings *** | ||
Library ImageHorizonLibrary ${CURDIR}${/}reference_images${/}calculator screenshot_folder=${TEMPDIR} | ||
|
||
*** Test cases *** | ||
|
||
Calculator | ||
Set Confidence 0.9 | ||
Launch application python tests/atest/calculator/calculator.py | ||
${location1}= Wait for inputs.png timeout=30 | ||
Click to the above of ${location1} 20 | ||
Type 1010 | ||
Click to the below of ${location1} 20 | ||
Type 1001 | ||
${location2}= Locate or_button.png | ||
Click to the below of ${location2} 0 | ||
Click to the below of ${location2} 50 | ||
${result}= Copy | ||
Should be equal as integers ${result} 1011 | ||
Click Image close_button.png | ||
[Teardown] Terminate application |
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 @@ | ||
import eel | ||
import os | ||
import sys | ||
|
||
|
||
os.chdir(os.path.dirname(__file__)) | ||
|
||
eel.init('web') | ||
|
||
|
||
@eel.expose | ||
def close(): | ||
sys.exit(0) | ||
|
||
|
||
eel.start('main.html', size=(300, 380)) |
Binary file not shown.
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,191 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Bitwise Calculator</title> | ||
|
||
<style> | ||
@font-face { | ||
font-family: Roboto; | ||
src: url('Roboto-Black.ttf') format('truetype'); | ||
} | ||
|
||
body { | ||
font-family: Roboto; | ||
font-size: 18px; | ||
} | ||
|
||
.clickable { | ||
user-select: none; | ||
cursor: pointer; | ||
} | ||
|
||
.button { | ||
background-color: black; | ||
color: white; | ||
padding: 10px 30px; | ||
margin: 10px; | ||
text-align: center; | ||
text-decoration: none; | ||
display: block; | ||
border: none; | ||
border-radius: 10px; | ||
} | ||
|
||
.button:active { | ||
background-color: gray; | ||
} | ||
|
||
.binary-input { | ||
border: 2px solid black; | ||
outline: none; | ||
} | ||
|
||
#first,#second { | ||
padding: 10px; | ||
} | ||
|
||
.check { | ||
color: gray; | ||
} | ||
|
||
.check[checked] { | ||
color: black; | ||
} | ||
|
||
#result { | ||
text-align: center; | ||
display: block; | ||
font-size: 24px; | ||
padding: 20px 0px; | ||
} | ||
</style> | ||
|
||
<script type="text/javascript" src="/eel.js"></script> | ||
<script type="text/javascript"> | ||
function setInputFilter(textbox, inputFilter) { | ||
["input", "keydown", "keyup", "mousedown", "mouseup", "select", "contextmenu", "drop"].forEach(function(event) { | ||
textbox.addEventListener(event, function() { | ||
if (inputFilter(this.value)) { | ||
this.oldValue = this.value; | ||
this.oldSelectionStart = this.selectionStart; | ||
this.oldSelectionEnd = this.selectionEnd; | ||
} else if (this.hasOwnProperty("oldValue")) { | ||
this.value = this.oldValue; | ||
this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd); | ||
} else { | ||
this.value = ""; | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function selectElementText(el, win) { | ||
win = win || window; | ||
var doc = win.document, sel, range; | ||
if (win.getSelection && doc.createRange) { | ||
sel = win.getSelection(); | ||
range = doc.createRange(); | ||
range.selectNodeContents(el); | ||
sel.removeAllRanges(); | ||
sel.addRange(range); | ||
} else if (doc.body.createTextRange) { | ||
range = doc.body.createTextRange(); | ||
range.moveToElementText(el); | ||
range.select(); | ||
} | ||
} | ||
|
||
function main() { | ||
let checks = document.querySelectorAll('.check'); | ||
checks.forEach(e => { | ||
e.addEventListener('click', event => { | ||
if (event.target.hasAttribute('checked')) { | ||
event.target.removeAttribute('checked'); | ||
} else { | ||
event.target.setAttribute('checked', 1); | ||
} | ||
}); | ||
}); | ||
|
||
let inputs = document.querySelectorAll('.binary-input'); | ||
inputs.forEach(e => { | ||
setInputFilter(e, function(value) { | ||
return /^[01]+$/.test(value); | ||
}); | ||
}); | ||
|
||
let close = document.querySelector('#close'); | ||
close.addEventListener('click', event => { | ||
eel.close(); | ||
window.close('','_parent',''); | ||
}); | ||
|
||
let result = document.querySelector('#result'); | ||
let resultArea = document.querySelector('#result-area'); | ||
resultArea.addEventListener('click', event => { | ||
selectElementText(result); | ||
}); | ||
|
||
let fnot = document.querySelector('#fnot'); | ||
let fnumber = document.querySelector('#fnumber'); | ||
let snot = document.querySelector('#snot'); | ||
let snumber = document.querySelector('#snumber'); | ||
|
||
let buttons = document.querySelectorAll('.button[operation]'); | ||
buttons.forEach(e => { | ||
e.addEventListener('click', event => { | ||
|
||
let fvalue = parseInt(fnumber.value, 2); | ||
if (fnot.hasAttribute('checked')) { | ||
fvalue = ~fvalue; | ||
} | ||
let svalue = parseInt(snumber.value, 2); | ||
if (snot.hasAttribute('checked')) { | ||
svalue = ~svalue; | ||
} | ||
|
||
let operation = event.target.getAttribute('operation'); | ||
|
||
switch (operation) { | ||
case 'and': | ||
res = fvalue & svalue; | ||
break; | ||
case 'or': | ||
res = fvalue | svalue; | ||
break; | ||
default: | ||
throw new Error('Unknown Operation'); | ||
} | ||
|
||
result.innerHTML = res.toString(2); | ||
}); | ||
}); | ||
}; | ||
|
||
setTimeout('main()'); | ||
</script> | ||
</head> | ||
|
||
|
||
<body> | ||
<div id="form"> | ||
<div id="first"> | ||
<label id="fnot" class="clickable check">NOT</label> | ||
<input type="text" id="fnumber" class="binary-input" /> | ||
</div> | ||
<div id="second"> | ||
<label id="snot" class="clickable check">NOT</label> | ||
<input type="text" id="snumber" class="binary-input" /> | ||
</div> | ||
|
||
<div> | ||
<label id="and" class="clickable button" operation="and">AND</label> | ||
<label id="or" class="clickable button" operation="or">OR</label> | ||
</div> | ||
</div> | ||
<div id="result-area"> | ||
<span id="result">N/A</span> | ||
</div> | ||
<label id="close" class="clickable button">Close</label> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.