Audit TW:WH3 second pass (#44)

* use keras funcs

* remove old code
This commit is contained in:
derek-hirotsu
2023-09-25 10:05:08 -07:00
committed by GitHub
parent 32764c4d7b
commit b087dcffae

View File

@@ -38,18 +38,6 @@ def start_game():
return os.system(cmd_string)
def await_logo_screens(attempts: int) -> bool:
"""Waits for logo screen"""
logging.info("looking for logo")
for _ in range(attempts):
result = kerasService.capture_screenshot_find_word("warning")
if result is not None:
return True
time.sleep(5)
return False
def skip_logo_screens() -> None:
"""Simulate input to skip logo screens"""
logging.info("Skipping logo screens")
@@ -71,127 +59,59 @@ def skip_logo_screens() -> None:
time.sleep(0.5)
def find_options(attempts: int) -> any:
"""Find options text"""
for _ in range(attempts):
result = kerasService.capture_screenshot_find_word("options")
if result is not None:
return (result["x"], result["y"])
time.sleep(1)
return None
def find_advanced(attempts: int) -> any:
"""Find advanced text"""
for _ in range(attempts):
result = kerasService.capture_screenshot_find_word("ad")
if result is not None:
return (result["x"], result["y"])
time.sleep(1)
return None
def find_benchmark(attempts: int) -> any:
"""Find benchmark options"""
for _ in range(attempts):
result = kerasService.capture_screenshot_find_word("bench")
if result is not None:
return (result["x"], result["y"])
time.sleep(1)
return None
def find_summary(attempts: int) -> bool:
"""Find benchmark results"""
for _ in range(attempts):
result = kerasService.capture_screenshot_find_word("summary")
if result is not None:
return True
time.sleep(5)
def await_benchmark_start(attempts: int, delay=5) -> bool:
"""Wait for benchmark to start"""
for _ in range(attempts):
result = kerasService.capture_screenshot_find_word("fps")
if result is not None:
return True
time.sleep(delay)
return None
def run_benchmark():
"""Starts the benchmark"""
start_game()
setup_start_time = time.time()
time.sleep(5)
logo_skip = await_logo_screens(10)
if not logo_skip:
logging.info("Did not warnings. Did the game start?")
result = kerasService.look_for_word("warning", attempts=10, interval=5)
if not result:
logging.info("Did not see warnings. Did the game start?")
sys.exit(1)
skip_logo_screens()
time.sleep(2)
options = find_options(10)
if not options:
logging.info(
"Did not find the options menu. Did the game skip the intros?")
result = kerasService.look_for_word("options", attempts=10, interval=1)
if not result:
logging.info("Did not find the options menu. Did the game skip the intros?")
sys.exit(1)
gui.moveTo(options[0], options[1])
gui.moveTo(result["x"], result["y"])
time.sleep(0.2)
gui.mouseDown()
time.sleep(0.2)
gui.mouseUp()
advanced = find_advanced(10)
if not advanced:
logging.info(
"Did not find the advanced menu. Did the game skip the intros?")
result = kerasService.look_for_word("ad", attempts=10, interval=1)
if not result:
logging.info("Did not find the advanced menu. Did the game skip the intros?")
sys.exit(1)
gui.moveTo(advanced[0], advanced[1])
gui.moveTo(result["x"], result["y"])
time.sleep(0.2)
gui.mouseDown()
time.sleep(0.2)
gui.mouseUp()
benchmark = find_benchmark(10)
if not benchmark:
logging.info(
"Did not find the benchmark menu. Did the game skip the intros?")
result = kerasService.look_for_word("bench", attempts=10, interval=1)
if not result:
logging.info("Did not find the benchmark menu. Did the game skip the intros?")
sys.exit(1)
gui.moveTo(benchmark[0], benchmark[1])
gui.moveTo(result["x"], result["y"])
time.sleep(0.2)
gui.mouseDown()
time.sleep(0.2)
gui.mouseUp()
time.sleep(2)
user.press("enter")
check_start = await_benchmark_start(5, 10)
loading_screen_start = time.time()
while True:
check_start = await_benchmark_start(2, 2)
if check_start:
break
if time.time()-loading_screen_start > 60:
logging.info("Benchmark didn't start.")
sys.exit(1)
logging.info("Benchmark hasn't started. Trying again in 10 seconds")
time.sleep(10)
result = kerasService.wait_for_word("fps", interval=5, timeout=100)
if not result:
logging.info("Benchmark didn't start.")
sys.exit(1)
elapsed_setup_time = round(time.time() - setup_start_time, 2)
logging.info("Setup took %f seconds", elapsed_setup_time)
@@ -199,9 +119,8 @@ def run_benchmark():
time.sleep(100) # Wait for benchmark
finish_benchmark = find_summary(250)
if not finish_benchmark:
result = kerasService.wait_for_word("fps", interval=5, timeout=250)
if not result:
logging.info(
"Results screen was not found! Did harness not wait long enough? Or test was too long?")
sys.exit(1)