diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py index 0be220cad0..466cd610e4 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py @@ -114,11 +114,8 @@ class TestDynamicSliceInstanceSpawner(EditorTestHelper): # This should result in 400 instances, since our box is 16 m x 16 m and by default the veg system plants # 20 instances per 16 meters spawner_entity.get_set_test(0, 'Configuration|Allow Empty Assets', True) - general.idle_wait(1.0) num_expected_instances = 20 * 20 - box = azlmbr.shape.ShapeComponentRequestsBus(bus.Event, 'GetEncompassingAabb', spawner_entity.id) - num_found = azlmbr.areasystem.AreaSystemRequestBus(bus.Broadcast, 'GetInstanceCountInAabb', box) - property_tree_success = property_tree_success and (num_found == num_expected_instances) + property_tree_success = property_tree_success and self.wait_for_condition(lambda: dynveg.validate_instance_count_in_entity_shape(spawner_entity.id, num_expected_instances), 5.0) self.test_success = self.test_success and property_tree_success self.log(f'Property Tree spawner type test: {property_tree_success}') @@ -127,10 +124,8 @@ class TestDynamicSliceInstanceSpawner(EditorTestHelper): # Since we have an empty slice path, we should have 0 instances once we disable 'Allow Empty Assets' num_expected_instances = 0 allow_empty_assets_success = allow_empty_assets_success and spawner_entity.get_set_test(0, 'Configuration|Allow Empty Assets', False) - general.idle_wait(1.0) - num_found = azlmbr.areasystem.AreaSystemRequestBus(bus.Broadcast, 'GetInstanceCountInAabb', box) - self.log(f'Allow Empty Assets test: Found {num_found} instances -- Expected {num_expected_instances} instances') - allow_empty_assets_success = allow_empty_assets_success and (num_found == num_expected_instances) + self.log('Allow Empty Assets test:') + allow_empty_assets_success = allow_empty_assets_success and self.wait_for_condition(lambda: dynveg.validate_instance_count_in_entity_shape(spawner_entity.id, num_expected_instances), 5.0) self.test_success = self.test_success and allow_empty_assets_success self.log(f'Allow Empty Assets test: {allow_empty_assets_success}') @@ -143,10 +138,8 @@ class TestDynamicSliceInstanceSpawner(EditorTestHelper): descriptor = hydra.get_component_property_value(spawner_entity.components[2], 'Configuration|Embedded Assets|[0]') descriptor.spawner = dynamic_slice_spawner spawns_slices_success = spawns_slices_success and spawner_entity.get_set_test(2, "Configuration|Embedded Assets|[0]", descriptor) - general.idle_wait(1.0) - num_found = azlmbr.areasystem.AreaSystemRequestBus(bus.Broadcast, 'GetInstanceCountInAabb', box) - self.log(f'Spawn dynamic slices test: Found {num_found} instances -- Expected {num_expected_instances} instances') - spawns_slices_success = spawns_slices_success and (num_found == num_expected_instances) + self.log('Spawn dynamic slices test:') + spawns_slices_success = spawns_slices_success and self.wait_for_condition(lambda: dynveg.validate_instance_count_in_entity_shape(spawner_entity.id, num_expected_instances), 5.0) self.test_success = self.test_success and spawns_slices_success self.log(f'Spawn dynamic slices test: {spawns_slices_success}') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py index 161ad038a5..dc353aca1a 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py @@ -100,21 +100,15 @@ class TestEmptyInstanceSpawner(EditorTestHelper): # This should result in 400 instances, since our box is 16 m x 16 m and by default the veg system plants # 20 instances per 16 meters - general.idle_wait(2.0) num_expected_instances = 20 * 20 - box = azlmbr.shape.ShapeComponentRequestsBus(bus.Event, 'GetEncompassingAabb', spawner_entity.id) - num_found = azlmbr.areasystem.AreaSystemRequestBus(bus.Broadcast, 'GetInstanceCountInAabb', box) - property_tree_success = property_tree_success and (num_found == num_expected_instances) + property_tree_success = property_tree_success and self.wait_for_condition(lambda: dynveg.validate_instance_count_in_entity_shape(spawner_entity.id, num_expected_instances), 5.0) self.test_success = self.test_success and property_tree_success - self.log(f'Found {num_found} instances -- Expected {num_expected_instances} instances') self.log(f'Property Tree spawner type test: {property_tree_success}') # 6) Validate that the "Allow Empty Assets" setting doesn't affect the EmptyInstanceSpawner allow_empty_assets_success = True spawner_entity.get_set_test(0, 'Configuration|Allow Empty Assets', False) - general.idle_wait(2.0) - num_found = azlmbr.areasystem.AreaSystemRequestBus(bus.Broadcast, 'GetInstanceCountInAabb', box) - allow_empty_assets_success = allow_empty_assets_success and (num_found == num_expected_instances) + allow_empty_assets_success = allow_empty_assets_success and self.wait_for_condition(lambda: dynveg.validate_instance_count_in_entity_shape(spawner_entity.id, num_expected_instances), 5.0) self.test_success = self.test_success and allow_empty_assets_success self.log(f'Allow Empty Assets test: {allow_empty_assets_success}')