test_remote_console.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. import filecmp
  7. import os
  8. import pytest
  9. import time
  10. # ly_test_tools dependencies.
  11. import ly_remote_console.remote_console_commands as remote_console_commands
  12. from ly_test_tools import WINDOWS
  13. @pytest.fixture
  14. def remote_console(request):
  15. """
  16. Creates a RemoteConsole() class instance to send console commands to the
  17. Lumberyard client console.
  18. :param request: _pytest.fixtures.SubRequest class that handles getting
  19. a pytest fixture from a pytest function/fixture.
  20. :return: ly_remote_console.remote_console_commands.RemoteConsole class instance
  21. representing the Lumberyard remote console executable.
  22. """
  23. # Initialize the RemoteConsole object to send commands to the Lumberyard client console.
  24. console = remote_console_commands.RemoteConsole()
  25. # Custom teardown method for this remote_console fixture.
  26. def teardown():
  27. console.stop()
  28. # Utilize request.addfinalizer() to add custom teardown() methods.
  29. request.addfinalizer(teardown) # This pattern must be used in pytest version
  30. return console
  31. @pytest.mark.skipif(not WINDOWS, reason="Editor currently only functions on Windows")
  32. @pytest.mark.parametrize("launcher_platform", ['windows_editor'])
  33. class TestRemoteConsole(object):
  34. @pytest.mark.parametrize("project", ["AutomatedTesting"])
  35. @pytest.mark.parametrize("level", ['Simple'])
  36. @pytest.mark.parametrize("load_wait", [120])
  37. def test_RemoteConsole_TakeScreenshot_Success(self, launcher, launcher_platform, remote_console, level, load_wait):
  38. with launcher.start():
  39. remote_console.start()
  40. launcher_load = remote_console.expect_log_line(
  41. match_string='========================== '
  42. 'Finished loading textures '
  43. '============================',
  44. timeout=load_wait)
  45. remote_console_commands.capture_screenshot_command(remote_console)
  46. assert True
  47. @pytest.mark.parametrize("project", ["AutomatedTesting"])
  48. @pytest.mark.parametrize("level", ['Simple'])
  49. @pytest.mark.parametrize("load_wait", [120])
  50. def test_RemoteConsole_DelayedConnection_Success(self, launcher, launcher_platform, remote_console, level, load_wait):
  51. remote_console.start()
  52. time.sleep(5)
  53. with launcher.start():
  54. launcher_load = remote_console.expect_log_line(
  55. match_string='========================== '
  56. 'Finished loading textures '
  57. '============================',
  58. timeout=load_wait)
  59. assert True