feat: add airtest scripts for camera and gallery testing

This commit is contained in:
2026-03-01 23:17:55 +08:00
parent 3ee14eabe6
commit a7c6e6b909
10 changed files with 898 additions and 17 deletions

89
test_simple.py Normal file
View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*-
"""
Simple test to verify merge works
"""
from airtest.core.api import *
from PIL import Image
import numpy as np
def init_device():
dev = connect_device("android://127.0.0.1:5037/emulator-5554")
print(f"Device connected")
return dev
def capture_screen(filename="screen.png"):
screen = device().snapshot()
img = Image.fromarray(screen)
img.save(filename)
print(f"Screenshot: {filename}")
return screen
# Main
print("=" * 50)
print("Simple Merge Test")
print("=" * 50)
init_device()
sleep(2)
# Go to merge screen
touch([810, 2300]) # Puzzle tab
sleep(2)
capture_screen("step1_merge.png")
# Select 2x2
touch([180, 200])
sleep(1)
# Add images
touch([270, 500])
sleep(2)
# Select 4 images from gallery
touch([540, 800]) # Gallery tab in picker
sleep(1)
touch([200, 400]) # Image 1
sleep(0.5)
touch([540, 400]) # Image 2
sleep(0.5)
touch([880, 400]) # Image 3
sleep(0.5)
touch([200, 700]) # Image 4
sleep(0.5)
touch([900, 2300]) # Confirm
sleep(2)
capture_screen("step2_selected.png")
# Click preview
touch([300, 2200]) # Preview button
sleep(3)
capture_screen("step3_preview.png")
# Check preview result
img = Image.open("step3_preview.png")
img_array = np.array(img)
h, w = img_array.shape[:2]
center_region = img_array[h//4:3*h//4, w//4:3*w//4]
avg_color = np.mean(center_region, axis=(0, 1))
print(f"Preview average color: {avg_color}")
# Close preview
touch([540, 1500])
sleep(1)
# Save
touch([800, 2200]) # Save button
sleep(2)
touch([700, 1400]) # Confirm save
sleep(3)
capture_screen("step4_saved.png")
print("\n" + "=" * 50)
if avg_color[0] < 250 and avg_color[1] < 250 and avg_color[2] < 250:
print("RESULT: Merge works! Preview shows merged images.")
else:
print("RESULT: Merge may have issues.")
print("=" * 50)