diff --git a/test/gui/shared/scripts/names.py b/test/gui/shared/scripts/names.py index 3d06adeb626..ec3fabf4d68 100644 --- a/test/gui/shared/scripts/names.py +++ b/test/gui/shared/scripts/names.py @@ -3,7 +3,6 @@ from objectmaphelper import * settings_OCC_SettingsDialog = {"name": "Settings", "type": "OCC::SettingsDialog", "visible": 1} -settings_settingsdialog_toolbutton_Add_account_QToolButton = {"name": "settingsdialog_toolbutton_Add account", "type": "QToolButton", "visible": 1, "window": settings_OCC_SettingsDialog} owncloudWizard_OCC_OwncloudWizard = {"name": "owncloudWizard", "type": "OCC::OwncloudWizard", "visible": 1} owncloudWizard_label_2_QLabel = {"name": "label_2", "type": "QLabel", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard} leUrl_OCC_PostfixLineEdit = {"buddy": owncloudWizard_label_2_QLabel, "name": "leUrl", "type": "OCC::PostfixLineEdit", "visible": 1} @@ -24,7 +23,6 @@ settings_stack_QStackedWidget = {"name": "stack", "type": "QStackedWidget", "visible": 1, "window": settings_OCC_SettingsDialog} stack_accountToolbox_QToolButton = {"container": settings_stack_QStackedWidget, "name": "_accountToolbox", "type": "QToolButton", "visible": 1} settings_QMenu = {"type": "QMenu", "unnamed": 1, "visible": 1, "window": settings_OCC_SettingsDialog} -stack_Remove_connection_QPushButton = {"container": settings_stack_QStackedWidget, "text": "Remove connection", "type": "QPushButton", "unnamed": 1, "visible": 1} owncloudWizard_usernameLabel_QLabel = {"name": "usernameLabel", "type": "QLabel", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard} owncloudWizard_passwordLabel_QLabel = {"name": "passwordLabel", "type": "QLabel", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard} qFileDialog_fileNameLabel_QLabel = {"name": "fileNameLabel", "type": "QLabel", "visible": 1, "window": qFileDialog_QFileDialog} diff --git a/test/gui/shared/scripts/pageObjects/AccountStatus.py b/test/gui/shared/scripts/pageObjects/AccountStatus.py new file mode 100644 index 00000000000..dda7ec92cb5 --- /dev/null +++ b/test/gui/shared/scripts/pageObjects/AccountStatus.py @@ -0,0 +1,48 @@ +import names +import squish + + +class AccountStatus: + ACCOUNT_BUTTON = { + "container": names.settings_stack_QStackedWidget, + "name": "_accountToolbox", + "type": "QToolButton", + "visible": 1, + } + ACCOUNT_MENU = { + "type": "QMenu", + "unnamed": 1, + "visible": 1, + "window": names.settings_OCC_SettingsDialog, + } + SIGNED_OUT_TEXT_BAR = { + "container": names.settings_stack_QStackedWidget, + "name": "connectLabel", + "type": "QLabel", + "visible": 1, + } + + REMOVE_CONNECTION_BUTTON = { + "container": names.settings_stack_QStackedWidget, + "text": "Remove connection", + "type": "QPushButton", + "unnamed": 1, + "visible": 1, + } + + def accountAction(self, action): + squish.sendEvent( + "QMouseEvent", + squish.waitForObject(self.ACCOUNT_BUTTON), + squish.QEvent.MouseButtonPress, + 0, + 0, + squish.Qt.LeftButton, + 0, + 0, + ) + squish.activateItem(squish.waitForObjectItem(self.ACCOUNT_MENU, action)) + + def removeConnection(self): + self.accountAction("Remove") + squish.clickButton(squish.waitForObject(self.REMOVE_CONNECTION_BUTTON)) diff --git a/test/gui/shared/scripts/pageObjects/Toolbar.py b/test/gui/shared/scripts/pageObjects/Toolbar.py index 6516cdbce35..291e38df236 100644 --- a/test/gui/shared/scripts/pageObjects/Toolbar.py +++ b/test/gui/shared/scripts/pageObjects/Toolbar.py @@ -9,50 +9,26 @@ class Toolbar: "visible": 1, "window": names.settings_OCC_SettingsDialog, } - ACCOUNT_BUTTON = { - "container": names.settings_stack_QStackedWidget, - "name": "_accountToolbox", + ADD_ACCOUNT_BUTTON = { + "name": "settingsdialog_toolbutton_Add account", "type": "QToolButton", "visible": 1, - } - ACCOUNT_MENU = { - "type": "QMenu", - "unnamed": 1, - "visible": 1, "window": names.settings_OCC_SettingsDialog, } - SIGNED_OUT_TEXT_BAR = { - "container": names.settings_stack_QStackedWidget, - "name": "connectLabel", - "type": "QLabel", - "visible": 1, - } def clickActivity(self): squish.clickButton(squish.waitForObject(self.ACTIVITY_BUTTON)) - def userLogout(self): - squish.sendEvent( - "QMouseEvent", - squish.waitForObject(self.ACCOUNT_BUTTON), - squish.QEvent.MouseButtonPress, - 0, - 0, - squish.Qt.LeftButton, - 0, - 0, - ) - squish.activateItem(squish.waitForObjectItem(self.ACCOUNT_MENU, "Log out")) + def clickAddAccount(self): + squish.clickButton(squish.waitForObject(self.ADD_ACCOUNT_BUTTON)) - def userLogsIn(self): - squish.sendEvent( - "QMouseEvent", - squish.waitForObject(self.ACCOUNT_BUTTON), - squish.QEvent.MouseButtonPress, - 0, - 0, - squish.Qt.LeftButton, - 0, - 0, + def getDisplayedAccountText(self, displayname, host): + return str( + squish.waitForObjectExists( + { + "name": "settingsdialog_toolbutton_" + displayname + "@" + host, + "type": "QToolButton", + "visible": 1, + } + ).text ) - squish.activateItem(squish.waitForObjectItem(self.ACCOUNT_MENU, "Log in")) diff --git a/test/gui/shared/steps/steps.py b/test/gui/shared/steps/steps.py index 50edc14bf99..0b80a96f457 100644 --- a/test/gui/shared/steps/steps.py +++ b/test/gui/shared/steps/steps.py @@ -18,7 +18,7 @@ from pageObjects.SyncWizard import SyncWizard from pageObjects.Toolbar import Toolbar from pageObjects.Activity import Activity - +from pageObjects.AccountStatus import AccountStatus # the script needs to use the system wide python # to switch from the built-in interpreter see https://kb.froglogic.com/squish/howto/using-external-python-interpreter-squish-6-6/ @@ -67,6 +67,15 @@ def hook(context): pass +@Given('the user has added an account with') +def step(context): + toolbar = Toolbar() + toolbar.clickAddAccount() + + newAccount = AccountConnectionWizard() + newAccount.addAccount(context) + + @When('the user adds the first account with') def step(context): newAccount = AccountConnectionWizard() @@ -117,9 +126,8 @@ def step(context): @When('the user adds an account with') def step(context): - clickButton( - waitForObject(names.settings_settingsdialog_toolbutton_Add_account_QToolButton) - ) + toolbar = Toolbar() + toolbar.clickAddAccount() newAccount = AccountConnectionWizard() newAccount.addAccount(context) @@ -516,16 +524,16 @@ def step(context, resource, role): @When('the user logs out of the client-UI') def step(context): - toolbar = Toolbar() - toolbar.userLogout() + accountStatus = AccountStatus() + accountStatus.accountAction("Log out") def isUserSignedOut(context, username): displayname = getDisplayname(username) server = context.userData['localBackendUrl'] - toolbar = Toolbar() + accountStatus = AccountStatus() test.compare( - str(waitForObjectExists(toolbar.SIGNED_OUT_TEXT_BAR).text), + str(waitForObjectExists(accountStatus.SIGNED_OUT_TEXT_BAR).text), 'Signed out from ' @@ -539,10 +547,10 @@ def isUserSignedOut(context, username): def isUserSignedIn(context, username): displayname = getDisplayname(username) server = context.userData['localBackendUrl'] - toolbar = Toolbar() + accountStatus = AccountStatus() test.compare( - str(waitForObjectExists(toolbar.SIGNED_OUT_TEXT_BAR).text), + str(waitForObjectExists(accountStatus.SIGNED_OUT_TEXT_BAR).text), 'Connected ' + 'to