feat: add airtest scripts for camera and gallery testing
This commit is contained in:
63
test_gallery_thumbnail.py
Normal file
63
test_gallery_thumbnail.py
Normal file
@@ -0,0 +1,63 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Gallery Test - Test clicking thumbnail to view full image
|
||||
"""
|
||||
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
|
||||
|
||||
def calculate_similarity(img1_path, img2_path):
|
||||
img1 = np.array(Image.open(img1_path))
|
||||
img2 = np.array(Image.open(img2_path))
|
||||
diff = np.abs(img1.astype(float) - img2.astype(float)).mean()
|
||||
return diff
|
||||
|
||||
print("=" * 50)
|
||||
print("Gallery Test - Click Thumbnail to View Full Image")
|
||||
print("=" * 50)
|
||||
|
||||
init_device()
|
||||
sleep(2)
|
||||
|
||||
# Step 1: Open Gallery app
|
||||
print("Step 1: Open Gallery app")
|
||||
touch([270, 2300]) # Gallery tab
|
||||
sleep(3)
|
||||
capture_screen("gallery_home.png")
|
||||
|
||||
# Step 2: Verify thumbnails are displayed
|
||||
print("Step 2: Verify thumbnails are displayed")
|
||||
thumbnails_visible = exists(Template(r"tpl_thumbnail.png"))
|
||||
print(f"Thumbnails visible: {thumbnails_visible}")
|
||||
|
||||
# Step 3: Click on a thumbnail to view full image
|
||||
print("Step 3: Click on first thumbnail")
|
||||
touch([540, 600]) # First thumbnail position
|
||||
sleep(2)
|
||||
capture_screen("full_image.png")
|
||||
|
||||
# Step 4: Verify full image viewer opened
|
||||
print("Step 4: Verify full image viewer opened")
|
||||
diff = calculate_similarity("gallery_home.png", "full_image.png")
|
||||
print(f"Screen difference: {diff:.2f}")
|
||||
|
||||
# Step 5: Test result
|
||||
print("=" * 50)
|
||||
if diff > 50:
|
||||
print("PASS: Clicking thumbnail opens full image viewer")
|
||||
else:
|
||||
print("FAIL: Clicking thumbnail does NOT open full image")
|
||||
print(" (This is a BUG - thumbnail click is not working)")
|
||||
print("=" * 50)
|
||||
Reference in New Issue
Block a user