2023-08-04 18:27:03 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import allure
|
|
|
|
|
2023-09-28 12:44:13 +00:00
|
|
|
import configs
|
2023-08-04 18:27:03 +00:00
|
|
|
import driver
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.object import QObject
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class Window(QObject):
|
|
|
|
|
|
|
|
def prepare(self) -> 'Window':
|
2023-09-11 18:24:13 +00:00
|
|
|
self.show()
|
2023-08-04 18:27:03 +00:00
|
|
|
self.maximize()
|
|
|
|
self.on_top_level()
|
|
|
|
return self
|
|
|
|
|
|
|
|
@allure.step("Maximize {0}")
|
|
|
|
def maximize(self):
|
|
|
|
assert driver.toplevel_window.maximize(self.real_name), 'Maximize failed'
|
2023-10-31 10:53:49 +00:00
|
|
|
_logger.info(f'Window {getattr(self, "title", "")} is maximized')
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
@allure.step("Minimize {0}")
|
|
|
|
def minimize(self):
|
|
|
|
assert driver.toplevel_window.minimize(self.real_name), 'Minimize failed'
|
2023-10-31 10:53:49 +00:00
|
|
|
_logger.info(f'Window {getattr(self, "title", "")} is minimized')
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
@allure.step("Set focus on {0}")
|
|
|
|
def set_focus(self):
|
|
|
|
assert driver.toplevel_window.set_focus(self.real_name), 'Set focus failed'
|
2023-10-31 10:53:49 +00:00
|
|
|
_logger.info(f'Window {getattr(self, "title", "")} in focus')
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
@allure.step("Move {0} on top")
|
|
|
|
def on_top_level(self):
|
|
|
|
assert driver.toplevel_window.on_top_level(self.real_name), 'Set on top failed'
|
2023-10-31 10:53:49 +00:00
|
|
|
_logger.info(f'Window {getattr(self, "title", "")} moved on top')
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
@allure.step("Close {0}")
|
|
|
|
def close(self):
|
|
|
|
driver.toplevel_window.close(self.real_name)
|
2023-11-01 07:19:05 +00:00
|
|
|
_logger.info(f'{self} closed')
|
2023-09-11 18:24:13 +00:00
|
|
|
|
|
|
|
@allure.step("Show {0}")
|
|
|
|
def show(self):
|
|
|
|
driver.waitForObjectExists(self.real_name).setVisible(True)
|
2023-11-01 07:19:05 +00:00
|
|
|
_logger.info(f'{self} is visible')
|
2023-09-11 18:24:13 +00:00
|
|
|
|
|
|
|
@allure.step("Hide {0}")
|
|
|
|
def hide(self):
|
|
|
|
driver.waitForObjectExists(self.real_name).setVisible(False)
|
2023-11-01 07:19:05 +00:00
|
|
|
_logger.info(f'{self} hidden')
|
2023-09-28 12:44:13 +00:00
|
|
|
|
|
|
|
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
|
|
|
|
super().wait_until_appears(timeout_msec)
|
2023-10-31 10:53:49 +00:00
|
|
|
_logger.info(f'Window {getattr(self, "title", "")} appears')
|
2023-09-28 12:44:13 +00:00
|
|
|
return self
|