58 lines
1.4 KiB
Python
58 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Gallery Test - Test if clicking thumbnail opens 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
|
|
|
|
# Main
|
|
print("=" * 50)
|
|
print("Gallery Test - Click Thumbnail")
|
|
print("=" * 50)
|
|
|
|
init_device()
|
|
sleep(2)
|
|
|
|
# Go to gallery tab
|
|
touch([270, 2300]) # Gallery tab
|
|
sleep(3)
|
|
capture_screen("gallery1_main.png")
|
|
|
|
# Click on first thumbnail (latest image)
|
|
touch([540, 600])
|
|
sleep(2)
|
|
capture_screen("gallery2_after_click.png")
|
|
|
|
# Check if screen changed (full image viewer opened)
|
|
# Compare two screenshots
|
|
img1 = np.array(Image.open("gallery1_main.png"))
|
|
img2 = np.array(Image.open("gallery2_after_click.png"))
|
|
|
|
# Calculate similarity
|
|
diff = np.abs(img1.astype(float) - img2.astype(float)).mean()
|
|
print(f"Screen difference: {diff:.2f}")
|
|
|
|
# Check if there's any UI change
|
|
# If diff > 50, it means screen changed significantly
|
|
if diff > 50:
|
|
print("RESULT: Screen changed after clicking thumbnail")
|
|
print(" (Full image viewer may have opened)")
|
|
else:
|
|
print("RESULT: Screen did NOT change after clicking thumbnail")
|
|
print(" (Click is NOT working - BUG!)")
|
|
|
|
print("=" * 50)
|