Skip to content

dev merge to main #14

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

Merged
merged 10 commits into from
Dec 6, 2021
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
25 changes: 13 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- checkout
# pip require package
- run:
command: pip install --user -r requirements.txt
name: pip requirements.txt
command: pip install --user -r dev_requirements.txt
name: pip dev_requirements.txt
# screen test
- run:
command: python ./circle_ci_test/unit_test/screen/screen_test.py
Expand Down Expand Up @@ -47,16 +47,6 @@ jobs:
- run:
command: python ./circle_ci_test/unit_test/exception/test_auto_control_exception.py
name: test_auto_control_exception
# image detect
- run:
command: python ./circle_ci_test/unit_test/image/locate_all_image_test.py
name: locate_all_image_test
- run:
command: python ./circle_ci_test/unit_test/image/locate_and_click_test.py
name: locate_and_click_test
- run:
command: python ./circle_ci_test/unit_test/image/locate_image_center_test.py
name: locate_image_center_test
# critical exit
- run:
command: python ./circle_ci_test/unit_test/critical_exit/critical_exit_test.py
Expand All @@ -80,6 +70,17 @@ jobs:
- run:
command: python ./circle_ci_test/unit_test/timeout/timeout_test.py
name: timeout_test
# GUI Test
# image detect
- run:
command: python ./circle_ci_test/gui_test/image/locate_all_image_test.py
name: locate_all_image_test
- run:
command: python ./circle_ci_test/gui_test/image/locate_and_click_test.py
name: locate_and_click_test
- run:
command: python ./circle_ci_test/gui_test/image/locate_image_center_test.py
name: locate_image_center_test

workflows:
main:
Expand Down
113 changes: 63 additions & 50 deletions .idea/workspace.xml

Large diffs are not rendered by default.

124 changes: 124 additions & 0 deletions circle_ci_test/gui_test/calculator/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import os
import subprocess
from time import sleep

from je_auto_control import locate_and_click

subprocess.Popen("calc", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=True)
sleep(3)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/1.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/plus.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)

locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/5.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)

locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/equal.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/plus.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/2.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/plus.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/3.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/plus.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/4.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/plus.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/6.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/plus.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/7.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/plus.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/8.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/plus.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/9.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
locate_and_click(
os.getcwd() + "/circle_ci_test/test_source/equal.png",
mouse_keycode="mouse_left",
detect_threshold=0.9,
draw_image=False
)
Binary file added circle_ci_test/test_source/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/equal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/minus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/multiply.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle_ci_test/test_source/plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlCantFindKeyException
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlKeyboardException
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlMouseException
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlScreenException
from je_auto_control.utils.je_auto_control_exception.exceptions import ImageNotFoundException
from je_auto_control.utils.exception.exceptions import AutoControlCantFindKeyException
from je_auto_control.utils.exception.exceptions import AutoControlException
from je_auto_control.utils.exception.exceptions import AutoControlKeyboardException
from je_auto_control.utils.exception.exceptions import AutoControlMouseException
from je_auto_control.utils.exception.exceptions import AutoControlScreenException
from je_auto_control.utils.exception.exceptions import ImageNotFoundException

exception_list = [
AutoControlException,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from je_auto_control.utils.je_auto_control_exception.exceptions import ImageNotFoundException
from je_auto_control.utils.exception.exceptions import ImageNotFoundException

raise ImageNotFoundException("test.png")
2 changes: 1 addition & 1 deletion circle_ci_test/unit_test/keyboard/hotkey_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from je_auto_control import hotkey

if sys.platform in ["win32", "cygwin", "msys"]:
hotkey(["lcontrol", "a"])
hotkey_event = hotkey(["lcontrol", "a"])
hotkey(["lcontrol", "c"])
hotkey(["lcontrol", "v"])
hotkey(["lcontrol", "v"])
Expand Down
13 changes: 7 additions & 6 deletions circle_ci_test/unit_test/keyboard/keyboard_is_press_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from je_auto_control import check_key_is_press
from je_auto_control import press_key
from je_auto_control import release_key
from je_auto_control import AutoControlException

try:
"""
Expand All @@ -24,18 +25,18 @@
if check_key_is_press(0x60):
sys.exit(0)
elif sys.platform in ["linux", "linux2"]:
press_key("backspace")
press_key("a")
"""
linux key backspace
linux key a
"""
if check_key_is_press(22):
if check_key_is_press(0):
sys.exit(0)
except Exception:
raise Exception
except AutoControlException:
raise AutoControlException
finally:
if sys.platform in ["win32", "cygwin", "msys"]:
release_key("A")
elif sys.platform in ["darwin"]:
release_key("f5")
elif sys.platform in ["linux", "linux2"]:
release_key("backspace")
release_key("a")
42 changes: 19 additions & 23 deletions circle_ci_test/unit_test/keyboard/keyboard_type_test.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
import time
import sys

from je_auto_control import type_key
from je_auto_control import keys_table
from je_auto_control import type_key
from je_auto_control import press_key
from je_auto_control import release_key
from je_auto_control import AutoControlKeyboardException

"""
check keys
"""
print(keys_table.keys())
"""
Linux in every type and press then release need stop 0.01 time in my computer,i'm not sure it's right?
assert (type_key("T") == "T")
assert (type_key("E") == "E")
assert (type_key("S") == "S")
assert (type_key("T") == "T")

example:
type("T")
time.sleep(0.01)
type("E")
time.sleep(0.01)
type("S")
time.sleep(0.01)
type("T")
time.sleep(0.01)

or:
press_key("T")
release_key("T")
time.sleep(0.01)
"""
try:
type_key("dwadawddwadaw")
except AutoControlKeyboardException as error:
print(repr(error), file=sys.stderr)
# no error system will catch it but may make some system error
# you can try to reconnect usb
type_key(-1)
type_key(18919819819165161616161651651651651231231)
press_key(1616516516516516516515)
release_key(15616516516511)

type_key("T")
type_key("E")
type_key("S")
type_key("T")
4 changes: 4 additions & 0 deletions circle_ci_test/unit_test/keyboard/keyboard_write_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@
assert (write("Ѓ123456789") == "123456789")
except AutoControlKeyboardException as error:
print(repr(error), file=sys.stderr)
try:
write("!#@L@#{@#PL#{!@#L{!#{|##PO}!@#O@!O#P!)KI#O_!K")
except AutoControlKeyboardException as error:
print(repr(error), file=sys.stderr)

26 changes: 26 additions & 0 deletions circle_ci_test/unit_test/mouse/mouse_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import time

from je_auto_control import position
Expand All @@ -6,6 +7,7 @@
from je_auto_control import release_mouse
from je_auto_control import click_mouse
from je_auto_control import mouse_table
from je_auto_control import AutoControlMouseException

time.sleep(1)

Expand All @@ -19,3 +21,27 @@
press_mouse("mouse_left")
release_mouse("mouse_left")
click_mouse("mouse_left")
try:
set_position(6468684648, 4686468648864684684)
except AutoControlMouseException as error:
print(repr(error), file=sys.stderr)
try:
click_mouse("dawdawddadaawd")
except AutoControlMouseException as error:
print(repr(error), file=sys.stderr)
try:
press_mouse("dawdawdawdawd")
except AutoControlMouseException as error:
print(repr(error), file=sys.stderr)
try:
release_mouse("dwadawdadwdada")
except AutoControlMouseException as error:
print(repr(error), file=sys.stderr)
try:
press_mouse(16515588646)
except AutoControlMouseException as error:
print(repr(error), file=sys.stderr)
try:
release_mouse(1651651915)
except AutoControlMouseException as error:
print(repr(error), file=sys.stderr)
17 changes: 11 additions & 6 deletions circle_ci_test/unit_test/record/record_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
from je_auto_control import record
from je_auto_control import stop_record
from je_auto_control import type_key
from je_auto_control import execute_action

"""
this program will type test two time
one time is type key one time is record
"""
record()
type_key("t")
type_key("e")
type_key("s")
type_key("t")
sleep(1)
stop_record()
sleep(1)
print(type_key("t"))
print(type_key("e"))
print(type_key("s"))
print(type_key("t"))
sleep(2)
record_result = stop_record()
print(record_result)
execute_action(record_result)
sleep(2)
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
je_auto_control
je_auto_control_dev
pillow
wheel
twine
Expand Down
Loading