updating tests for screenshot using editor_test.py
Signed-off-by: Scott Murray <scottmur@amazon.com>
This commit is contained in:
@@ -82,12 +82,13 @@ def compare_screenshot_similarity(
|
||||
result = 'You must specify a screenshot_directory in order to create a zip archive.\n'
|
||||
|
||||
mean_similarity = compare_screenshots(test_screenshot, golden_image)
|
||||
print(f"MEAN_SIMILARITY = {mean_similarity}")
|
||||
if not mean_similarity > similarity_threshold:
|
||||
if create_zip_archive:
|
||||
create_screenshots_archive(screenshot_directory)
|
||||
result = (
|
||||
f"When comparing the test_screenshot: '{test_screenshot}' "
|
||||
f"to golden_image: '{golden_image}' the mean similarity of '{mean_similarity}' "
|
||||
f"to golden_image: '{golden_image}'.\nThe mean similarity of '{mean_similarity}' "
|
||||
f"was lower than the similarity threshold of '{similarity_threshold}'. ")
|
||||
|
||||
return result
|
||||
@@ -123,7 +124,9 @@ def initial_viewport_setup(screen_width=1280, screen_height=720):
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
general.set_viewport_size(screen_width, screen_height)
|
||||
general.idle_wait_frames(1)
|
||||
general.update_viewport()
|
||||
general.idle_wait_frames(1)
|
||||
|
||||
|
||||
def enter_exit_game_mode_take_screenshot(screenshot_name, enter_game_tuple, exit_game_tuple, timeout_in_seconds=4):
|
||||
@@ -137,13 +140,18 @@ def enter_exit_game_mode_take_screenshot(screenshot_name, enter_game_tuple, exit
|
||||
"""
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
from editor_python_test_tools.utils import TestHelper
|
||||
from editor_python_test_tools.utils import TestHelper, Report
|
||||
|
||||
from Atom.atom_utils.screenshot_utils import ScreenshotHelper
|
||||
|
||||
screenshot_helper = ScreenshotHelper(general.idle_wait_frames)
|
||||
TestHelper.enter_game_mode(enter_game_tuple)
|
||||
TestHelper.wait_for_condition(function=lambda: general.is_in_game_mode(), timeout_in_seconds=timeout_in_seconds)
|
||||
ScreenshotHelper(general.idle_wait_frames).capture_screenshot_blocking(screenshot_name)
|
||||
screenshot_helper.prepare_viewport_for_screenshot(1920, 1080)
|
||||
success_screenshot = TestHelper.wait_for_condition(
|
||||
function=lambda: screenshot_helper.capture_screenshot_blocking(screenshot_name),
|
||||
timeout_in_seconds=timeout_in_seconds)
|
||||
Report.result(("Screenshot taken", "Screenshot failed to be taken"), success_screenshot)
|
||||
TestHelper.exit_game_mode(exit_game_tuple)
|
||||
TestHelper.wait_for_condition(function=lambda: not general.is_in_game_mode(), timeout_in_seconds=timeout_in_seconds)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user