From e9ae93e2c04fd4c8fbd649b7be411025826313a8 Mon Sep 17 00:00:00 2001 From: Swoichha Adhikari Date: Mon, 9 Aug 2021 12:52:48 +0545 Subject: [PATCH] [Tests Only] add test for enable/disable vfs (#8835) * [Tests Only] add test for vfs * add test for disabling vfs * vfs object from model * make code DRY * added few comment for coordinates --- test/gui/shared/scripts/names.py | 5 ++- test/gui/shared/steps/steps.py | 62 ++++++++++++++++++++++++++++++++ test/gui/suite.conf | 2 +- test/gui/tst_vfs/test.feature | 20 +++++++++++ test/gui/tst_vfs/test.py | 9 +++++ 5 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 test/gui/tst_vfs/test.feature create mode 100644 test/gui/tst_vfs/test.py diff --git a/test/gui/shared/scripts/names.py b/test/gui/shared/scripts/names.py index 01df761a5da..783b35dbe17 100644 --- a/test/gui/shared/scripts/names.py +++ b/test/gui/shared/scripts/names.py @@ -98,4 +98,7 @@ o_tableView_0_1_QModelIndex = {"column": 1, "container": oCC_IssuesWidget_tableView_QTableView, "row": 0, "type": "QModelIndex"} settings_settingsdialog_toolbutton_Add_account_QToolButton = {"name": "settingsdialog_toolbutton_Add account", "type": "QToolButton", "visible": 1, "window": settings_OCC_SettingsDialog} settings_settingsdialog_toolbutton_Activity_QToolButton = {"name": "settingsdialog_toolbutton_Activity", "type": "QToolButton", "visible": 1, "window": settings_OCC_SettingsDialog} -sharingDialog_Close_QPushButton = {"text": "Close", "type": "QPushButton", "unnamed": 1, "visible": 1, "window": sharingDialog_OCC_ShareDialog} \ No newline at end of file +sharingDialog_Close_QPushButton = {"text": "Close", "type": "QPushButton", "unnamed": 1, "visible": 1, "window": sharingDialog_OCC_ShareDialog} +stack_Enable_experimental_placeholder_mode_QPushButton = {"container": settings_stack_QStackedWidget, "text": "Enable experimental placeholder mode", "type": "QPushButton", "unnamed": 1, "visible": 1} +disable_virtual_file_support_QMessageBox = {"type": "QMessageBox", "unnamed": 1, "visible": 1, "windowTitle": "Disable virtual file support?"} +disable_virtual_file_support_Disable_support_QPushButton = {"text": "Disable support", "type": "QPushButton", "unnamed": 1, "visible": 1, "window": disable_virtual_file_support_QMessageBox} diff --git a/test/gui/shared/steps/steps.py b/test/gui/shared/steps/steps.py index 56f8aceef9e..85a99f70f59 100644 --- a/test/gui/shared/steps/steps.py +++ b/test/gui/shared/steps/steps.py @@ -744,3 +744,65 @@ def step(context, resource, content): print("file has been overwritten") waitForFileToBeSynced(context, resource) + + +def enableVFSSupport(vfsBtnText): + # The enabling/disabling VFS button do not have it's own object + # But it is inside the "stack_folderList_QTreeView" object. + # So we are clicking at (718, 27) of "stack_folderList_QTreeView" object to enable/disable VFS + mouseClick( + waitForObjectItem(names.stack_folderList_QTreeView, "_1"), + 718, + 27, + Qt.NoModifier, + Qt.LeftButton, + ) + activateItem(waitForObjectItem(names.settings_QMenu, vfsBtnText)) + clickButton( + waitForObject(names.stack_Enable_experimental_placeholder_mode_QPushButton) + ) + + +@When("the user enables virtual file support") +def step(context): + enableVFSSupport("Enable virtual file support (experimental)...") + + +@Then('the "|any|" button should be available') +def step(context, btnText): + # The enabling/disabling VFS button do not have it's own object + # But it is inside the "stack_folderList_QTreeView" object. + # So we are clicking at (718, 27) of "stack_folderList_QTreeView" object to enable/disable VFS + mouseClick( + waitForObjectItem(names.stack_folderList_QTreeView, "_1"), + 718, + 27, + Qt.NoModifier, + Qt.LeftButton, + ) + waitForObjectItem(names.settings_QMenu, btnText) + + +@Given("the user has enabled virtual file support") +def step(context): + enableVFSSupport("Enable virtual file support (experimental)...") + + +@When("the user disables virtual file support") +def step(context): + # The enabling/disabling VFS button do not have it's own object + # But it is inside the "stack_folderList_QTreeView" object. + # So we are clicking at (718, 27) of "stack_folderList_QTreeView" object to enable/disable VFS + mouseClick( + waitForObjectItem(names.stack_folderList_QTreeView, "_1"), + 733, + 27, + Qt.NoModifier, + Qt.LeftButton, + ) + activateItem( + waitForObjectItem(names.settings_QMenu, "Disable virtual file support...") + ) + clickButton( + waitForObject(names.disable_virtual_file_support_Disable_support_QPushButton) + ) diff --git a/test/gui/suite.conf b/test/gui/suite.conf index cbb183980ee..fd4cbf70171 100644 --- a/test/gui/suite.conf +++ b/test/gui/suite.conf @@ -4,6 +4,6 @@ HOOK_SUB_PROCESSES=false IMPLICITAUTSTART=0 LANGUAGE=Python OBJECTMAPSTYLE=script -TEST_CASES=tst_addAccount tst_sharing tst_syncing tst_loginLogout tst_removeAccountConnection tst_checkAlltabs +TEST_CASES=tst_addAccount tst_sharing tst_syncing tst_loginLogout tst_removeAccountConnection tst_checkAlltabs tst_vfs VERSION=3 WRAPPERS=Qt diff --git a/test/gui/tst_vfs/test.feature b/test/gui/tst_vfs/test.feature new file mode 100644 index 00000000000..8bcb23bd0a0 --- /dev/null +++ b/test/gui/tst_vfs/test.feature @@ -0,0 +1,20 @@ +Feature: Enable/disable virtual file support + + As a user + I want to enable virtual file support + So that I can synchronize virtual files with local folder + + + Scenario: Enable VFS + Given user "Alice" has been created on the server with default attributes and without skeleton files + And user "Alice" has set up a client with default settings + When the user enables virtual file support + Then the "Disable virtual file support..." button should be available + + + Scenario: Disable VFS + Given user "Alice" has been created on the server with default attributes and without skeleton files + And user "Alice" has set up a client with default settings + And the user has enabled virtual file support + When the user disables virtual file support + Then the "Enable virtual file support (experimental)..." button should be available \ No newline at end of file diff --git a/test/gui/tst_vfs/test.py b/test/gui/tst_vfs/test.py new file mode 100644 index 00000000000..d6224b99e57 --- /dev/null +++ b/test/gui/tst_vfs/test.py @@ -0,0 +1,9 @@ +source(findFile('scripts', 'python/bdd.py')) + +setupHooks('../shared/scripts/bdd_hooks.py') +collectStepDefinitions('./steps', '../shared/steps') + + +def main(): + testSettings.throwOnFailure = True + runFeatureFile('test.feature')