Example #1
0
 def test_presseing_esc_does_not_close_or_clear_the_data_window(self):
     dw = self.aw.datawindow
     self.aw.show()
     self.assertTrue(dw.isVisible())
     QTest.keyPress(dw, Qt.Key_Escape)
     self.assertTrue(dw.isVisible())
     self.aw.hide()
 def write_to_input_line(self, text):
     '''emulate writing to inputline and press return'''
     pv = self.pile_viewer
     il = pv.inputline
     QTest.keyPress(pv, ':')
     QTest.keyClicks(il, text)
     QTest.keyPress(il, Qt.Key_Return)
Example #3
0
 def test_get_information_returns_the_right_data(self):
     # create some groups
     item = self.aw.datawindow.ui.no_groups
     set_text_spinbox(item, 12)
     A1 = 1.12e-4
     N01 = 1.34e-5
     cost1 = 22.
     A2 = 1.2e-4
     N02 = 2.2e-1
     one = self.aw.datawindow.assetgrouplist[11]
     set_text_textbox(one.A, A1)
     A1 = float(one.A.text())
     set_text_textbox(one.N0, N01)
     N01 = float(one.N0.text())
     set_text_textbox(one.cost, cost1)
     cost1 = float(one.cost.text())
     box = self.aw.datawindow.assetgrouplist[2]
     set_text_textbox(box.A, A2)
     A2 = float(box.A.text())
     set_text_textbox(box.N0, N02)
     N02 = float(box.N0.text())
     set_text_spinbox(item, 4)
     QTest.keyPress(item, Qt.Key_Return)  # now we have only 4 active items
     active, values = self.aw.datawindow.get_information(all=True)
     self.assertEqual(active, 4)
     self.assertEqual(values[11][0], A1)
     self.assertEqual(values[11][1], N01)
     self.assertEqual(values[11][2], cost1)
     self.assertEqual(values[2][0], A2)
     self.assertEqual(values[2][1], N02)
Example #4
0
    def test_markers(self):
        self.add_one_pick()
        pv = self.pile_viewer
        self.assertEqual(pv.viewer.get_active_event(), None)

        conf = config.config('snuffler')

        # test kinds and phases
        kinds = range(5)
        fkey_map = pyrocko_pile_viewer.fkey_map

        for k in kinds:
            for fkey, fkey_int in fkey_map.items():
                fkey_int += 1
                QTest.keyPress(pv, fkey)
                QTest.keyPress(pv, str(k))

                if fkey_int != 10:
                    want = conf.phase_key_mapping.get("F%s" % fkey_int,
                                                      'Undefined')
                else:
                    want = None
                m = pv.viewer.get_markers()[0]
                self.assertEqual(m.kind, k)
                if want:
                    self.assertEqual(m.get_phasename(), want)
    def test_load_save_markers(self):
        nmarkers = 505
        times = num.arange(nmarkers)
        markers = [gui_util.Marker(tmin=t, tmax=t,
                                   nslc_ids=[('*', '*', '*', '*'), ])
                   for t in times]

        tempfn = self.get_tempfile()
        tempfn_selected = self.get_tempfile()

        self.viewer.add_markers(markers)
        self.viewer.write_selected_markers(
            fn=tempfn_selected)
        self.viewer.write_markers(fn=tempfn)

        self.viewer.read_markers(fn=tempfn_selected)
        self.viewer.read_markers(fn=tempfn)

        for k in 'pnPN':
            QTest.keyPress(self.pile_viewer, k)

        self.viewer.go_to_time(-20., 20)
        self.pile_viewer.update()
        self.viewer.update()
        assert(len(self.viewer.markers) != 0)
        assert(len(self.viewer.markers) == nmarkers * 2)
        len_before = len(self.viewer.markers)
        self.viewer.remove_marker(
            self.viewer.markers[0])
        assert(len(self.viewer.markers) == len_before-1)
        self.viewer.remove_markers(self.viewer.markers)
        assert(len(self.viewer.markers) == 0)
Example #6
0
    def test_load_save_markers(self):
        nmarkers = 505
        times = num.arange(nmarkers)
        markers = [
            gui_util.Marker(tmin=t, tmax=t, nslc_ids=[
                ('*', '*', '*', '*'),
            ]) for t in times
        ]

        tempfn = self.get_tempfile()
        tempfn_selected = self.get_tempfile()

        self.viewer.add_markers(markers)
        self.viewer.write_selected_markers(fn=tempfn_selected)
        self.viewer.write_markers(fn=tempfn)

        self.viewer.read_markers(fn=tempfn_selected)
        self.viewer.read_markers(fn=tempfn)

        for k in 'pnPN':
            QTest.keyPress(self.pile_viewer, k)

        self.viewer.go_to_time(-20., 20)
        self.pile_viewer.update()
        self.viewer.update()
        assert (len(self.viewer.markers) != 0)
        assert (len(self.viewer.markers) == nmarkers * 2)
        len_before = len(self.viewer.markers)
        self.viewer.remove_marker(self.viewer.markers[0])
        assert (len(self.viewer.markers) == len_before - 1)
        self.viewer.remove_markers(self.viewer.markers)
        assert (len(self.viewer.markers) == 0)
Example #7
0
 def write_to_input_line(self, text):
     '''emulate writing to inputline and press return'''
     pv = self.pile_viewer
     il = pv.inputline
     QTest.keyPress(pv, ':')
     QTest.keyClicks(il, text)
     QTest.keyPress(il, Qt.Key_Return)
Example #8
0
    def test_inputline(self):
        initrange = self.viewer.shown_tracks_range

        self.write_to_input_line('hide W.X.Y.Z')
        self.write_to_input_line('unhide W.X.Y.Z')
        self.pile_viewer.update()

        self.write_to_input_line('hide *')
        self.pile_viewer.update()

        assert (self.viewer.shown_tracks_range == (0, 1))
        self.write_to_input_line('unhide')

        assert (self.viewer.shown_tracks_range == initrange)

        self.write_to_input_line('markers')
        self.write_to_input_line('markers 4')
        self.write_to_input_line('markers all')

        # should error
        self.write_to_input_line('scaling 1000.')
        self.write_to_input_line('scaling -1000. 1000.')

        gotos = [
            '2015-01-01 00:00:00', '2015-01-01 00:00', '2015-01-01 00',
            '2015-01-01', '2015-01', '2015'
        ]

        for gt in gotos:
            self.write_to_input_line('goto %s' % gt)

        # test some false input
        self.write_to_input_line('asdf')
        QTest.keyPress(self.pile_viewer.inputline, Qt.Key_Escape)
    def testSmartStringLineEdit(self):
        widget = SmartStringLineEdit("abc")
        spy = QSignalSpy(widget.value_changed_sgn)

        # set an empty string
        widget.clear()
        QTest.keyPress(widget, Qt.Key_Enter)
        self.assertEqual(0, len(spy))

        # set a space
        widget.clear()
        QTest.keyClicks(widget, ' ')
        QTest.keyPress(widget, Qt.Key_Enter)
        self.assertEqual(0, len(spy))

        # a string started with a space is allowed
        widget.clear()
        QTest.keyClicks(widget, ' Any')
        QTest.keyPress(widget, Qt.Key_Enter)
        self.assertEqual(1, len(spy))

        # a Karabo device ID
        widget.clear()
        QTest.keyClicks(widget, 'SA3_XTD10_MONO/MDL/PHOTON_ENERGY')
        QTest.keyPress(widget, Qt.Key_Enter)
        self.assertEqual(2, len(spy))

        # a string started with number and contains special characters and white spaces
        widget.clear()
        QTest.keyClicks(widget, '123 *$ Any')
        QTest.keyPress(widget, Qt.Key_Enter)
        self.assertEqual(3, len(spy))
Example #10
0
    def testCtrl(self):
        win = self._win
        ctrl_widget = win._ctrl_widget_st
        proc = win._worker_st

        # test default values
        self.assertTrue(proc._magnet_device_id)
        self.assertEqual(_DEFAULT_CURRENT_THRESHOLD, proc._current_threshold)

        # test set new values

        widget = ctrl_widget.magnet_device_le
        widget.clear()
        QTest.keyClicks(widget, "new/output/channel")
        QTest.keyPress(widget, Qt.Key_Enter)
        self.assertEqual("new/output/channel", proc._magnet_device_id)

        widget = ctrl_widget.current_threshold_le
        widget.clear()
        QTest.keyClicks(widget, "0.1")
        QTest.keyPress(widget, Qt.Key_Enter)
        self.assertEqual(0.1, proc._current_threshold)

        # only allow to display the spectra of one channel
        for i, widget in enumerate(ctrl_widget.spectra_displayed.buttons()):
            QTest.mouseClick(widget,
                             Qt.LeftButton,
                             pos=QPoint(2,
                                        widget.height() / 2))
            self.assertEqual(i, win._pn_spectra._displayed)
            self.assertEqual(i, win._xas_xmcd_spectra._displayed)
    def test_markers(self):
        self.add_one_pick()
        pv = self.pile_viewer
        self.assertEqual(pv.viewer.get_active_event(), None)

        conf = config.config('snuffler')

        # test kinds and phases
        kinds = range(5)
        fkey_map = pyrocko_pile_viewer.fkey_map

        for k in kinds:
            for fkey, fkey_int in fkey_map.items():
                fkey_int += 1
                QTest.keyPress(pv, fkey)
                QTest.keyPress(pv, str(k))

                if fkey_int != 10:
                    want = conf.phase_key_mapping.get(
                        "F%s" % fkey_int, 'Undefined')
                else:
                    want = None
                m = pv.viewer.get_markers()[0]
                self.assertEqual(m.kind, k)
                if want:
                    self.assertEqual(m.get_phasename(), want)
    def testSmartSliceLineEdit(self):
        # test initialization with invalid content
        with self.assertRaises(ValueError):
            SmartSliceLineEdit("")

        # test initialization
        widget = SmartIdLineEdit("0:10:1")
        self.assertEqual("0:10:1", widget._cached)
        spy = QSignalSpy(widget.value_changed_sgn)
        self.assertEqual(0, len(spy))

        # set an invalid value
        widget.clear()
        QTest.keyClicks(widget, "0:10:2:2")
        QTest.keyPress(widget, Qt.Key_Enter)
        self.assertEqual("0:10:2:2", widget.text())
        self.assertEqual("0:10:1", widget._cached)
        self.assertEqual(0, len(spy))

        # set a valid value again
        widget.clear()
        QTest.keyClicks(widget, "0:10")
        QTest.keyPress(widget, Qt.Key_Enter)
        self.assertEqual("0:10", widget.text())
        self.assertEqual("0:10", widget._cached)
        self.assertEqual(1, len(spy))
    def tearDownClass(cls):
        '''
        Quit snuffler.
        '''
        if no_gui:  # nosetests runs this even when class is has @skip
            return

        QTest.keyPress(cls.pile_viewer, 'q')
Example #14
0
    def testThresholdMask(self, on_mask_mediator, on_mask):
        widget = self.image_tool._image_ctrl_widget

        widget.threshold_mask_le.clear()
        QTest.keyClicks(widget.threshold_mask_le, "1, 10")
        QTest.keyPress(widget.threshold_mask_le, Qt.Key_Enter)
        on_mask.assert_called_once_with((1, 10))
        on_mask_mediator.assert_called_once_with((1, 10))
Example #15
0
    def tearDownClass(cls):
        '''
        Quit snuffler.
        '''
        if no_gui:  # nosetests runs this even when class is has @skip
            return

        QTest.keyPress(cls.pile_viewer, 'q')
Example #16
0
def start_dialog(editor):
    print("start_dialog")
    global dialog_result

    dialog_result['title'] = editor.mainwindow.windowTitle()
    # simulate press of  'Ctrl-Q'
    QTest.keyPress(editor.mainwindow, Qt.Key_Q, Qt.ControlModifier)
    dialog_result['closed_window'] = editor.mainwindow.close()
    editor._app.quit()
Example #17
0
    def test_create_new_query_tab(self):
        """Create a new tab triggering the actions and using the keyboard."""
        self.assertEqual(self._get_tabs_count(), 0)
        self._add_new_query_tab()
        self.assertEqual(self._get_tabs_count(), 1)

        QTest.keyPress(self.ui, Qt.Key_N, Qt.ControlModifier)
        self.assertEqual(self._get_tabs_count(), 2)
        return
Example #18
0
def tst_channels_widget(window,
                        widget,
                        widget_name,
                        sort_column=1,
                        test_filter=True,
                        test_subscribe=True):
    wait_for_list_populated(widget.content_table)
    screenshot(window, name=f"{widget_name}-page")

    # Sort
    widget.content_table.sortByColumn(sort_column, 1)
    wait_for_list_populated(widget.content_table)
    screenshot(window, name=f"{widget_name}-sorted")
    max_items = min(widget.content_table.model().channel_info["total"], 50)
    assert widget.content_table.verticalHeader().count() <= max_items

    # Filter
    if test_filter:
        old_num_items = widget.content_table.verticalHeader().count()
        QTest.keyClick(widget.channel_torrents_filter_input, 'r')
        wait_for_list_populated(widget.content_table)
        screenshot(window, name=f"{widget_name}-filtered")
        assert widget.content_table.verticalHeader().count() <= old_num_items
        QTest.keyPress(widget.channel_torrents_filter_input, Qt.Key_Backspace)
        wait_for_list_populated(widget.content_table)

    if test_subscribe:
        widget.content_table.sortByColumn(0, 0)
        wait_for_list_populated(widget.content_table)
        screenshot(window, name=f"{widget_name}-sorted-on-subscribe")
        # Subscribe
        index = get_index_of_row_column(
            widget.content_table, 0,
            widget.model.column_position[Column.VOTES])
        widget.content_table.on_subscribe_control_clicked(index)
        QTest.qWait(200)

        # Unsubscribe
        widget.content_table.on_subscribe_control_clicked(index)
        QTest.qWait(200)
        screenshot(window, name=f"{widget_name}-unsubscribed")
        window.dialog.button_clicked.emit(0)

    # Test channel view
    index = get_index_of_row_column(widget.content_table, 0,
                                    widget.model.column_position[Column.NAME])
    widget.content_table.on_table_item_clicked(index)
    wait_for_list_populated(widget.content_table)
    screenshot(window, name=f"{widget_name}-channel_loaded")

    # Click the first torrent
    index = get_index_of_row_column(widget.content_table, 0,
                                    widget.model.column_position[Column.NAME])
    widget.content_table.on_table_item_clicked(index)
    QTest.qWait(100)
    screenshot(window, name=f"{widget_name}-torrent_details")
Example #19
0
 def test_read_no_delim(self):        
     delim = ""
     fileName = "good_delim.txt"
     QTest.qWaitForWindowActive(ReadFileTests.gui)
     QtCore.QTimer.singleShot(1000, lambda: inject(QApplication.activeModalWidget(), delim))
     QTest.keyPress(ReadFileTests.gui, Qt.Key_F, Qt.ControlModifier | Qt.ShiftModifier)
     QTest.keyRelease(ReadFileTests.gui, Qt.Key_F, Qt.ControlModifier | Qt.ShiftModifier)
     
     self.assertEqual(core._attributes, [])
     self.assertEqual(ReadFileTests.gui.ui.schemaLine.text(), "")
Example #20
0
    def test_no_file(self):
        QTest.qWaitForWindowActive(DatabaseTests.gui)
        QtCore.QTimer.singleShot(
            2000, lambda: QTest.keyPress(QApplication.activeModalWidget(), Qt.
                                         Key_Escape))
        QTest.keyPress(DatabaseTests.gui, Qt.Key_I, Qt.ControlModifier)
        QTest.keyRelease(DatabaseTests.gui, Qt.Key_I, Qt.ControlModifier)

        self.assertEqual(core._attributes, [])
        self.assertEqual(core._fds, [])
        self.assertEqual(core._cover, [])
        self.assertEqual(DatabaseTests.gui.ui.schemaLine.text(), "")
    def testSmartLineEdit(self):
        widget = SmartLineEdit()

        QTest.keyClicks(widget, 'abc')
        self.assertTrue(widget._text_modified)
        QTest.keyPress(widget, Qt.Key_Enter)
        self.assertFalse(widget._text_modified)

        spy = QSignalSpy(widget.returnPressed)
        widget.setText('abc')
        self.assertEqual(1, len(spy))
        widget.setTextWithoutSignal('efg')
        self.assertEqual(1, len(spy))
Example #22
0
 def test_number_of_property_groups_is_kept_equal_to_no_groups_spinbox(
         self):
     self.compare()
     item = self.aw.datawindow.ui.no_groups
     set_text_spinbox(item, "12")
     self.compare()
     set_text_spinbox(item, "2")
     self.compare()
     set_text_spinbox(item, "8")
     QTest.keyPress(item, Qt.Key_Return)
     self.compare()
     set_text_spinbox(item, "-5")
     self.compare()
Example #23
0
    def test_close_current_tab(self):
        """Close the current tab triggering the action and using keyboard."""
        self.assertEqual(self._get_tabs_count(), 0)
        self.tab = self._add_new_query_tab()
        self.tab = self._add_new_query_tab()
        self.assertEqual(self._get_tabs_count(), 2)
        self.ui.tab_widget.removeTab(0)
        self.assertEqual(self._get_tabs_count(), 1)

        QTest.keyPress(self.ui, Qt.Key_W, Qt.ControlModifier)
        self.assertEqual(self._get_tabs_count(), 0)

        return
Example #24
0
 def test_presseing_esc_does_not_close_or_clear_the_closable_graph(self):
     dummytitle = uniquestring()
     title = uniquestring()
     self.dummy = CurveDialogWithClosable(wintitle=dummytitle,
                                          mainwindow=self.aw)
     self.aw.addSubWindow(self.dummy)
     self.graph = CurveDialogWithClosable(wintitle=title,
                                          mainwindow=self.aw)
     self.graph.setClosable(False)
     self.aw.addSubWindow(self.graph)
     self.aw.show()
     self.assertTrue(self.graph.isVisible())
     QTest.keyPress(self.graph, Qt.Key_Escape)
     self.assertTrue(self.graph.isVisible())
Example #25
0
    def test_good_file_multi_table(self):
        fileName = "database.db"
        QTest.qWaitForWindowActive(DatabaseTests.gui)
        QtCore.QTimer.singleShot(
            1000, lambda: inject(QApplication.activeModalWidget(), fileName))
        QtCore.QTimer.singleShot(
            2000, lambda: inject(QApplication.activeModalWidget(), "Beers"))
        QTest.keyPress(DatabaseTests.gui, Qt.Key_I, Qt.ControlModifier)
        QTest.keyRelease(DatabaseTests.gui, Qt.Key_I, Qt.ControlModifier)

        self.assertEqual(core._attributes, ['name', 'manf'])
        self.assertEqual(core._fds, [])
        self.assertEqual(core._cover, [])
        self.assertEqual(DatabaseTests.gui.ui.schemaLine.text(), "name,manf")
Example #26
0
 def test_if_key_presses_registered_as_action(self, row_chosen, qtbot, key,
                                              row, expected_action):
     # GIVEN main window displayed and a row selected - handled by fixture
     # WHEN action key pressed
     # self.mark_rows_with_actions(row, key)
     QTest.keyPress(self.ui, key, Qt.NoModifier, 100)
     QTest.keyRelease(self.ui, key)
     # THEN Action column value changed to action
     data = list()
     for i in range(7):
         index = self.ui.model.createIndex(row, i)
         data.append(index.data(Qt.DisplayRole))
     assert data[Column.Action.index] == expected_action
     assert data[Column.Processed.index] is False
Example #27
0
 def mark_rows_with_keys(self, rows, keys):
     actions = self.convert_keys_to_actions(keys)
     for row, key, action in zip(rows, keys, actions):
         if row == -1:
             row = self.ui.model.rowCount(0) - 1
         self.ui.tableView.selectRow(row)
         QTest.keyPress(self.ui, key, Qt.NoModifier, 100)
         QTest.keyRelease(self.ui, key)
         data = list()
         for i in range(7):
             index = self.ui.model.createIndex(row, i)
             data.append(index.data(Qt.DisplayRole))
         # group = data[Column.Group.index]
         assert data[Column.Action.index] == action.value
         assert data[Column.Processed.index] is False
Example #28
0
    def test_manual(self):
        self._window.show()

        self.qpart.text = 'aaaaa\naaaaaXXXXX\n'

        base._processPendingEvents(self.app)

        self.qpart.cursorPosition = (2, 0)
        QTest.keyClicks(self.qpart, "a")

        QTest.keyPress(self.qpart, Qt.Key_Space, Qt.ControlModifier, 100)

        QTest.keyClicks(self.qpart, "a")
        QTest.keyClick(self.qpart, Qt.Key_Tab)
        self.assertEqual(self.qpart.text, 'aaaaa\naaaaaXXXXX\naaaaa')
Example #29
0
    def test_too_long_list(self):
        self._window.show()

        self.qpart.text = '\n'.join(['asdf' + str(i) \
                                        for i in range(100)]) + '\n'
        base._processPendingEvents(self.app)
        self.qpart.cursorPosition = (100, 0)
        QTest.keyClicks(self.qpart, "asdf")
        self.assertIsNotNone(self.qpart._completer._widget)

        self.qpart.text = '\n'.join(['asdf' + str(i) \
                                        for i in range(1000)]) + '\n'
        base._processPendingEvents(self.app)
        self.qpart.cursorPosition = (1000, 0)
        QTest.keyClicks(self.qpart, "asdf")
        self.assertIsNone(self.qpart._completer._widget)

        QTest.keyPress(self.qpart, Qt.Key_Space, Qt.ControlModifier, 100)
        self.assertIsNotNone(self.qpart._completer._widget)
Example #30
0
    def test_copy_result_table_cell(self):
        """Select and copy a column cell value into a clipboard."""
        self.tab = self._add_new_query_tab()
        sql_query_string = """
        SELECT name, type FROM streets
        ORDER BY name desc, type desc LIMIT 1
        """
        self._prepare_query_text(sql_query_string)
        self._execute_sql(sql_query_string)

        self.tab.table.view.model().fetchMore(
        )  # need to load into `rows` from OGR layer
        tm = self.tab.table.view.model()
        sm = self.tab.table.view.selectionModel()
        idx = tm.index(0, 0, QModelIndex())
        sm.select(idx, QItemSelectionModel.Select)

        QTest.keyPress(self.tab.table.view, Qt.Key_C, Qt.ControlModifier)
        cp = self.app.clipboard().text()
        self.assertEqual(cp, 'Zwicky Ave')
        return
Example #31
0
    def test_copy_result_table_row(self):
        """Select and copy a row into a clipboard."""
        self.tab = self._add_new_query_tab()
        sql_query_string = """
        SELECT name, type FROM streets
        ORDER BY name desc, type desc LIMIT 1
        """
        self._prepare_query_text(sql_query_string)
        self._execute_sql(sql_query_string)

        self.tab.table.view.model().fetchMore(
        )  # need to load into `rows` from OGR layer
        self.assertEqual(len(self.tab.table.view.model().rows), 1)
        self.tab.table.view.selectRow(0)

        QTest.keyPress(self.tab.table.view, Qt.Key_C, Qt.ControlModifier)
        cp = self.app.clipboard().text()
        parsed_cp = [i.split('\t') for i in cp.split('\n') if i]
        self.assertEqual(parsed_cp[0], ['NAME', 'TYPE'])
        self.assertEqual(parsed_cp[1], ['Zwicky Ave', 'residential'])
        return
Example #32
0
 def test_processing_changes_table_values(self, row_chosen, qtbot, key, row,
                                          expected_action,
                                          expected_processed):
     # todo reuse same logic among tests
     # GIVEN actions assigned to some files
     QTest.keyPress(self.ui, key, Qt.NoModifier, 100)
     QTest.keyRelease(self.ui, key)
     data = list()
     for i in range(7):
         index = self.ui.model.createIndex(row, i)
         data.append(index.data(Qt.DisplayRole))
     assert data[Column.Action.index] == expected_action
     assert data[Column.Processed.index] is False
     # WHEN click Execute Action button
     QTest.mouseClick(self.ui.pushButton_2, Qt.LeftButton)
     # THEN Processed set == True where Action is not empty
     data.clear()
     for i in range(7):
         index = self.ui.model.createIndex(row, i)
         data.append(index.data(Qt.DisplayRole))
     assert data[Column.Processed.index] == expected_processed
Example #33
0
 def test_normal_keypress(self):
     QTest.keyPress(self.input, '1')
     self.assertEqual(self.input.text(), '1')
     QTest.keyPress(self.input, '2')
     self.assertEqual(self.input.text(), '12')
     QTest.keyPress(self.input, Qt.Key_Backspace)
     self.assertEqual(self.input.text(), '1')
Example #34
0
    def testTransformIdentity(self):

        crsIn = QgsCoordinateReferenceSystem("EPSG:4326")
        crsOut = QgsCoordinateReferenceSystem("EPSG:4326")

        self.coordinator.setInputCrs(crsIn)
        self.dw.outputCrsConn.setEnabled(False)
        self.coordinator.setOutputCrs(crsOut)

        QTest.keyPress(self.dw.inLeft, "2")
        self.assertEqual(helperFormatCoordinates("2°0′0.000″E"),
                         self.dw.resultLeft.text())
        self.assertEqual(helperFormatCoordinates("0°0′0.000″"),
                         self.dw.resultRight.text())

        QTest.keyPress(self.dw.inLeft, "3")
        self.assertEqual(helperFormatCoordinates("23°0′0.000″E"),
                         self.dw.resultLeft.text())
        self.assertEqual(helperFormatCoordinates("0°0′0.000″"),
                         self.dw.resultRight.text())

        QTest.keyPress(self.dw.inRightMin, "2")
        self.assertEqual(helperFormatCoordinates("23°0′0.000″E"),
                         self.dw.resultLeft.text())
        self.assertEqual(helperFormatCoordinates("0°2′0.000″N"),
                         self.dw.resultRight.text())
    def test_inputline(self):
        initrange = self.viewer.shown_tracks_range

        self.write_to_input_line('hide W.X.Y.Z')
        self.write_to_input_line('unhide W.X.Y.Z')
        self.pile_viewer.update()

        self.write_to_input_line('hide *')
        self.pile_viewer.update()

        assert(self.viewer.shown_tracks_range == (0, 1))
        self.write_to_input_line('unhide')

        assert(self.viewer.shown_tracks_range == initrange)

        self.write_to_input_line('markers')
        self.write_to_input_line('markers 4')
        self.write_to_input_line('markers all')

        # should error
        self.write_to_input_line('scaling 1000.')
        self.write_to_input_line('scaling -1000. 1000.')

        gotos = ['2015-01-01 00:00:00',
                 '2015-01-01 00:00',
                 '2015-01-01 00',
                 '2015-01-01',
                 '2015-01',
                 '2015']

        for gt in gotos:
            self.write_to_input_line('goto %s' % gt)

        # test some false input
        self.write_to_input_line('asdf')
        QTest.keyPress(self.pile_viewer.inputline, Qt.Key_Escape)
    def test_frames(self):
        frame_snuffling = TestSnuffling()

        self.viewer.add_snuffling(frame_snuffling)
        frame_snuffling.call()

        # close three opened frames
        QTest.keyPress(self.pile_viewer, 'd')
        QTest.keyPress(self.pile_viewer, 'd')
        QTest.keyPress(self.pile_viewer, 'd')
    def test_event_marker(self):
        pv = self.pile_viewer
        self.add_one_pick()

        # select all markers
        QTest.keyPress(pv, 'a', Qt.ShiftModifier, 100)

        # convert to EventMarker
        QTest.keyPress(pv, 'e')

        QTest.keyPress(pv, 'd')

        for m in pv.viewer.get_markers():
            self.assertTrue(isinstance(m, gui_util.EventMarker))
Example #38
0
 def press_key(self, key):
     if KeyboardLayout.is_modifier(key):
         self._modifiers |= KeyboardLayout.modifier_code(key)
     else:
         QTest.keyPress(self._widget_under_cursor(), KeyboardLayout.key_code(key), self._modifiers)
 def clear_all_markers(self):
     pv = self.pile_viewer
     QTest.keyPress(pv, 'A', Qt.ShiftModifier, 10)
     QTest.keyPress(pv, Qt.Key_Backspace)
     self.assertEqual(len(pv.viewer.get_markers()), 0)
 def fire_key(x):
     QTest.keyPress(self.pile_viewer, key)