diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2013-04-11 21:11:32 -0300 |
---|---|---|
committer | Bruno Oliveira <nicoddemus@gmail.com> | 2013-04-11 21:11:32 -0300 |
commit | 28152ba2e959571f06688617620bf8ef53fdc716 (patch) | |
tree | e10378e7f47afbc58cbbe1741d5207796e9c6f97 | |
parent | 6587efbcbcdb9241ab8a5f06153d32294ec4f6b5 (diff) |
added test for examples/dialogs/findfiles.py
-rwxr-xr-x | examples/dialogs/findfiles.py | 10 | ||||
-rw-r--r-- | examples/dialogs/findfiles_test.py | 37 |
2 files changed, 42 insertions, 5 deletions
diff --git a/examples/dialogs/findfiles.py b/examples/dialogs/findfiles.py index 5206f7f..adc61ba 100755 --- a/examples/dialogs/findfiles.py +++ b/examples/dialogs/findfiles.py @@ -9,8 +9,8 @@ class Window(QtGui.QDialog): def __init__(self, parent=None): super(Window, self).__init__(parent) - browseButton = self.createButton("&Browse...", self.browse) - findButton = self.createButton("&Find", self.find) + self.browseButton = self.createButton("&Browse...", self.browse) + self.findButton = self.createButton("&Find", self.find) self.fileComboBox = self.createComboBox("*") self.textComboBox = self.createComboBox() @@ -25,7 +25,7 @@ class Window(QtGui.QDialog): buttonsLayout = QtGui.QHBoxLayout() buttonsLayout.addStretch() - buttonsLayout.addWidget(findButton) + buttonsLayout.addWidget(self.findButton) mainLayout = QtGui.QGridLayout() mainLayout.addWidget(fileLabel, 0, 0) @@ -34,14 +34,14 @@ class Window(QtGui.QDialog): mainLayout.addWidget(self.textComboBox, 1, 1, 1, 2) mainLayout.addWidget(directoryLabel, 2, 0) mainLayout.addWidget(self.directoryComboBox, 2, 1) - mainLayout.addWidget(browseButton, 2, 2) + mainLayout.addWidget(self.browseButton, 2, 2) mainLayout.addWidget(self.filesTable, 3, 0, 1, 3) mainLayout.addWidget(self.filesFoundLabel, 4, 0) mainLayout.addLayout(buttonsLayout, 5, 0, 1, 3) self.setLayout(mainLayout) self.setWindowTitle("Find Files") - self.resize(700, 300) + self.resize(500, 300) def browse(self): directory = QtGui.QFileDialog.getExistingDirectory(self, "Find Files", diff --git a/examples/dialogs/findfiles_test.py b/examples/dialogs/findfiles_test.py new file mode 100644 index 0000000..2d51415 --- /dev/null +++ b/examples/dialogs/findfiles_test.py @@ -0,0 +1,37 @@ +from findfiles import Window
+from PySide import QtCore
+
+
+#===================================================================================================
+# test_basic_search
+#===================================================================================================
+def test_basic_search(qtbot, tmpdir):
+ '''
+ test to ensure basic find files functionality is working.
+ '''
+ tmpdir.join('video1.avi').ensure()
+ tmpdir.join('video1.srt').ensure()
+
+ tmpdir.join('video2.avi').ensure()
+ tmpdir.join('video2.srt').ensure()
+
+ window = Window()
+ window.show()
+ qtbot.addWidget(window)
+ qtbot.stopForInteraction()
+
+ window.fileComboBox.clear()
+ qtbot.keyClicks(window.fileComboBox, '*.avi')
+
+ window.directoryComboBox.clear()
+ qtbot.keyClicks(window.directoryComboBox, str(tmpdir))
+
+ qtbot.mouseClick(window.findButton, QtCore.Qt.LeftButton)
+
+ assert window.filesTable.rowCount() == 2
+ assert window.filesTable.item(0, 0).text() == 'video1.avi'
+ assert window.filesTable.item(1, 0).text() == 'video2.avi'
+
+
+
+
\ No newline at end of file |