将test_mumu.py中的卸载测试移至单独的test_uninstall.py文件 在卸载测试中添加模拟器关闭操作 移除test_mumu.py中冗余的关闭模拟器测试
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
"""
|
||
Mumu模拟器测试
|
||
"""
|
||
|
||
import pytest
|
||
import pyautogui
|
||
import os
|
||
import time
|
||
|
||
|
||
def test_start_emulator_sequence(emulator):
|
||
"""测试模拟器启动和操作序列"""
|
||
time.sleep(3)
|
||
emulator.start()
|
||
time.sleep(3)
|
||
|
||
script_dir = os.path.dirname(__file__)
|
||
start_image_path = os.path.join(script_dir, "start.png")
|
||
|
||
if not os.path.exists(start_image_path):
|
||
pytest.fail(f"start.png 图片文件不存在: {start_image_path}")
|
||
|
||
print("正在查找 start.png 图片...")
|
||
location = None
|
||
for _ in range(10):
|
||
try:
|
||
location = pyautogui.locateOnScreen(start_image_path, confidence=0.8)
|
||
if location:
|
||
break
|
||
except Exception:
|
||
pass
|
||
time.sleep(1)
|
||
|
||
if not location:
|
||
print("未找到 start.png,退出 pytest")
|
||
pytest.exit("未在屏幕上找到 start.png 图片,测试终止")
|
||
|
||
center = pyautogui.center(location)
|
||
pyautogui.click(center)
|
||
print(f"已点击 start.png,位置: {center}")
|
||
|
||
assert emulator.is_running(), "模拟器启动失败"
|
||
|
||
|
||
def test_run_sequence(emulator):
|
||
"""测试按顺序执行任务"""
|
||
time.sleep(3)
|
||
if not emulator.is_running():
|
||
pytest.skip("模拟器未运行")
|
||
|
||
emulator.run_sequence()
|