Files
flomo-ai/mumu-pytest/test_mumu.py

60 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
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()
def test_close_emulator(emulator):
"""测试关闭模拟器"""
time.sleep(3)
if emulator.is_running():
emulator.close()
assert not emulator.is_running(), "模拟器关闭失败"