status-desktop/test/e2e/gui/components/picture_edit_popup.py

52 lines
1.8 KiB
Python

import time
from collections import namedtuple
import allure
import driver.mouse
from gui.components.base_popup import BasePopup
from gui.elements.button import Button
from gui.elements.object import QObject
from gui.elements.slider import Slider
shift_image = namedtuple('Shift', ['left', 'right', 'top', 'bottom'])
class PictureEditPopup(BasePopup):
def __init__(self):
super(PictureEditPopup, self).__init__()
self._zoom_slider = Slider('o_StatusSlider')
self._view = QObject('cropSpaceItem_Item')
self._make_picture_button = Button('make_picture_StatusButton')
self._slider_handler = QObject('o_DropShadow')
@allure.step('Make picture')
def make_picture(
self,
zoom: int = None,
shift: shift_image = None
):
if zoom is not None:
self._zoom_slider.value = zoom
# The slider changed value, but image updates only after click on slider
self._slider_handler.click()
time.sleep(1)
if shift is not None:
if shift.left:
driver.mouse.press_and_move(self._view.object, 1, 1, shift.left, 1)
time.sleep(1)
if shift.right:
driver.mouse.press_and_move(
self._view.object, self._view.width, 1, self._view.width - shift.right, 1)
time.sleep(1)
if shift.top:
driver.mouse.press_and_move(self._view.object, 1, 1, 1, shift.top, step=1)
time.sleep(1)
if shift.bottom:
driver.mouse.press_and_move(
self._view.object, 1, self._view.height, 1, self._view.height - shift.bottom, step=1)
time.sleep(1)
self._make_picture_button.click()