Пример #1
0
 def testCreateNxdataFromDataset(self):
     widget = CustomNxdataWidget()
     model = widget.model()
     signal = commonh5.Dataset("foo", data=numpy.array([[[5]]]))
     model.createFromSignal(signal)
     widget.setVisible(True)
     self.qWaitForWindowExposed(widget)
Пример #2
0
 def testCreateNxdata(self):
     widget = CustomNxdataWidget()
     model = widget.model()
     model.createNewNxdata()
     model.createNewNxdata("Foo")
     widget.setVisible(True)
     self.qWaitForWindowExposed(widget)
Пример #3
0
 def testCreateNxdataFromDataset(self):
     widget = CustomNxdataWidget()
     model = widget.model()
     signal = commonh5.Dataset("foo", data=numpy.array([[[5]]]))
     model.createFromSignal(signal)
     widget.setVisible(True)
     self.qWaitForWindowExposed(widget)
Пример #4
0
 def testCreateNxdata(self):
     widget = CustomNxdataWidget()
     model = widget.model()
     model.createNewNxdata()
     model.createNewNxdata("Foo")
     widget.setVisible(True)
     self.qWaitForWindowExposed(widget)
Пример #5
0
 def testCreateNxdataFromNxdata(self):
     widget = CustomNxdataWidget()
     model = widget.model()
     data = numpy.array([[[5]]])
     nxdata = commonh5.Group("foo")
     nxdata.attrs["NX_class"] = "NXdata"
     nxdata.attrs["signal"] = "signal"
     nxdata.create_dataset("signal", data=data)
     model.createFromNxdata(nxdata)
     widget.setVisible(True)
     self.qWaitForWindowExposed(widget)
Пример #6
0
 def testCreateNxdataFromNxdata(self):
     widget = CustomNxdataWidget()
     model = widget.model()
     data = numpy.array([[[5]]])
     nxdata = commonh5.Group("foo")
     nxdata.attrs["NX_class"] = "NXdata"
     nxdata.attrs["signal"] = "signal"
     nxdata.create_dataset("signal", data=data)
     model.createFromNxdata(nxdata)
     widget.setVisible(True)
     self.qWaitForWindowExposed(widget)
Пример #7
0
class TestCustomNxdataWidgetInteraction(TestCaseQt):
    """Test CustomNxdataWidget with user interaction"""

    def setUp(self):
        TestCaseQt.setUp(self)

        self.widget = CustomNxdataWidget()
        self.model = self.widget.model()
        data = numpy.array([[[5]]])
        dataset = commonh5.Dataset("foo", data=data)
        self.model.createFromSignal(dataset)
        self.selectionModel = self.widget.selectionModel()

    def tearDown(self):
        self.selectionModel = None
        self.model.clear()
        self.model = None
        self.widget = None
        TestCaseQt.tearDown(self)

    def testSelectedNxdata(self):
        index = self.model.index(0, 0)
        self.selectionModel.setCurrentIndex(index, qt.QItemSelectionModel.ClearAndSelect)
        nxdata = self.widget.selectedNxdata()
        self.assertEqual(len(nxdata), 1)
        self.assertIsNot(nxdata[0], None)

    def testSelectedItems(self):
        index = self.model.index(0, 0)
        self.selectionModel.setCurrentIndex(index, qt.QItemSelectionModel.ClearAndSelect)
        items = self.widget.selectedItems()
        self.assertEqual(len(items), 1)
        self.assertIsNot(items[0], None)
        self.assertIsInstance(items[0], qt.QStandardItem)

    def testRowsAboutToBeRemoved(self):
        self.model.removeRow(0)
        self.qWaitForWindowExposed(self.widget)

    def testPaintItems(self):
        self.widget.expandAll()
        self.widget.setVisible(True)
        self.qWaitForWindowExposed(self.widget)

    def testCreateDefaultContextMenu(self):
        nxDataIndex = self.model.index(0, 0)
        menu = self.widget.createDefaultContextMenu(nxDataIndex)
        self.assertIsNot(menu, None)
        self.assertIsInstance(menu, qt.QMenu)

        signalIndex = self.model.index(0, 0, nxDataIndex)
        menu = self.widget.createDefaultContextMenu(signalIndex)
        self.assertIsNot(menu, None)
        self.assertIsInstance(menu, qt.QMenu)

        axesIndex = self.model.index(1, 0, nxDataIndex)
        menu = self.widget.createDefaultContextMenu(axesIndex)
        self.assertIsNot(menu, None)
        self.assertIsInstance(menu, qt.QMenu)

    def testDropNewDataset(self):
        dataset = commonh5.Dataset("foo", numpy.array([1, 2, 3, 4]))
        mimedata = Hdf5DatasetMimeData(dataset=dataset)
        self.model.dropMimeData(mimedata, qt.Qt.CopyAction, -1, -1, qt.QModelIndex())
        self.assertEqual(self.model.rowCount(qt.QModelIndex()), 2)

    def testDropNewNxdata(self):
        data = numpy.array([[[5]]])
        nxdata = commonh5.Group("foo")
        nxdata.attrs["NX_class"] = "NXdata"
        nxdata.attrs["signal"] = "signal"
        nxdata.create_dataset("signal", data=data)
        mimedata = Hdf5DatasetMimeData(dataset=nxdata)
        self.model.dropMimeData(mimedata, qt.Qt.CopyAction, -1, -1, qt.QModelIndex())
        self.assertEqual(self.model.rowCount(qt.QModelIndex()), 2)

    def testDropAxisDataset(self):
        dataset = commonh5.Dataset("foo", numpy.array([1, 2, 3, 4]))
        mimedata = Hdf5DatasetMimeData(dataset=dataset)
        nxDataIndex = self.model.index(0, 0)
        axesIndex = self.model.index(1, 0, nxDataIndex)
        self.model.dropMimeData(mimedata, qt.Qt.CopyAction, -1, -1, axesIndex)
        self.assertEqual(self.model.rowCount(qt.QModelIndex()), 1)
        item = self.model.itemFromIndex(axesIndex)
        self.assertIsNot(item.getDataset(), None)

    def testMimeData(self):
        nxDataIndex = self.model.index(0, 0)
        signalIndex = self.model.index(0, 0, nxDataIndex)
        mimeData = self.model.mimeData([signalIndex])
        self.assertIsNot(mimeData, None)
        self.assertIsInstance(mimeData, qt.QMimeData)

    def testRemoveNxdataItem(self):
        nxdataIndex = self.model.index(0, 0)
        item = self.model.itemFromIndex(nxdataIndex)
        self.model.removeNxdataItem(item)

    def testAppendAxisToNxdataItem(self):
        nxdataIndex = self.model.index(0, 0)
        item = self.model.itemFromIndex(nxdataIndex)
        self.model.appendAxisToNxdataItem(item)

    def testRemoveAxisItem(self):
        nxdataIndex = self.model.index(0, 0)
        axesIndex = self.model.index(1, 0, nxdataIndex)
        item = self.model.itemFromIndex(axesIndex)
        self.model.removeAxisItem(item)
Пример #8
0
class TestCustomNxdataWidgetInteraction(TestCaseQt):
    """Test CustomNxdataWidget with user interaction"""
    def setUp(self):
        TestCaseQt.setUp(self)

        self.widget = CustomNxdataWidget()
        self.model = self.widget.model()
        data = numpy.array([[[5]]])
        dataset = commonh5.Dataset("foo", data=data)
        self.model.createFromSignal(dataset)
        self.selectionModel = self.widget.selectionModel()

    def tearDown(self):
        self.selectionModel = None
        self.model.clear()
        self.model = None
        self.widget = None
        TestCaseQt.tearDown(self)

    def testSelectedNxdata(self):
        index = self.model.index(0, 0)
        self.selectionModel.setCurrentIndex(
            index, qt.QItemSelectionModel.ClearAndSelect)
        nxdata = self.widget.selectedNxdata()
        self.assertEqual(len(nxdata), 1)
        self.assertIsNot(nxdata[0], None)

    def testSelectedItems(self):
        index = self.model.index(0, 0)
        self.selectionModel.setCurrentIndex(
            index, qt.QItemSelectionModel.ClearAndSelect)
        items = self.widget.selectedItems()
        self.assertEqual(len(items), 1)
        self.assertIsNot(items[0], None)
        self.assertIsInstance(items[0], qt.QStandardItem)

    def testRowsAboutToBeRemoved(self):
        self.model.removeRow(0)
        self.qWaitForWindowExposed(self.widget)

    def testPaintItems(self):
        self.widget.expandAll()
        self.widget.setVisible(True)
        self.qWaitForWindowExposed(self.widget)

    def testCreateDefaultContextMenu(self):
        nxDataIndex = self.model.index(0, 0)
        menu = self.widget.createDefaultContextMenu(nxDataIndex)
        self.assertIsNot(menu, None)
        self.assertIsInstance(menu, qt.QMenu)

        signalIndex = self.model.index(0, 0, nxDataIndex)
        menu = self.widget.createDefaultContextMenu(signalIndex)
        self.assertIsNot(menu, None)
        self.assertIsInstance(menu, qt.QMenu)

        axesIndex = self.model.index(1, 0, nxDataIndex)
        menu = self.widget.createDefaultContextMenu(axesIndex)
        self.assertIsNot(menu, None)
        self.assertIsInstance(menu, qt.QMenu)

    def testDropNewDataset(self):
        dataset = commonh5.Dataset("foo", numpy.array([1, 2, 3, 4]))
        mimedata = Hdf5DatasetMimeData(dataset=dataset)
        self.model.dropMimeData(mimedata, qt.Qt.CopyAction, -1, -1,
                                qt.QModelIndex())
        self.assertEqual(self.model.rowCount(qt.QModelIndex()), 2)

    def testDropNewNxdata(self):
        data = numpy.array([[[5]]])
        nxdata = commonh5.Group("foo")
        nxdata.attrs["NX_class"] = "NXdata"
        nxdata.attrs["signal"] = "signal"
        nxdata.create_dataset("signal", data=data)
        mimedata = Hdf5DatasetMimeData(dataset=nxdata)
        self.model.dropMimeData(mimedata, qt.Qt.CopyAction, -1, -1,
                                qt.QModelIndex())
        self.assertEqual(self.model.rowCount(qt.QModelIndex()), 2)

    def testDropAxisDataset(self):
        dataset = commonh5.Dataset("foo", numpy.array([1, 2, 3, 4]))
        mimedata = Hdf5DatasetMimeData(dataset=dataset)
        nxDataIndex = self.model.index(0, 0)
        axesIndex = self.model.index(1, 0, nxDataIndex)
        self.model.dropMimeData(mimedata, qt.Qt.CopyAction, -1, -1, axesIndex)
        self.assertEqual(self.model.rowCount(qt.QModelIndex()), 1)
        item = self.model.itemFromIndex(axesIndex)
        self.assertIsNot(item.getDataset(), None)

    def testMimeData(self):
        nxDataIndex = self.model.index(0, 0)
        signalIndex = self.model.index(0, 0, nxDataIndex)
        mimeData = self.model.mimeData([signalIndex])
        self.assertIsNot(mimeData, None)
        self.assertIsInstance(mimeData, qt.QMimeData)

    def testRemoveNxdataItem(self):
        nxdataIndex = self.model.index(0, 0)
        item = self.model.itemFromIndex(nxdataIndex)
        self.model.removeNxdataItem(item)

    def testAppendAxisToNxdataItem(self):
        nxdataIndex = self.model.index(0, 0)
        item = self.model.itemFromIndex(nxdataIndex)
        self.model.appendAxisToNxdataItem(item)

    def testRemoveAxisItem(self):
        nxdataIndex = self.model.index(0, 0)
        axesIndex = self.model.index(1, 0, nxdataIndex)
        item = self.model.itemFromIndex(axesIndex)
        self.model.removeAxisItem(item)