PrefabNotifications_RootPrefabLoadedNotificationsReceived.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. rootPrefabLoaded = False
  7. def PrefabNotifications_RootPrefabLoadedNotificationsReceived():
  8. from pathlib import Path
  9. import azlmbr.prefab as prefab
  10. import Prefab.tests.PrefabTestUtils as prefab_test_utils
  11. # Connects PrefabPublicNotificationBusHandler and add callbacks for 'OnRootPrefabInstanceLoaded'
  12. def OnRootPrefabInstanceLoaded(parameters):
  13. global rootPrefabLoaded
  14. rootPrefabLoaded = True
  15. handler = prefab.PrefabPublicNotificationBusHandler()
  16. handler.connect()
  17. handler.add_callback('OnRootPrefabInstanceLoaded', OnRootPrefabInstanceLoaded)
  18. prefab_test_utils.open_base_tests_level()
  19. handler.disconnect()
  20. assert rootPrefabLoaded, "Notification 'PrefabPublicNotifications::OnRootPrefabInstanceLoaded' is not sent."
  21. if __name__ == "__main__":
  22. from editor_python_test_tools.utils import Report
  23. Report.start_test(PrefabNotifications_RootPrefabLoadedNotificationsReceived)