diff --git a/.env b/.env new file mode 100644 index 0000000000000000000000000000000000000000..59e96ba1f1620e15c08c736db5827ef1ae058221 --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +PIPENV_VENV_IN_PROJECT=true +PIPENV_PYPI_MIRROR=https://pypi.tuna.tsinghua.edu.cn/simple +PIPENV_QUIET=true +PIPENV_DEFAULT_PYTHON_VERSION=3 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a9d4f071e14a06ac169a48d18334fa8fb6b97497 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.idea +.vscode +__pycache__ +Pipfile +Pipfile.lock +report diff --git a/README.md b/README.md index d0213edaeb57ca4b476f804182b74221a01e30a7..e2d3c2af1d1727f7190c0f53dbeca6149c609de9 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,29 @@ -# dde_autotest_euler +# ${app_name} -#### 介绍 -dde autotest case for openEuler +## 环境部署 -#### 软件架构 -软件架构说明 +```bash +pip3 install youqu3 +youqu3 envx +``` -#### 安装教程 +## Ruff -1. xxxx -2. xxxx -3. xxxx +## 安装 Ruff -#### 使用说明 +```bash +pip3 install ruff +``` -1. xxxx -2. xxxx -3. xxxx +### 代码检查 -#### 参与贡献 +```bash +ruff check . +``` -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +### 代码格式化 - -#### 特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +```bash +ruff format . +``` \ No newline at end of file diff --git a/case/__init__.py b/case/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/case/assert_res/README.md b/case/assert_res/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5f38070e41c2a7d59591725a5b5236def8d6262b --- /dev/null +++ b/case/assert_res/README.md @@ -0,0 +1,3 @@ +# assert_res + +用例断言资源 \ No newline at end of file diff --git a/case/assert_res/all_categories_in_launcher.png b/case/assert_res/all_categories_in_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..42d2e72cf5db2500418acacc062cf31f0058d874 Binary files /dev/null and b/case/assert_res/all_categories_in_launcher.png differ diff --git a/case/assert_res/deepin_manager_cn.png b/case/assert_res/deepin_manager_cn.png new file mode 100644 index 0000000000000000000000000000000000000000..d45f79b244c873eca5ec5b40c2e5e2583de0a61e Binary files /dev/null and b/case/assert_res/deepin_manager_cn.png differ diff --git a/case/assert_res/firefox_icon_in_window.png b/case/assert_res/firefox_icon_in_window.png new file mode 100644 index 0000000000000000000000000000000000000000..8b407dfce5c1c1af72129fb7089859a3135f2e51 Binary files /dev/null and b/case/assert_res/firefox_icon_in_window.png differ diff --git a/case/assert_res/keyboard_layout_hanyu.png b/case/assert_res/keyboard_layout_hanyu.png new file mode 100644 index 0000000000000000000000000000000000000000..f85167fdd5a60a4bec9ff9f1b14c12a38d83d326 Binary files /dev/null and b/case/assert_res/keyboard_layout_hanyu.png differ diff --git a/case/assert_res/launcher_window.png b/case/assert_res/launcher_window.png new file mode 100644 index 0000000000000000000000000000000000000000..ab45afc2c4760593ec967fba985a56e2361f370a Binary files /dev/null and b/case/assert_res/launcher_window.png differ diff --git a/case/base_case.py b/case/base_case.py new file mode 100644 index 0000000000000000000000000000000000000000..57b425641da7d3416ad1046c990993e24798178f --- /dev/null +++ b/case/base_case.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# _*_ coding:utf-8 _*_ +""" +:Author:uos +:Date :2024/08/22 13:15:47 +""" + +from method.assert_method import AssertMethod + + +class BaseCase(AssertMethod): + """用例基类""" diff --git a/case/test_mycase_001.py b/case/test_mycase_001.py new file mode 100644 index 0000000000000000000000000000000000000000..462ea6c6ab9c7cfc97aa491ba561759c2d99eaa3 --- /dev/null +++ b/case/test_mycase_001.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# _*_ coding:utf-8 _*_ +""" +:Author:uos +:Date :2024/08/27 13:42:04 +""" +from case.base_case import BaseCase +from method.dde_autotest_euler_method import DdeAutotestEulerMethod + +class TestMyCase(BaseCase): + + def test_mycase_001(self): + """this is my test case title""" + # 用例步骤,调用方法层封装好的方法进行操作 + DdeAutotestEulerMethod().click_dde_file_manager_on_dock_by_attr() + # 在关键节点进行断言 + self.assert_true(True) diff --git a/case/test_mycase_002.py b/case/test_mycase_002.py new file mode 100644 index 0000000000000000000000000000000000000000..7f7b0472143f2c5933556f428751cedfc2addd5b --- /dev/null +++ b/case/test_mycase_002.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# _*_ coding:utf-8 _*_ +""" +:Author:uos +:Date :2024/08/27 13:42:04 +""" +from case.base_case import BaseCase +from youqu3 import sleep +from youqu3.gui import pylinuxauto + +class TestMyCase(BaseCase): + + def test_mycase_002(self, check): + """快捷键 ctrl + alt + t 启动终端""" + # 用例步骤,调用方法层封装好的方法进行操作 + pylinuxauto.ctrl_alt_t() + # 在关键节点进行断言 + # 等待 2 秒,判断终端是否启动 + sleep(2) + check.asset_true(True) diff --git a/config.py b/config.py new file mode 100644 index 0000000000000000000000000000000000000000..5b8744b642e5560d7896cf502afdfd70bef5e756 --- /dev/null +++ b/config.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# _*_ coding:utf-8 _*_ +""" +:Author:uos +:Date :2024/08/22 13:15:47 +""" + +import pathlib +import os + + +class _Config: + ROOTDIR = pathlib.Path(__file__).parent + ASSERT_RES = ROOTDIR / "case/assert_res" + IMAGE_RES = ROOTDIR / "method/image_res" + STATIC_RES = ROOTDIR / "method/static_res" + BASE_PATH = os.getcwd() + + +config = _Config() diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..a0b0c1ad2ba6d15baa932e62d4838761682d3f8f --- /dev/null +++ b/conftest.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# _*_ coding:utf-8 _*_ +""" +:Author:uos +:Date :2024/08/22 13:15:47 +""" + +import pytest + +# fixtures diff --git a/env.sh b/env.sh new file mode 100644 index 0000000000000000000000000000000000000000..77deca01b10b674ae3c3721358ff35103302f3ce --- /dev/null +++ b/env.sh @@ -0,0 +1,7 @@ +python3-pyatspi + +pyscreenshot + + +python3-pillow +xdotool \ No newline at end of file diff --git a/method/__init__.py b/method/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/method/assert_method.py b/method/assert_method.py new file mode 100644 index 0000000000000000000000000000000000000000..a7f221c10ea5445312af428d40753d349df5dc1f --- /dev/null +++ b/method/assert_method.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# _*_ coding:utf-8 _*_ +""" +:Author:uos +:Date :2024/08/22 13:15:47 +""" + +from dbus.decorators import method +from youqu3.assertx import Assert +from config import config + + +class AssertMethod(Assert): + """AssertMethod""" + + @classmethod + def assert_image_exist_in_dde(cls, img_name, rate=0.8): + cls.assert_image_exist(f"{config.ASSERT_RES}/{img_name}", rate=rate) + + @classmethod + def assert_image_not_exist_in_dde(cls, img_name, rate=0.8): + cls.assert_image_not_exist(f"{config.ASSERT_RES}/{img_name}", rate=rate) diff --git a/method/base_method.py b/method/base_method.py new file mode 100644 index 0000000000000000000000000000000000000000..568b87c2ea32c8f5077d914b2202b9e228c97756 --- /dev/null +++ b/method/base_method.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# _*_ coding:utf-8 _*_ +""" +:Author:uos +:Date :2024/08/22 13:15:47 +""" + + +class BaseMethod: + """应用的方法基类""" diff --git a/method/dde_autotest_euler_method.py b/method/dde_autotest_euler_method.py new file mode 100644 index 0000000000000000000000000000000000000000..7cd0907d5ae76dd082aca9884547311f20a67192 --- /dev/null +++ b/method/dde_autotest_euler_method.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +# _*_ coding:utf-8 _*_ +""" +:Author:uos +:Date :2024/08/22 13:15:47 +""" + +from time import sleep + +from dnf.yum.misc import import_key_to_pubring +from funnylog2.config import config as funnylog2_config + +funnylog2_config.CLASS_NAME_ENDSWITH = ["Method"] + +from youqu3 import log +from youqu3.gui import pylinuxauto +from config import config +from method.base_method import BaseMethod + + +@log +class DdeMethod(BaseMethod): + """应用方法主类""" + + def dde_method_click_dde_file_manager_on_dock_by_attr(self): + """在任务栏点击文件管理器""" + pylinuxauto.find_element_by_attr_path("/dde-dock/Btn_文件管理器").click() + + def dde_method_click_by_ocr(self, text): + pylinuxauto.find_element_by_ocr(text).click() + + def dde_method_click_by_attr(self, PATH): + pylinuxauto.find_element_by_attr_path(PATH).click() + + def dde_method_click_by_img(self, img_name): + pylinuxauto.find_element_by_image(f"{config.IMAGE_RES}/{img_name}").click() + + def dde_method_click_launcher_on_dock_by_attr(self): + DdeMethod().dde_method_click_by_attr( + "/dde-dock/Form_mainwindow/Btn_mainpanelcontrol/Form_fixedarea/Btn_launcheritem" + ) + + def dde_method_search_software_in_dock(self): + DdeMethod().dde_method_click_launcher_on_dock_by_attr() + DdeMethod().dde_method_click_by_attr( + "/dde-launcher/Form_windowedframe/Form_rightwidget/Form_searcheredit/Editable_dlineeditchildlineedit" + ) + + def dde_method_click_all_categories_in_launcher(self): + DdeMethod().dde_method_click_launcher_on_dock_by_attr() + DdeMethod().dde_method_click_by_attr( + "/dde-launcher/Form_windowedframe/Form_rightwidget/Btn_switchbtn/AllIcon" + ) + + def dde_method_click_back_in_all_categories_view(self): + DdeMethod().dde_method_click_by_attr( + "/dde-launcher/Form_windowedframe/Form_rightwidget/Btn_switchbtn/AllIcon" + ) + + def dde_method_click_system_manager_in_all_categories_view(self): + DdeMethod().dde_method_click_by_img("system_manager_in_all_categories_view.png") + + def dde_method_open_control_center_by_dock(self): + pylinuxauto.find_element_by_attr_path("/dde-dock/Btn_控制中心").click() + + def dde_method_click_keyboard_and_language_in_control_center(self): + pylinuxauto.find_element_by_attr_path( + "/dde-control-center/DMainWindow/contentwindow/键盘和语言" + ).click() + + def dde_method_click_keyboard_layout_in_control_center(self): + DdeMethod().dde_method_click_by_attr( + "/dde-control-center/DMainWindow/contentwindow/Form_modulepage/Form_keyboardwidget/List_keyboardlist/键盘布局" + ) + + def dde_method_close_control_center_by_window(self): + DdeMethod().dde_method_click_by_img("close_window_btn.png") + + def dde_method_add_keyboard_layout_in_control_center(self): + DdeMethod().dde_method_open_control_center_by_dock() + sleep(3) + DdeMethod().dde_method_click_keyboard_and_language_in_control_center() + DdeMethod().dde_method_click_keyboard_layout_in_control_center() + DdeMethod().dde_method_click_by_attr( + "/dde-control-center/DMainWindow/contentwindow/Form_modulepage/Form_kblayoutsettingwidget/Btn_addlayout" + ) + DdeMethod().dde_method_click_by_attr( + "/dde-control-center/DMainWindow/contentwindow/Form_modulepage/ContentWidget_contentArea/TranslucentFrame/List_keyboardmenulist/汉语" + ) + DdeMethod().dde_method_click_by_attr( + "/dde-control-center/DMainWindow/contentwindow/Form_modulepage/ContentWidget_contentArea/ButtonTuple/Btn_添加" + ) + + + + +if __name__ == "__main__": + sleep(3) + DdeMethod().dde_method_close_control_center_by_window() \ No newline at end of file diff --git a/method/image_res/README.md b/method/image_res/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5239ba22933f0a065778090df287377638efc3f2 --- /dev/null +++ b/method/image_res/README.md @@ -0,0 +1,3 @@ +# image_res + +用于图像识别定位的图片资源 \ No newline at end of file diff --git a/method/image_res/close_window_btn.png b/method/image_res/close_window_btn.png new file mode 100644 index 0000000000000000000000000000000000000000..fd0dc5fe7e2499cca7b31c347d0d750f404d1b8a Binary files /dev/null and b/method/image_res/close_window_btn.png differ diff --git a/method/image_res/delete_keyboard_layout_icon.png b/method/image_res/delete_keyboard_layout_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ed7c7ae9e36104cf3902d83841846fad365ca659 Binary files /dev/null and b/method/image_res/delete_keyboard_layout_icon.png differ diff --git a/method/static_res/README.md b/method/static_res/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b95a396a7043684f0cab3b62df175f467d9c13ab --- /dev/null +++ b/method/static_res/README.md @@ -0,0 +1,3 @@ +# static_res + +用例执行需要用到的测试资源 \ No newline at end of file diff --git a/method/ui.ini b/method/ui.ini new file mode 100644 index 0000000000000000000000000000000000000000..d4ba15345bd3cde3ba9414501ac97b0a066aad03 --- /dev/null +++ b/method/ui.ini @@ -0,0 +1,14 @@ +[播放按钮] +direction = left_bottom +location = 0, 0, 0, 0 + +# section 是你根据对应的元素按钮命名,你可以任意命名,但最好有具体含义,且能明确表示这个元素按钮的名称; + +# direction 是配置该元素的参考系,分别为: +# left_top 左上 +# left_bottom 左下 +# right_top 右上 +# right_bottom 右下 + +# location 是该元素按钮的相对与参考系的x, y的距离,及大小(w, h),这四个数据可以通过 UI 设计图上 +# 获取数据,在编辑模式下,点击 UI 图上的按钮,右侧就会出现该元素按钮的x, y, w, h数据。 diff --git a/mycase.csv b/mycase.csv new file mode 100644 index 0000000000000000000000000000000000000000..6ecae0bcd250e2e1d43c47b74481eab2b085be86 --- /dev/null +++ b/mycase.csv @@ -0,0 +1,3 @@ +脚本ID,跳过原因,确认修复,废弃用例 +test_euler_104633, +002, diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000000000000000000000000000000000000..fb208449f1a41c4a8596db0a582b4e63b1453b72 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,18 @@ +[pytest] +addopts = + -s + --no-header + --verbosity=2 + --show-capture=no + --reruns-delay=1 + --color=auto + --code-highlight=yes + --tb=auto + -r fEs + --continue-on-collection-errors +filterwarnings = + ignore + ignore::UserWarning + ignore:.*U.*mode is deprecated:DeprecationWarning + +console_output_style = count diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..1d57132a3f99e4ade87e1e90c0603fb213eccab5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +-i https://pypi.tuna.tsinghua.edu.cn/simple + +youqu3[gui] \ No newline at end of file diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000000000000000000000000000000000000..d1a61defe9e94a00e7fdb59ec15cf2fe4ce7ef7f --- /dev/null +++ b/ruff.toml @@ -0,0 +1,90 @@ +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + ".idea", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. +line-length = 100 +indent-width = 4 + +# Assume Python 3.7 +target-version = "py37" + +[lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = [ + "E402", + "E711", + "E721", + "E722", + "E731", + "E712", + "F401", + "F403", + "F507", + "F541", + "F841", +] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" \ No newline at end of file