def testClickOnBackToParentTool(self): if h5py is None: self.skipTest("h5py is missing") dialog = self.createDialog() dialog.show() self.qWaitForWindowExposed(dialog) url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] action = utils.findChildren(dialog, qt.QAction, name="toParentAction")[0] toParentButton = utils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data.h5" # init state path = silx.io.url.DataUrl(file_path=filename, data_path="/group/image").path() dialog.selectUrl(path) self.qWaitForPendingActions(dialog) path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/group/image").path() self.assertSamePath(url.text(), path) # test self.mouseClick(toParentButton, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/").path() self.assertSamePath(url.text(), path) self.mouseClick(toParentButton, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertSamePath(url.text(), _tmpDirectory) self.mouseClick(toParentButton, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertSamePath(url.text(), os.path.dirname(_tmpDirectory))
def testClickOnBackToDirectoryTool(self): if h5py is None: self.skipTest("h5py is missing") dialog = self.createDialog() dialog.show() self.qWaitForWindowExposed(dialog) url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] action = utils.findChildren(dialog, qt.QAction, name="toDirectoryAction")[0] button = utils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data.h5" # init state path = silx.io.url.DataUrl(file_path=filename, data_path="/group/image").path() dialog.selectUrl(path) self.qWaitForPendingActions(dialog) path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/group/image").path() self.assertSamePath(url.text(), path) self.assertTrue(button.isEnabled()) # test self.mouseClick(button, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertSamePath(url.text(), _tmpDirectory) self.assertFalse(button.isEnabled()) # FIXME: There is an unreleased qt.QWidget without nameObject # No idea where it come from. self.allowedLeakingWidgets = 1
def testClickOnShortcut(self): dialog = self.createDialog() dialog.show() self.qWaitForWindowExposed(dialog) sidebar = utils.findChildren(dialog, qt.QListView, name="sidebar")[0] url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] browser = utils.findChildren(dialog, qt.QWidget, name="browser")[0] dialog.setDirectory(_tmpDirectory) self.qWaitForPendingActions(dialog) self.assertSamePath(url.text(), _tmpDirectory) urls = sidebar.urls() if len(urls) == 0: self.skipTest("No sidebar path") path = urls[0].path() if path != "" and not os.path.exists(path): self.skipTest("Sidebar path do not exists") index = sidebar.model().index(0, 0) # rect = sidebar.visualRect(index) # self.mouseClick(sidebar, qt.Qt.LeftButton, pos=rect.center()) # Using mouse click is not working, let's use the selection API sidebar.selectionModel().select(index, qt.QItemSelectionModel.ClearAndSelect) self.qWaitForPendingActions(dialog) index = browser.rootIndex() if not index.isValid(): path = "" else: path = index.model().filePath(index) self.assertNotSamePath(_tmpDirectory, path) self.assertNotSamePath(url.text(), _tmpDirectory)
def testClickOnBackToRootTool(self): if h5py is None: self.skipTest("h5py is missing") dialog = self.createDialog() dialog.show() self.qWaitForWindowExposed(dialog) url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] action = utils.findChildren(dialog, qt.QAction, name="toRootFileAction")[0] button = utils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data.h5" # init state path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/group/image").path() dialog.selectUrl(path) self.qWaitForPendingActions(dialog) self.assertSamePath(url.text(), path) self.assertTrue(button.isEnabled()) # test self.mouseClick(button, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/").path() self.assertSamePath(url.text(), path)
def testClickOnBackToParentTool(self): dialog = self.createDialog() dialog.show() self.qWaitForWindowExposed(dialog) url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] action = testutils.findChildren(dialog, qt.QAction, name="toParentAction")[0] toParentButton = testutils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data/data.h5" # init state path = silx.io.url.DataUrl(file_path=filename, data_path="/group/image").path() dialog.selectUrl(path) self.qWaitForPendingActions(dialog) path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/group/image").path() self.assertSamePath(url.text(), path) # test self.mouseClick(toParentButton, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/").path() self.assertSamePath(url.text(), path) self.mouseClick(toParentButton, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertSamePath(url.text(), _tmpDirectory + "/data") self.mouseClick(toParentButton, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertSamePath(url.text(), _tmpDirectory)
def testClickOnHistoryTools(self): if h5py is None: self.skipTest("h5py is missing") dialog = self.createDialog() dialog.show() self.qWaitForWindowExposed(dialog) url = utils.findChildren(dialog, qt.QLineEdit, name="url")[0] forwardAction = utils.findChildren(dialog, qt.QAction, name="forwardAction")[0] backwardAction = utils.findChildren(dialog, qt.QAction, name="backwardAction")[0] filename = _tmpDirectory + "/data.h5" dialog.setDirectory(_tmpDirectory) self.qWaitForPendingActions(dialog) # No way to use QTest.mouseDClick with QListView, QListWidget # Then we feed the history using selectPath dialog.selectUrl(filename) self.qWaitForPendingActions(dialog) path2 = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/").path() dialog.selectUrl(path2) self.qWaitForPendingActions(dialog) path3 = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/group").path() dialog.selectUrl(path3) self.qWaitForPendingActions(dialog) self.assertFalse(forwardAction.isEnabled()) self.assertTrue(backwardAction.isEnabled()) button = utils.getQToolButtonFromAction(backwardAction) self.mouseClick(button, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertTrue(forwardAction.isEnabled()) self.assertTrue(backwardAction.isEnabled()) self.assertSamePath(url.text(), path2) button = utils.getQToolButtonFromAction(forwardAction) self.mouseClick(button, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) self.assertFalse(forwardAction.isEnabled()) self.assertTrue(backwardAction.isEnabled()) self.assertSamePath(url.text(), path3)
def testClickOnBackToRootTool(self): dialog = self.createDialog() dialog.show() self.qWaitForWindowExposed(dialog) url = testutils.findChildren(dialog, qt.QLineEdit, name="url")[0] action = testutils.findChildren(dialog, qt.QAction, name="toRootFileAction")[0] button = testutils.getQToolButtonFromAction(action) filename = _tmpDirectory + "/data.h5" # init state path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/group/image").path() dialog.selectUrl(path) self.qWaitForPendingActions(dialog) self.assertSamePath(url.text(), path) self.assertTrue(button.isEnabled()) # test self.mouseClick(button, qt.Qt.LeftButton) self.qWaitForPendingActions(dialog) path = silx.io.url.DataUrl(scheme="silx", file_path=filename, data_path="/").path() self.assertSamePath(url.text(), path)