From 320913b73978028f550e2982c8620cd9f38e6b06 Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Sun, 10 Mar 2013 18:07:44 +0100 Subject: [PATCH] add GUI test directory --- .gitignore | 9 ++++-- doc/test.html | 2 + guitest/objects.map | 35 ++++++++++++++++++++++++ guitest/shared/scripts/common.py | 22 +++++++++++++++ guitest/suite.conf | 8 +++++ guitest/tst_login-prep/test.py | 54 ++++++++++++++++++++++++++++++++++++++ tests/setup-clean.sh | 5 +++ 7 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 guitest/envvars create mode 100644 guitest/objects.map create mode 100644 guitest/shared/scripts/common.py create mode 100644 guitest/suite.conf create mode 100644 guitest/tst_login-prep/test.py diff --git a/.gitignore b/.gitignore index b7bdbaf..352439f 100644 --- a/.gitignore +++ b/.gitignore @@ -43,16 +43,19 @@ dist-* debian/*log debian/*substvars debian/magicsmoke2-* +bin/* #Unit Test Environment tests/apache/*pid tests/apache/log tests/apache/www -tests/apache/etc/apache2.conf -tests/apache/etc/ssl.conf +tests/apache/etc/*.conf tests/apache/etc/server.* +tests/apache/etc/config.php tests/config tests/db/data tests/db/etc/environment tests/db/etc/*.conf -tests/db/run \ No newline at end of file +tests/db/run +tests/appdata +tests/appconf diff --git a/doc/test.html b/doc/test.html index 7f3ae5c..0264d0e 100644 --- a/doc/test.html +++ b/doc/test.html @@ -54,6 +54,8 @@ Tests are distributed over the following directories:

  • run - dynamically created directory that hold server logs, sockets and other housekeeping
  • ssl - contains the SSL certificates used for the tests, normally you should not need to alter them +
  • appdata - dynamically created: contains the profile data for the client under test +
  • appconf - dynamically created: contains the configuration data for the client under test
  • guitest - GUI test scripts for Squish
  • diff --git a/guitest/envvars b/guitest/envvars new file mode 100644 index 0000000..e69de29 diff --git a/guitest/objects.map b/guitest/objects.map new file mode 100644 index 0000000..f158d6b --- /dev/null +++ b/guitest/objects.map @@ -0,0 +1,35 @@ +:Chose Language.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':Chose Language_QInputDialog'} +:Chose Language_QInputDialog {type='QInputDialog' unnamed='1' visible='1' windowTitle='Chose Language'} +:Default Username:_QLabel {container=':qt_tabwidget_stackedwidget_QWidget' text='Default Username:' type='QLabel' unnamed='1' visible='1'} +:Default Username:_QLineEdit {container=':qt_tabwidget_stackedwidget_QWidget' leftWidget=':Default Username:_QLabel' type='QLineEdit' unnamed='1' visible='1'} +:Error.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':Error_QMessageBox'} +:Error_QMessageBox {type='QMessageBox' unnamed='1' visible='1' windowTitle='Error'} +:Import Key from File.splitter_QSplitter {name='splitter' type='QSplitter' visible='1' window=':Import Key from File_QFileDialog'} +:Import Key from File.toParentButton_QToolButton {name='toParentButton' type='QToolButton' visible='1' window=':Import Key from File_QFileDialog'} +:Import Key from File_QFileDialog {name='QFileDialog' type='QFileDialog' visible='1' windowTitle='Import Key from File'} +:Initial Profile Warning.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':Initial Profile Warning_QMessageBox'} +:Initial Profile Warning_QMessageBox {type='QMessageBox' unnamed='1' visible='1' windowTitle='Initial Profile Warning'} +:Magic Smoke Configuration.Profile_QMenu {title='Profile' type='QMenu' unnamed='1' visible='1' window=':Magic Smoke Configuration_MConfigDialog'} +:Magic Smoke Configuration.qt_tabwidget_stackedwidget_QStackedWidget {name='qt_tabwidget_stackedwidget' type='QStackedWidget' visible='1' window=':Magic Smoke Configuration_MConfigDialog'} +:Magic Smoke Configuration.qt_tabwidget_tabbar_QTabBar {name='qt_tabwidget_tabbar' type='QTabBar' visible='1' window=':Magic Smoke Configuration_MConfigDialog'} +:Magic Smoke Configuration_MConfigDialog {type='MConfigDialog' unnamed='1' visible='1' windowTitle='Magic Smoke Configuration'} +:Magic Smoke Configuration_QListView {type='QListView' unnamed='1' visible='1' window=':Magic Smoke Configuration_MConfigDialog'} +:Magic Smoke Configuration_QMenuBar {type='QMenuBar' unnamed='1' visible='1' window=':Magic Smoke Configuration_MConfigDialog'} +:Magic Smoke Login.Login_QPushButton {text='Login' type='QPushButton' unnamed='1' visible='1' window=':Magic Smoke Login_MLogin'} +:Magic Smoke Login_MLogin {type='MLogin' unnamed='1' visible='1' windowTitle='Magic Smoke Login'} +:New Profile.Please enter a profile name. It must be non-empty and must not be used yet:_QLabel {text='Please enter a profile name. It must be non-empty and must not be used yet:' type='QLabel' unnamed='1' visible='1' window=':New Profile_QInputDialog'} +:New Profile_QInputDialog {type='QInputDialog' unnamed='1' visible='1' windowTitle='New Profile'} +:Please enter a profile name. It must be non-empty and must not be used yet:_QLineEdit {buddy=':New Profile.Please enter a profile name. It must be non-empty and must not be used yet:_QLabel' type='QLineEdit' unnamed='1' visible='1'} +:Probe Server_QPushButton {container=':qt_tabwidget_stackedwidget_QWidget' text='Probe Server' type='QPushButton' unnamed='1' visible='1'} +:SSL Warning.Yes_QPushButton {text='Yes' type='QPushButton' unnamed='1' visible='1' window=':SSL Warning_QMessageBox'} +:SSL Warning_QMessageBox {type='QMessageBox' unnamed='1' visible='1' windowTitle='SSL Warning'} +:Server Probe.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':Server Probe_QMessageBox'} +:Server Probe_QMessageBox {type='QMessageBox' unnamed='1' visible='1' windowTitle='Server Probe'} +:Warning.Yes_QPushButton {text='Yes' type='QPushButton' unnamed='1' visible='1' window=':Warning_QMessageBox'} +:Warning_QMessageBox {type='QMessageBox' unnamed='1' visible='1' windowTitle='Warning'} +:frame.stackedWidget_QStackedWidget {container=':splitter.frame_QFrame' name='stackedWidget' type='QStackedWidget' visible='1'} +:https://_QLabel {container=':qt_tabwidget_stackedwidget_QWidget' text='https://' type='QLabel' unnamed='1' visible='1'} +:https://_QLineEdit {container=':qt_tabwidget_stackedwidget_QWidget' leftWidget=':https://_QLabel' type='QLineEdit' unnamed='1' visible='1'} +:qt_tabwidget_stackedwidget_QWidget {container=':Magic Smoke Configuration.qt_tabwidget_stackedwidget_QStackedWidget' type='QWidget' unnamed='1' visible='1'} +:splitter.frame_QFrame {container=':Import Key from File.splitter_QSplitter' name='frame' type='QFrame' visible='1'} +:stackedWidget.listView_QListView {container=':frame.stackedWidget_QStackedWidget' name='listView' type='QListView' visible='1'} diff --git a/guitest/shared/scripts/common.py b/guitest/shared/scripts/common.py new file mode 100644 index 0000000..e3c5fe2 --- /dev/null +++ b/guitest/shared/scripts/common.py @@ -0,0 +1,22 @@ +import subprocess + +MagicSmokeBasePath=squishinfo.testCase + "/../.." + +def startMagicSmoke(): + startApplication("magicsmoke -datadir=$APP/../tests/appdata -confdir=$APP/../tests/appconf") + +def cleanUpMagicSmoke(): + subprocess.call(MagicSmokeBasePath+"/tests/setup-stop.sh") + subprocess.call(MagicSmokeBasePath+"/tests/setup-clean.sh") + +def cleanUpClient(): + subprocess.call("rm -rf "+MagicSmokeBasePath+"/tests/appdata "+MagicSmokeBasePath+"/tests/appconf",shell=True) + +def startServer(): + subprocess.call(MagicSmokeBasePath+"/tests/setup-start.sh") + +def initServer(): + subprocess.call(MagicSmokeBasePath+"/tests/setup-create.sh") + +def stopServer(): + subprocess.call(MagicSmokeBasePath+"/tests/setup-stop.sh") \ No newline at end of file diff --git a/guitest/suite.conf b/guitest/suite.conf new file mode 100644 index 0000000..e0e5ed1 --- /dev/null +++ b/guitest/suite.conf @@ -0,0 +1,8 @@ +AUT=magicsmoke -datadir=$APP/../tests/appdata -confdir=$APP/../tests/appconf +ENVVARS=envvars +HOOK_SUB_PROCESSES=false +IMPLICITAUTSTART=0 +LANGUAGE=Python +TEST_CASES=tst_login-prep +VERSION=2 +WRAPPERS=Qt diff --git a/guitest/tst_login-prep/test.py b/guitest/tst_login-prep/test.py new file mode 100644 index 0000000..69c8abe --- /dev/null +++ b/guitest/tst_login-prep/test.py @@ -0,0 +1,54 @@ +source(findFile("scripts","common.py")) + +def init(): + cleanUpClient() + startServer() + initServer() + +def cleanup(): + stopServer() + +def createProfile(): + #we'll be asked for the language, ack C + clickButton(waitForObject(":Chose Language.OK_QPushButton",100)) + #yes we want an initial profile + clickButton(waitForObject(":Initial Profile Warning.OK_QPushButton",100)) + #create a profile + activateItem(waitForObjectItem(":Magic Smoke Configuration_QMenuBar", "Profile",100)) + activateItem(waitForObjectItem(":Magic Smoke Configuration.Profile_QMenu", "New Profile...",100)) + type(waitForObject(":Please enter a profile name. It must be non-empty and must not be used yet:_QLineEdit",100), "test") + type(waitForObject(":Please enter a profile name. It must be non-empty and must not be used yet:_QLineEdit",1), "") + #enter URL + type(waitForObject(":https://_QLineEdit",100), "") + type(waitForObject(":https://_QLineEdit",1), "") + type(waitForObject(":https://_QLineEdit",1), "localhost:20989/machine.php") + #go to authentication, import host key + clickTab(waitForObject(":Magic Smoke Configuration.qt_tabwidget_tabbar_QTabBar",100), "Authentication") + activateItem(waitForObjectItem(":Magic Smoke Configuration_QMenuBar", "Profile",100)) + activateItem(waitForObjectItem(":Magic Smoke Configuration.Profile_QMenu", "Import Host Key...",100)) + clickButton(waitForObject(":Warning.Yes_QPushButton",100)) + #we usually start in the application bin directory + # from here we go to ../tests/testhost.mshk + clickButton(waitForObject(":Import Key from File.toParentButton_QToolButton",2000)) + waitForObjectItem(":stackedWidget.listView_QListView", "tests",1000) + clickItem(":stackedWidget.listView_QListView", "tests", 41, 8, 0, Qt.LeftButton) + doubleClick(waitForObject(":stackedWidget.listView_QListView",1000), 136, 8, 0, Qt.LeftButton) + waitForObjectItem(":stackedWidget.listView_QListView", "testhost\\.mshk",1000) + clickItem(":stackedWidget.listView_QListView", "testhost\\.mshk", 103, 14, 0, Qt.LeftButton) + #enter a default user name too: admin + mouseClick(waitForObject(":Default Username:_QLineEdit",100), 14, 14, 0, Qt.LeftButton) + type(waitForObject(":Default Username:_QLineEdit",1), "admin") + #get the SSL exceptions + clickTab(waitForObject(":Magic Smoke Configuration.qt_tabwidget_tabbar_QTabBar",100), "SSL Exceptions") + clickButton(waitForObject(":Probe Server_QPushButton",100)) + clickButton(waitForObject(":SSL Warning.Yes_QPushButton",2000)) + clickButton(waitForObject(":Server Probe.OK_QPushButton",1000)) + #done, close dialog + activateItem(waitForObjectItem(":Magic Smoke Configuration_QMenuBar", "Profile",100)) + activateItem(waitForObjectItem(":Magic Smoke Configuration.Profile_QMenu", "Close Window",100)) + + +def main(): + startMagicSmoke() + createProfile() + sendEvent("QCloseEvent", waitForObject(":Magic Smoke Login_MLogin",1000)) diff --git a/tests/setup-clean.sh b/tests/setup-clean.sh index b9aa510..4d30602 100755 --- a/tests/setup-clean.sh +++ b/tests/setup-clean.sh @@ -28,4 +28,9 @@ rm -rf apache/log apache/www rm -f server.* mods.conf ) +#################################### +#Client + +rm -rf appdata appconf + exit 0 -- 1.7.2.5