use wait_for_condition() on newly created material cache files and wait for them to exist before continuing to prevent race condition
Signed-off-by: jromnoa <jromnoa@amazon.com>
This commit is contained in:
+9
-2
@@ -33,6 +33,7 @@ MATERIAL_TYPE_PATH = os.path.join(
|
||||
azlmbr.paths.devroot, "Gems", "Atom", "Feature", "Common", "Assets",
|
||||
"Materials", "Types", "StandardPBR.materialtype",
|
||||
)
|
||||
CACHE_FILE_EXTENSION = ".azmaterial"
|
||||
|
||||
|
||||
def run():
|
||||
@@ -109,16 +110,22 @@ def run():
|
||||
expected_color_1 = math.Color(0.5, 0.5, 0.5, 1.0)
|
||||
material_editor.set_property(document_id, property_name, expected_color_1)
|
||||
target_path_1 = os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Materials", NEW_MATERIAL_1)
|
||||
cache_file_name_1 = os.path.splitext(NEW_MATERIAL_1) # Example output: ('test_material_1', '.material')
|
||||
cache_file_1 = f"{cache_file_name_1[0]}{CACHE_FILE_EXTENSION}"
|
||||
target_path_1_cache = os.path.join(azlmbr.paths.devassets, "Cache", "pc", "materials", cache_file_1)
|
||||
material_editor.save_document_as_copy(document_id, target_path_1)
|
||||
time.sleep(2.0)
|
||||
material_editor.wait_for_condition(lambda: os.path.exists(target_path_1_cache), 4.0)
|
||||
|
||||
# 8) Test Case: Saving as a Child Material
|
||||
# Assign new color to the material file save the document as child
|
||||
expected_color_2 = math.Color(0.75, 0.75, 0.75, 1.0)
|
||||
material_editor.set_property(document_id, property_name, expected_color_2)
|
||||
target_path_2 = os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Materials", NEW_MATERIAL_2)
|
||||
cache_file_name_2 = os.path.splitext(NEW_MATERIAL_1) # Example output: ('test_material_2', '.material')
|
||||
cache_file_2 = f"{cache_file_name_2[0]}{CACHE_FILE_EXTENSION}"
|
||||
target_path_2_cache = os.path.join(azlmbr.paths.devassets, "Cache", "pc", "materials", cache_file_2)
|
||||
material_editor.save_document_as_child(document_id, target_path_2)
|
||||
time.sleep(2.0)
|
||||
material_editor.wait_for_condition(lambda: os.path.exists(target_path_2_cache), 4.0)
|
||||
|
||||
# Close/Reopen documents
|
||||
material_editor.close_all_documents()
|
||||
|
||||
Reference in New Issue
Block a user