diff options
author | Swoichha Adhikari <swoichhaa@gmail.com> | 2021-05-25 12:04:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-25 12:04:19 +0300 |
commit | 808284d75bb23a85de3c8068051995dbbf8e18d2 (patch) | |
tree | 28b1f60e6bc8e3523dd65dee0cbc8aeebdd93c3d /test | |
parent | a64b638468455a6e2edf185578d7c3be3a888d9b (diff) |
[tests-only]POM for sharing (#8634)
Diffstat (limited to 'test')
-rw-r--r-- | test/gui/shared/scripts/helpers/SetupClientHelper.py | 61 | ||||
-rw-r--r-- | test/gui/shared/scripts/names.py | 20 | ||||
-rw-r--r-- | test/gui/shared/scripts/pageObjects/EnterPassword.py | 29 | ||||
-rw-r--r-- | test/gui/shared/scripts/pageObjects/PublicLinkDialog.py | 174 | ||||
-rw-r--r-- | test/gui/shared/scripts/pageObjects/SharingDialog.py | 84 | ||||
-rw-r--r-- | test/gui/shared/steps/steps.py | 283 | ||||
-rw-r--r-- | test/gui/tst_sharing/test.feature | 2 |
7 files changed, 394 insertions, 259 deletions
diff --git a/test/gui/shared/scripts/helpers/SetupClientHelper.py b/test/gui/shared/scripts/helpers/SetupClientHelper.py index 7e20adb5e..5a572716f 100644 --- a/test/gui/shared/scripts/helpers/SetupClientHelper.py +++ b/test/gui/shared/scripts/helpers/SetupClientHelper.py @@ -1,4 +1,9 @@ from urllib.parse import urlparse +import squish + + +confdir = '/tmp/bdd-tests-owncloud-client/' +confFilePath = confdir + 'owncloud.cfg' def substituteInLineCodes(context, value): @@ -27,3 +32,59 @@ def getClientDetails(context): except: pass return server, user, password, localfolder + + +def startClient(context): + squish.startApplication( + "owncloud -s" + + " --logfile " + + context.userData['clientConfigFile'] + + " --language en_US" + + " --confdir " + + confdir + ) + squish.snooze(1) + + +def getPollingInterval(): + pollingInterval = '''[ownCloud] + remotePollInterval={pollingInterval} + ''' + args = {'pollingInterval': 5000} + pollingInterval = pollingInterval.format(**args) + return pollingInterval + + +def setUpClient(context, username, confFilePath): + userSetting = ''' + [Accounts] + 0/Folders/1/ignoreHiddenFiles=true + 0/Folders/1/localPath={client_sync_path} + 0/Folders/1/paused=false + 0/Folders/1/targetPath=/ + 0/Folders/1/version=2 + 0/Folders/1/virtualFilesMode=off + 0/dav_user={davUserName} + 0/display-name={displayUserName} + 0/http_oauth=false + 0/http_user={davUserName} + 0/url={local_server} + 0/user={displayUserFirstName} + 0/version=1 + version=2 + ''' + userFirstName = username.split() + userSetting = userSetting + getPollingInterval() + args = { + 'displayUserName': username, + 'davUserName': userFirstName[0].lower(), + 'displayUserFirstName': userFirstName[0], + 'client_sync_path': context.userData['clientSyncPath'], + 'local_server': context.userData['localBackendUrl'], + } + userSetting = userSetting.format(**args) + configFile = open(confFilePath, "w") + configFile.write(userSetting) + configFile.close() + + startClient(context) diff --git a/test/gui/shared/scripts/names.py b/test/gui/shared/scripts/names.py index 074a5952b..d25961616 100644 --- a/test/gui/shared/scripts/names.py +++ b/test/gui/shared/scripts/names.py @@ -26,22 +26,19 @@ stack_accountToolbox_QToolButton = {"container": settings_stack_QStackedWidget, 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} -leUsername_QLineEdit = {"buddy": owncloudWizard_usernameLabel_QLabel, "name": "leUsername", "type": "QLineEdit", "visible": 1} owncloudWizard_passwordLabel_QLabel = {"name": "passwordLabel", "type": "QLabel", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard} -lePassword_QLineEdit = {"buddy": owncloudWizard_passwordLabel_QLabel, "name": "lePassword", "type": "QLineEdit", "visible": 1} qFileDialog_fileNameLabel_QLabel = {"name": "fileNameLabel", "type": "QLabel", "visible": 1, "window": qFileDialog_QFileDialog} -fileNameEdit_QLineEdit = {"buddy": qFileDialog_fileNameLabel_QLabel, "name": "fileNameEdit", "type": "QLineEdit", "visible": 1} +leUsername_QLineEdit = {"buddy": owncloudWizard_usernameLabel_QLabel, "name": "leUsername", "type": "QLineEdit", "visible": 1} owncloudWizard_cbSyncFromScratch_QRadioButton = {"name": "cbSyncFromScratch", "type": "QRadioButton", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard} +lePassword_QLineEdit = {"buddy": owncloudWizard_passwordLabel_QLabel, "name": "lePassword", "type": "QLineEdit", "visible": 1} +fileNameEdit_QLineEdit = {"buddy": qFileDialog_fileNameLabel_QLabel, "name": "fileNameEdit", "type": "QLineEdit", "visible": 1} settings_settingsdialog_toolbutton_artur_jankaritech_ocloud_de_QToolButton = {"name": "settingsdialog_toolbutton_artur@jankaritech.ocloud.de", "type": "QToolButton", "visible": 1, "window": settings_OCC_SettingsDialog} stack_folderList_QTreeView = {"container": settings_stack_QStackedWidget, "name": "_folderList", "type": "QTreeView", "visible": 1} sharingDialog_OCC_ShareDialog = {"name": "SharingDialog", "type": "OCC::ShareDialog", "visible": 1} sharingDialog_qt_tabwidget_stackedwidget_QStackedWidget = {"name": "qt_tabwidget_stackedwidget", "type": "QStackedWidget", "visible": 1, "window": sharingDialog_OCC_ShareDialog} qt_tabwidget_stackedwidget_SharingDialogUG_OCC_ShareUserGroupWidget = {"container": sharingDialog_qt_tabwidget_stackedwidget_QStackedWidget, "name": "SharingDialogUG", "type": "OCC::ShareUserGroupWidget", "visible": 1} -sharingDialogUG_shareeLineEdit_QLineEdit = {"container": qt_tabwidget_stackedwidget_SharingDialogUG_OCC_ShareUserGroupWidget, "name": "shareeLineEdit", "type": "QLineEdit", "visible": 1} -o_QListView = {"type": "QListView", "unnamed": 1, "visible": 1} sharingDialogUG_scrollArea_QScrollArea = {"container": qt_tabwidget_stackedwidget_SharingDialogUG_OCC_ShareUserGroupWidget, "name": "scrollArea", "type": "QScrollArea", "visible": 1} scrollArea_deleteShareButton_QToolButton = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "deleteShareButton", "type": "QToolButton", "visible": 1} -sharingDialog_Close_QPushButton = {"text": "Close", "type": "QPushButton", "unnamed": 1, "visible": 1, "window": sharingDialog_OCC_ShareDialog} settings_settingsdialog_toolbutton_Quit_ownCloud_QToolButton = {"name": "settingsdialog_toolbutton_Quit ownCloud", "type": "QToolButton", "visible": 1, "window": settings_OCC_SettingsDialog} quit_ownCloud_QMessageBox = {"type": "QMessageBox", "unnamed": 1, "visible": 1, "windowTitle": "Quit ownCloud"} quit_ownCloud_Yes_QPushButton = {"text": "Yes", "type": "QPushButton", "unnamed": 1, "visible": 1, "window": quit_ownCloud_QMessageBox} @@ -69,30 +66,25 @@ o_notifyScroll_Accept_QPushButton = {"container": oCC_ActivityWidget_notifyScrol o_notifyScroll_timeLabel_QLabel = {"container": oCC_ActivityWidget_notifyScroll_QScrollArea, "name": "_timeLabel", "type": "QLabel", "visible": 1} o_notifyScroll_subjectLabel_QLabel = {"container": oCC_ActivityWidget_notifyScroll_QScrollArea, "name": "_subjectLabel", "type": "QLabel", "visible": 1} scrollArea_OCC_ShareUserLine_OCC_ShareUserLine = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "OCC__ShareUserLine", "type": "OCC::ShareUserLine", "visible": 1} -scrollArea_permissionShare_QCheckBox = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "permissionShare", "type": "QCheckBox", "visible": 1} -scrollArea_permissionsEdit_QCheckBox = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "permissionsEdit", "type": "QCheckBox", "visible": 1} -scrollArea_sharedWith_QLabel = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "sharedWith", "type": "QLabel", "visible": 1} -enter_Password_Field = {"container": enter_Password_QInputDialog, "type": "QLineEdit", "unnamed": 1, "visible": 1} -enter_Password_OK_QPushButton = {"text": "OK", "type": "QPushButton", "unnamed": 1, "visible": 1, "window": enter_Password_QInputDialog} o_folderList_QModelIndex = {"column": 0, "container": stack_folderList_QTreeView, "text": "", "type": "QModelIndex"} qt_tabwidget_stackedwidget_OCC_IssuesWidget_OCC_IssuesWidget = {"container": stack_qt_tabwidget_stackedwidget_QStackedWidget, "name": "OCC__IssuesWidget", "type": "OCC::IssuesWidget", "visible": 1} oCC_IssuesWidget_treeWidget_QTreeWidget = {"container": qt_tabwidget_stackedwidget_OCC_IssuesWidget_OCC_IssuesWidget, "name": "_treeWidget", "type": "QTreeWidget", "visible": 1} o_treeWidget_lorem_conflicted_copy_2020_12_14_133239_txt_QModelIndex = {"column": 1, "container": oCC_IssuesWidget_treeWidget_QTreeWidget, "text": RegularExpression("lorem (conflicted copy 2020-12-14 133239).txt"), "type": "QModelIndex"} stack_QTabWidget = {"container": settings_stack_QStackedWidget, "type": "QTabWidget", "unnamed": 1, "visible": 1} +scrollArea_sharedWith_QLabel = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "sharedWith", "type": "QLabel", "visible": 1} +scrollArea_permissionsEdit_QCheckBox = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "permissionsEdit", "type": "QCheckBox", "visible": 1} +scrollArea_permissionShare_QCheckBox = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "permissionShare", "type": "QCheckBox", "visible": 1} stack_qt_tabwidget_tabbar_QTabBar = {"container": settings_stack_QStackedWidget, "name": "qt_tabwidget_tabbar", "type": "QTabBar", "visible": 1} o_treeWidget_Conflict_Server_version_downloaded_local_copy_renamed_and_not_uploaded_QModelIndex = {"column": 3, "container": oCC_IssuesWidget_treeWidget_QTreeWidget, "text": "Conflict: Server version downloaded, local copy renamed and not uploaded.", "type": "QModelIndex"} qt_tabwidget_stackedwidget_OCC_ProtocolWidget_OCC_ProtocolWidget = {"container": stack_qt_tabwidget_stackedwidget_QStackedWidget, "name": "OCC__ProtocolWidget", "type": "OCC::ProtocolWidget", "visible": 1} oCC_ProtocolWidget_treeWidget_QTreeWidget = {"container": qt_tabwidget_stackedwidget_OCC_ProtocolWidget_OCC_ProtocolWidget, "name": "_treeWidget", "type": "QTreeWidget", "visible": 1} o_treeWidget_lorem_txt_QModelIndex = {"column": 1, "container": oCC_ProtocolWidget_treeWidget_QTreeWidget, "text": "lorem.txt", "type": "QModelIndex"} sharingDialog_qt_tabwidget_tabbar_QTabBar = {"name": "qt_tabwidget_tabbar", "type": "QTabBar", "visible": 1, "window": sharingDialog_OCC_ShareDialog} -qt_tabwidget_tabbar_Public_Links_TabItem = {"container": sharingDialog_qt_tabwidget_tabbar_QTabBar, "text": "Public Links", "type": "TabItem"} qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget = {"container": sharingDialog_qt_tabwidget_stackedwidget_QStackedWidget, "name": "OCC__ShareLinkWidget", "type": "OCC::ShareLinkWidget", "visible": 1} oCC_ShareLinkWidget_checkBox_password_QCheckBox = {"container": qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, "name": "checkBox_password", "type": "QCheckBox", "visible": 1} oCC_ShareLinkWidget_widget_editing_QWidget = {"container": qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, "name": "widget_editing", "type": "QWidget", "visible": 1} oCC_ShareLinkWidget_checkBox_password_QProgressIndicator = {"aboveWidget": oCC_ShareLinkWidget_widget_editing_QWidget, "container": qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, "leftWidget": oCC_ShareLinkWidget_checkBox_password_QCheckBox, "type": "QProgressIndicator", "unnamed": 1, "visible": 1} -sharingDialog_The_file_can_not_be_shared_because_it_was_shared_without_sharing_permission_QLabel = {"text": "The file can not be shared because it was shared without sharing permission.", "type": "QLabel", "unnamed": 1, "visible": 1, "window": sharingDialog_OCC_ShareDialog} sharingDialog_label_name_QLabel = {"name": "label_name", "type": "QLabel", "visible": 1, "window": sharingDialog_OCC_ShareDialog} -oCC_ShareLinkWidget_createShareButton_QPushButton = {"container": qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, "name": "createShareButton", "type": "QPushButton", "visible": 1} oCC_ShareLinkWidget_linkShares_QTableWidget = {"container": qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, "name": "linkShares", "type": "QTableWidget", "visible": 1} linkShares_QToolButton = {"container": oCC_ShareLinkWidget_linkShares_QTableWidget, "text": "...", "type": "QToolButton", "unnamed": 1, "visible": 1} oCC_ShareLinkWidget_lineEdit_password_QLineEdit = {"container": qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, "name": "lineEdit_password", "type": "QLineEdit", "visible": 1} diff --git a/test/gui/shared/scripts/pageObjects/EnterPassword.py b/test/gui/shared/scripts/pageObjects/EnterPassword.py new file mode 100644 index 000000000..5311fe654 --- /dev/null +++ b/test/gui/shared/scripts/pageObjects/EnterPassword.py @@ -0,0 +1,29 @@ +import names +import squish + + +class EnterPassword: + PASSWORD_BOX = { + "container": names.enter_Password_QInputDialog, + "type": "QLineEdit", + "unnamed": 1, + "visible": 1, + } + OK_BUTTON = { + "text": "OK", + "type": "QPushButton", + "unnamed": 1, + "visible": 1, + "window": names.enter_Password_QInputDialog, + } + + def __init__(self): + pass + + def enterPassword(self, password): + try: + squish.waitForObject(self.PASSWORD_BOX, 10000) + squish.type(squish.waitForObject(self.PASSWORD_BOX), password) + squish.clickButton(squish.waitForObject(self.OK_BUTTON)) + except LookupError: + pass diff --git a/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py b/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py new file mode 100644 index 000000000..536bb002d --- /dev/null +++ b/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py @@ -0,0 +1,174 @@ +import names +import squish +import test +import datetime + + +class PublicLinkDialog: + PUBLIC_LINKS_TAB = { + "container": names.sharingDialog_qt_tabwidget_tabbar_QTabBar, + "text": "Public Links", + "type": "TabItem", + } + ITEM_TO_SHARE = { + "name": "label_name", + "type": "QLabel", + "visible": 1, + "window": names.sharingDialog_OCC_ShareDialog, + } + PASSWORD_CHECKBOX = { + "container": names.qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, + "name": "checkBox_password", + "type": "QCheckBox", + "visible": 1, + } + CREATE_SHARE_BUTTON = { + "container": names.qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, + "name": "createShareButton", + "type": "QPushButton", + "visible": 1, + } + + PUBLIC_LINK_NAME = { + "column": 0, + "container": names.oCC_ShareLinkWidget_linkShares_QTableWidget, + "row": 0, + "type": "QModelIndex", + } + EXPIRATION_DATE_FIELD = { + "container": names.qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, + "name": "qt_spinbox_lineedit", + "type": "QLineEdit", + "visible": 1, + } + READ_ONLY_RADIO_BUTTON = { + "container": names.qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, + "name": "radio_readOnly", + "type": "QRadioButton", + "visible": 1, + } + READ_WRITE_RADIO_BUTTON = { + "container": names.qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, + "name": "radio_readWrite", + "type": "QRadioButton", + "visible": 1, + } + UPLOAD_ONLY_RADIO_BUTTON = { + "container": names.qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget, + "name": "radio_uploadOnly", + "type": "QRadioButton", + "visible": 1, + } + + def openPublicLinkDialog(self): + squish.mouseClick( + squish.waitForObject(self.PUBLIC_LINKS_TAB), + 0, + 0, + squish.Qt.NoModifier, + squish.Qt.LeftButton, + ) + + def createPublicLink(self, context, resource, password='', permissions=''): + radioObjectName = '' + if permissions: + radioObjectName = self.getRadioObjectForPermssion(permissions) + + test.compare( + str(squish.waitForObjectExists(self.ITEM_TO_SHARE).text), + resource.replace(context.userData['clientSyncPath'], ''), + ) + + if radioObjectName: + test.compare( + str(squish.waitForObjectExists(radioObjectName).text), permissions + ) + squish.clickButton(squish.waitForObject(radioObjectName)) + + if password: + squish.clickButton(squish.waitForObject(self.PASSWORD_CHECKBOX)) + squish.mouseClick( + squish.waitForObject(self.PASSWORD_CHECKBOX), + 0, + 0, + squish.Qt.NoModifier, + squish.Qt.LeftButton, + ) + squish.type( + squish.waitForObject(self.PASSWORD_CHECKBOX), + password, + ) + + squish.clickButton(squish.waitForObject(self.CREATE_SHARE_BUTTON)) + squish.waitFor( + lambda: ( + squish.waitForObject(names.linkShares_0_0_QModelIndex).displayText + == "Public link" + ) + ) + + def togglesPassword(self): + squish.clickButton(squish.waitForObject(self.PASSWORD_CHECKBOX)) + + def setExpirationDate(self, context, publicLinkName, resource): + test.compare( + str(squish.waitForObjectExists(self.ITEM_TO_SHARE).text), + resource, + ) + test.compare( + str(squish.waitForObjectExists(self.PUBLIC_LINK_NAME).text), + publicLinkName, + ) + expDate = [] + for row in context.table: + if row[0] == 'expireDate': + expDate = datetime.datetime.strptime(row[1], '%Y-%m-%d') + expYear = expDate.year - 2000 + squish.mouseClick( + squish.waitForObject(self.EXPIRATION_DATE_FIELD), + 0, + 0, + squish.Qt.NoModifier, + squish.Qt.LeftButton, + ) + squish.nativeType("<Delete>") + squish.nativeType("<Delete>") + squish.nativeType(expDate.month) + squish.nativeType(expDate.day) + squish.nativeType(expYear) + squish.nativeType("<Return>") + squish.testSettings.silentVerifications = True + squish.waitFor( + lambda: (test.xvp("publicLinkExpirationProgressIndicatorInvisible")) + ) + waitFor(lambda: (test.vp("publicLinkExpirationProgressIndicatorInvisible"))) + squish.testSettings.silentVerifications = False + test.compare( + str(squish.waitForObjectExists(self.EXPIRATION_DATE_FIELD).displayText), + str(expDate.month) + "/" + str(expDate.day) + "/" + str(expYear), + ) + + def getRadioObjectForPermssion(self, permissions): + radioObjectName = '' + if permissions == 'Download / View' or permissions == 'Viewer': + radioObjectName = self.READ_ONLY_RADIO_BUTTON + elif permissions == 'Download / View / Edit' or permissions == 'Editor': + radioObjectName = self.READ_WRITE_RADIO_BUTTON + elif permissions == 'Upload only (File Drop)' or permissions == 'Contributor': + radioObjectName = self.UPLOAD_ONLY_RADIO_BUTTON + else: + raise Exception("No such radio object found for given permission") + + return radioObjectName + + def createPublicLinkWithRole(self, role): + radioObjectName = self.getRadioObjectForPermssion(role) + + squish.clickButton(squish.waitForObject(radioObjectName)) + squish.clickButton(squish.waitForObject(self.CREATE_SHARE_BUTTON)) + squish.waitFor( + lambda: ( + squish.findObject(names.linkShares_0_0_QModelIndex).displayText + == "Public link" + ) + ) diff --git a/test/gui/shared/scripts/pageObjects/SharingDialog.py b/test/gui/shared/scripts/pageObjects/SharingDialog.py new file mode 100644 index 000000000..0447593eb --- /dev/null +++ b/test/gui/shared/scripts/pageObjects/SharingDialog.py @@ -0,0 +1,84 @@ +import names +import squish +import test + + +class SharingDialog: + + SHARE_WITH_COLLABORATOR_INPUT_FIELD = { + "container": names.qt_tabwidget_stackedwidget_SharingDialogUG_OCC_ShareUserGroupWidget, + "name": "shareeLineEdit", + "type": "QLineEdit", + "visible": 1, + } + SUGGESTED_COLLABORATOR = {"type": "QListView", "unnamed": 1, "visible": 1} + EDIT_PERMISSIONS_CHECKBOX = { + "container": names.sharingDialogUG_scrollArea_QScrollArea, + "name": "permissionsEdit", + "type": "QCheckBox", + "visible": 1, + } + SHARE_PERMISSIONS_CHECKBOX = { + "container": names.sharingDialogUG_scrollArea_QScrollArea, + "name": "permissionShare", + "type": "QCheckBox", + "visible": 1, + } + SHARING_DIALOG_CLOSE_BUTTON = { + "text": "Close", + "type": "QPushButton", + "unnamed": 1, + "visible": 1, + "window": names.sharingDialog_OCC_ShareDialog, + } + SHARED_WITH_ = { + "container": names.sharingDialogUG_scrollArea_QScrollArea, + "name": "sharedWith", + "type": "QLabel", + "visible": 1, + } + ERROR_SHOWN_ON_SHARING_DIALOG = { + "type": "QLabel", + "unnamed": 1, + "visible": 1, + "window": names.sharingDialog_OCC_ShareDialog, + } + + def addCollaborator(self, receiver, permissions): + squish.mouseClick( + squish.waitForObject(self.SHARE_WITH_COLLABORATOR_INPUT_FIELD), + 0, + 0, + squish.Qt.NoModifier, + squish.Qt.LeftButton, + ) + squish.type( + squish.waitForObject(self.SHARE_WITH_COLLABORATOR_INPUT_FIELD), + receiver, + ) + squish.mouseClick( + squish.waitForObjectItem(self.SUGGESTED_COLLABORATOR, receiver), + 0, + 0, + squish.Qt.NoModifier, + squish.Qt.LeftButton, + ) + permissionsList = permissions.split(",") + + editChecked = squish.waitForObjectExists(self.EDIT_PERMISSIONS_CHECKBOX).checked + shareChecked = squish.waitForObjectExists( + self.SHARE_PERMISSIONS_CHECKBOX + ).checked + if ('edit' in permissionsList and editChecked == False) or ( + 'edit' not in permissionsList and editChecked == True + ): + squish.clickButton(squish.waitForObject(self.EDIT_PERMISSIONS_CHECKBOX)) + if ('share' in permissionsList and shareChecked == False) or ( + 'share' not in permissionsList and shareChecked == True + ): + squish.clickButton(squish.waitForObject(self.SHARE_PERMISSIONS_CHECKBOX)) + + squish.clickButton(squish.waitForObject(self.SHARING_DIALOG_CLOSE_BUTTON)) + + def getErrorText(self): + return str(squish.waitForObjectExists(self.ERROR_SHOWN_ON_SHARING_DIALOG).text) diff --git a/test/gui/shared/steps/steps.py b/test/gui/shared/steps/steps.py index 5f107227b..63a1ca41e 100644 --- a/test/gui/shared/steps/steps.py +++ b/test/gui/shared/steps/steps.py @@ -7,11 +7,13 @@ from os.path import isfile, join import re import urllib.request import json -import datetime from objectmaphelper import RegularExpression from pageObjects.AccountConnectionWizard import AccountConnectionWizard -from helpers.SetupClientHelper import substituteInLineCodes +from helpers.SetupClientHelper import * +from pageObjects.EnterPassword import EnterPassword +from pageObjects.PublicLinkDialog import PublicLinkDialog +from pageObjects.SharingDialog import SharingDialog # the script needs to use the system wide python @@ -85,72 +87,11 @@ def step(context, displayname, host): ) -def startClient(context): - startApplication( - "owncloud -s" - + " --logfile " - + context.userData['clientConfigFile'] - + " --language en_US" - + " --confdir " - + confdir - ) - snooze(1) - - -def getPollingInterval(): - pollingInterval = '''[ownCloud] - remotePollInterval={pollingInterval} - ''' - args = {'pollingInterval': 5000} - pollingInterval = pollingInterval.format(**args) - return pollingInterval - - -def setUpClient(context, username, password): - userSetting = ''' - [Accounts] - 0/Folders/1/ignoreHiddenFiles=true - 0/Folders/1/localPath={client_sync_path} - 0/Folders/1/paused=false - 0/Folders/1/targetPath=/ - 0/Folders/1/version=2 - 0/Folders/1/virtualFilesMode=off - 0/dav_user={davUserName} - 0/display-name={displayUserName} - 0/http_oauth=false - 0/http_user={davUserName} - 0/url={local_server} - 0/user={displayUserFirstName} - 0/version=1 - version=2 - ''' - userFirstName = username.split() - userSetting = userSetting + getPollingInterval() - args = { - 'displayUserName': username, - 'davUserName': userFirstName[0].lower(), - 'displayUserFirstName': userFirstName[0], - 'client_sync_path': context.userData['clientSyncPath'], - 'local_server': context.userData['localBackendUrl'], - } - userSetting = userSetting.format(**args) - configFile = open(confFilePath, "w") - configFile.write(userSetting) - configFile.close() - - startClient(context) - - try: - waitForObject(names.enter_Password_Field, 10000) - type(waitForObject(names.enter_Password_Field), password) - clickButton(waitForObject(names.enter_Password_OK_QPushButton)) - except LookupError: - pass - - @Given('user "|any|" has set up a client with default settings and password "|any|"') def step(context, username, password): - setUpClient(context, username, password) + setUpClient(context, username, confFilePath) + enterUserPassword = EnterPassword() + enterUserPassword.enterPassword(password) @Given('the user has started the client') @@ -240,40 +181,8 @@ def executeStepThroughMiddleware(context, step): ) def step(context, receiver, resource, permissions): openSharingDialog(context, resource) - - mouseClick( - waitForObject(names.sharingDialogUG_shareeLineEdit_QLineEdit), - 0, - 0, - Qt.NoModifier, - Qt.LeftButton, - ) - type(waitForObject(names.sharingDialogUG_shareeLineEdit_QLineEdit), receiver) - mouseClick( - waitForObjectItem(names.o_QListView, receiver), - 0, - 0, - Qt.NoModifier, - Qt.LeftButton, - ) - permissionsList = permissions.split(",") - - editChecked = waitForObjectExists( - names.scrollArea_permissionsEdit_QCheckBox - ).checked - shareChecked = waitForObjectExists( - names.scrollArea_permissionShare_QCheckBox - ).checked - if ('edit' in permissionsList and editChecked == False) or ( - 'edit' not in permissionsList and editChecked == True - ): - clickButton(waitForObject(names.scrollArea_permissionsEdit_QCheckBox)) - if ('share' in permissionsList and shareChecked == False) or ( - 'share' not in permissionsList and shareChecked == True - ): - clickButton(waitForObject(names.scrollArea_permissionShare_QCheckBox)) - - clickButton(waitForObject(names.sharingDialog_Close_QPushButton)) + shareItem = SharingDialog() + shareItem.addCollaborator(receiver, permissions) @Then( @@ -502,25 +411,18 @@ def openSharingDialog(context, resource, itemType='file'): ) -def openPublicLinkDialog(context, resource, itemType='file'): - openSharingDialog(context, resource, itemType) - mouseClick( - waitForObject(names.qt_tabwidget_tabbar_Public_Links_TabItem), - 0, - 0, - Qt.NoModifier, - Qt.LeftButton, - ) - - @When('the user opens the public links dialog of "|any|" using the client-UI') def step(context, resource): - openPublicLinkDialog(context, resource) + resource = sanitizePath(substituteInLineCodes(context, resource)) + openSharingDialog(context, resource) + publicLinkDialog = PublicLinkDialog() + publicLinkDialog.openPublicLinkDialog() @When("the user toggles the password protection using the client-UI") def step(context): - clickButton(waitForObject(names.oCC_ShareLinkWidget_checkBox_password_QCheckBox)) + publicLinkDialog = PublicLinkDialog() + publicLinkDialog.togglesPassword() @Then('the password progress indicator should not be visible in the client-UI') @@ -542,169 +444,62 @@ def step(context, receiver, resource): @Then('the error text "|any|" should be displayed in the sharing dialog') def step(context, fileShareContext): + shareItem = SharingDialog() + errorText = shareItem.getErrorText() test.compare( - str( - waitForObjectExists( - names.sharingDialog_The_file_can_not_be_shared_because_it_was_shared_without_sharing_permission_QLabel - ).text - ), + errorText, fileShareContext, ) +def createPublicLinkShare(context, resource, password='', permissions=''): + resource = sanitizePath(substituteInLineCodes(context, resource)) + openSharingDialog(context, resource) + publicLinkDialog = PublicLinkDialog() + publicLinkDialog.openPublicLinkDialog() + publicLinkDialog.createPublicLink(context, resource, password, permissions) + + @When( 'the user creates a new public link for file "|any|" without password using the client-UI' ) def step(context, resource): - resource = sanitizePath(substituteInLineCodes(context, resource)) - openPublicLinkDialog(context, resource) - test.compare( - str(waitForObjectExists(names.sharingDialog_label_name_QLabel).text), - resource.replace(context.userData['clientSyncPath'], ''), - ) - clickButton(waitForObject(names.oCC_ShareLinkWidget_createShareButton_QPushButton)) - waitFor( - lambda: ( - waitForObject(names.linkShares_0_0_QModelIndex).displayText == "Public link" - ) - ) + createPublicLinkShare(context, resource) @When( 'the user creates a new public link for file "|any|" with password "|any|" using the client-UI' ) def step(context, resource, password): - resource = sanitizePath(substituteInLineCodes(context, resource)) - openPublicLinkDialog(context, resource) - test.compare( - str(waitForObjectExists(names.sharingDialog_label_name_QLabel).text), - resource.replace(context.userData['clientSyncPath'], ''), - ) - clickButton(waitForObject(names.oCC_ShareLinkWidget_checkBox_password_QCheckBox)) - mouseClick( - waitForObject(names.oCC_ShareLinkWidget_lineEdit_password_QLineEdit), - 0, - 0, - Qt.NoModifier, - Qt.LeftButton, - ) - type(waitForObject(names.oCC_ShareLinkWidget_lineEdit_password_QLineEdit), password) - clickButton(waitForObject(names.oCC_ShareLinkWidget_createShareButton_QPushButton)) - waitFor( - lambda: ( - findObject(names.linkShares_0_0_QModelIndex).displayText == "Public link" - ) - ) + createPublicLinkShare(context, resource, password) @When('the user edits the public link named "|any|" of file "|any|" changing following') def step(context, publicLinkName, resource): - test.compare( - str(waitForObjectExists(names.sharingDialog_label_name_QLabel).text), resource - ) - test.compare( - str(waitForObjectExists(names.linkShares_0_0_QModelIndex).text), publicLinkName - ) - expDate = [] - for row in context.table: - if row[0] == 'expireDate': - expDate = datetime.datetime.strptime(row[1], '%Y-%m-%d') - expYear = expDate.year - 2000 - mouseClick( - waitForObject(names.oCC_ShareLinkWidget_qt_spinbox_lineedit_QLineEdit), - 0, - 0, - Qt.NoModifier, - Qt.LeftButton, - ) - nativeType("<Delete>") - nativeType("<Delete>") - nativeType(expDate.month) - nativeType(expDate.day) - nativeType(expYear) - nativeType("<Return>") - testSettings.silentVerifications = True - waitFor(lambda: (test.xvp("publicLinkExpirationProgressIndicatorInvisible"))) - waitFor(lambda: (test.vp("publicLinkExpirationProgressIndicatorInvisible"))) - testSettings.silentVerifications = False - test.compare( - str( - waitForObjectExists( - names.oCC_ShareLinkWidget_qt_spinbox_lineedit_QLineEdit - ).displayText - ), - str(expDate.month) + "/" + str(expDate.day) + "/" + str(expYear), - ) + publicLinkDialog = PublicLinkDialog() + publicLinkDialog.setExpirationDate(context, publicLinkName, resource) @When( 'the user creates a new public link with permissions "|any|" for folder "|any|" without password using the client-UI' ) def step(context, permissions, resource): - resource = sanitizePath(substituteInLineCodes(context, resource)) - openPublicLinkDialog(context, resource) - radioObjectName = '' - if permissions == 'Download / View': - radioObjectName = names.oCC_ShareLinkWidget_radio_readOnly_QRadioButton - elif permissions == 'Download / View / Edit': - radioObjectName = names.oCC_ShareLinkWidget_radio_readWrite_QRadioButton - elif permissions == 'Upload only (File Drop)': - radioObjectName = names.oCC_ShareLinkWidget_radio_uploadOnly_QRadioButton - test.compare(str(waitForObjectExists(radioObjectName).text), permissions) - - clickButton(waitForObject(radioObjectName)) - clickButton(waitForObject(names.oCC_ShareLinkWidget_createShareButton_QPushButton)) - waitFor( - lambda: ( - findObject(names.linkShares_0_0_QModelIndex).displayText == "Public link" - ) - ) + createPublicLinkShare(context, resource, '', permissions) @When( 'the user creates a new public link with permissions "|any|" for folder "|any|" with password "|any|" using the client-UI' ) def step(context, permissions, resource, password): - resource = sanitizePath(substituteInLineCodes(context, resource)) - openPublicLinkDialog(context, resource) - clickButton(waitForObject(names.oCC_ShareLinkWidget_checkBox_password_QCheckBox)) - mouseClick( - waitForObject(names.oCC_ShareLinkWidget_lineEdit_password_QLineEdit), - 0, - 0, - Qt.NoModifier, - Qt.LeftButton, - ) - type(waitForObject(names.oCC_ShareLinkWidget_lineEdit_password_QLineEdit), password) - clickButton(waitForObject(names.oCC_ShareLinkWidget_createShareButton_QPushButton)) - waitFor( - lambda: ( - findObject(names.linkShares_0_0_QModelIndex).displayText == "Public link" - ) - ) + createPublicLinkShare(context, resource, password, permissions) -def createPublicShare(context, resource, role): +def createPublicShareWithRole(context, resource, role): resource = sanitizePath(substituteInLineCodes(context, resource)) - radioObjectName = '' - - if role == 'Viewer': - radioObjectName = names.oCC_ShareLinkWidget_radio_readOnly_QRadioButton - elif role == 'Editor': - radioObjectName = names.oCC_ShareLinkWidget_radio_readWrite_QRadioButton - elif role == 'Contributor': - radioObjectName = names.oCC_ShareLinkWidget_radio_uploadOnly_QRadioButton - else: - raise Exception("No such role found for resource") - - openPublicLinkDialog(context, resource) - clickButton(waitForObject(radioObjectName)) - clickButton(waitForObject(names.oCC_ShareLinkWidget_createShareButton_QPushButton)) - waitFor( - lambda: ( - findObject(names.linkShares_0_0_QModelIndex).displayText == "Public link" - ) - ) + openSharingDialog(context, resource) + publicLinkDialog = PublicLinkDialog() + publicLinkDialog.openPublicLinkDialog() + publicLinkDialog.createPublicLinkWithRole(role) @When( @@ -720,11 +515,11 @@ def step(context, resource): if role == '': raise Exception("No role has been found") else: - createPublicShare(context, resource, role) + createPublicShareWithRole(context, resource, role) @When( 'the user creates a new public link for folder "|any|" with "|any|" using the client-UI' ) def step(context, resource, role): - createPublicShare(context, resource, role) + createPublicShareWithRole(context, resource, role) diff --git a/test/gui/tst_sharing/test.feature b/test/gui/tst_sharing/test.feature index e434ed566..c0b62be12 100644 --- a/test/gui/tst_sharing/test.feature +++ b/test/gui/tst_sharing/test.feature @@ -81,7 +81,7 @@ Feature: Sharing Scenario: simple sharing of a folder by public link with password Given user "Alice" has created on the server folder "simple-folder" And user "Alice" has set up a client with default settings and password "1234" - When the user creates a new public link with permissions "Download / View " for folder "%client_sync_path%/simple-folder" with password "pass123" using the client-UI + When the user creates a new public link with permissions "Download / View" for folder "%client_sync_path%/simple-folder" with password "pass123" using the client-UI Then as user "Alice" the folder "simple-folder" should have a public link on the server And the public should be able to download the folder "lorem.txt" with password "pass123" from the last created public link by "Alice" on the server |