Пример #1
0
    def test_set_rx_parameters(self):
        rx_settings_widget = self.dialog.device_settings_rx_widget
        bh = BackendContainer("test", {Backends.native}, True, True)
        self.assertTrue(bh.is_enabled)
        rx_settings_widget.backend_handler.device_backends["test"] = bh
        rx_settings_widget.ui.cbDevice.addItem("test")
        rx_settings_widget.ui.cbDevice.setCurrentText("test")
        self.assertEqual(rx_settings_widget.device.name, "test")
        self.assertEqual(rx_settings_widget.device.backend, Backends.native)

        simulator = self.dialog.simulator
        self.__edit_spinbox_value(rx_settings_widget.ui.spinBoxFreq, 500e6)
        self.assertEqual(simulator.sniffer.rcv_device.frequency, 500e6)

        self.__edit_spinbox_value(rx_settings_widget.ui.spinBoxSampleRate, 4e6)
        self.assertEqual(simulator.sniffer.rcv_device.sample_rate, 4e6)

        self.__edit_spinbox_value(rx_settings_widget.ui.spinBoxBandwidth, 5e6)
        self.assertEqual(simulator.sniffer.rcv_device.bandwidth, 5e6)

        self.__edit_spinbox_value(rx_settings_widget.ui.spinBoxGain, 15)
        self.assertEqual(simulator.sniffer.rcv_device.gain, 15)

        self.__edit_spinbox_value(rx_settings_widget.ui.spinBoxIFGain, 24)
        self.assertEqual(simulator.sniffer.rcv_device.if_gain, 24)

        self.__edit_spinbox_value(rx_settings_widget.ui.spinBoxBasebandGain, 11)
        self.assertEqual(simulator.sniffer.rcv_device.baseband_gain, 11)

        self.__edit_spinbox_value(rx_settings_widget.ui.spinBoxFreqCorrection, 22)
        self.assertEqual(simulator.sniffer.rcv_device.freq_correction, 22)

        rx_settings_widget.ui.lineEditIP.setText("4.4.4.4")
        rx_settings_widget.ui.lineEditIP.editingFinished.emit()
        self.assertEqual(simulator.sniffer.rcv_device.ip, "4.4.4.4")
Пример #2
0
    def test_change_device_parameters(self):
        for dialog in self.__get_all_dialogs():
            bh = BackendContainer("test", {Backends.native}, True, True)
            self.assertTrue(bh.is_enabled)
            dialog.backend_handler.device_backends["test"] = bh
            dialog.ui.cbDevice.addItem("test")
            dialog.ui.cbDevice.setCurrentText("test")
            self.assertEqual(dialog.device.name, "test", msg=type(dialog))
            self.assertEqual(dialog.device.backend, Backends.native, msg=type(dialog))

            dialog.ui.lineEditIP.setText("1.3.3.7")
            dialog.ui.lineEditIP.editingFinished.emit()
            self.assertEqual(dialog.device.ip, "1.3.3.7", msg=type(dialog))

            dialog.ui.spinBoxFreq.setValue(2e9)
            dialog.ui.spinBoxFreq.editingFinished.emit()
            self.assertEqual(dialog.ui.spinBoxFreq.text()[-1], "G")
            self.assertEqual(dialog.device.frequency, 2e9)

            dialog.ui.spinBoxSampleRate.setValue(10e6)
            dialog.ui.spinBoxSampleRate.editingFinished.emit()
            self.assertEqual(dialog.ui.spinBoxSampleRate.text()[-1], "M")
            self.assertEqual(dialog.device.sample_rate, 10e6)

            dialog.ui.spinBoxBandwidth.setValue(3e6)
            dialog.ui.spinBoxBandwidth.editingFinished.emit()
            self.assertEqual(dialog.ui.spinBoxBandwidth.text()[-1], "M")
            self.assertEqual(dialog.device.bandwidth, 3e6)

            dialog.ui.spinBoxGain.setValue(5)
            dialog.ui.spinBoxGain.editingFinished.emit()
            self.assertEqual(dialog.device.gain, 5)

            dialog.ui.spinBoxIFGain.setValue(10)
            dialog.ui.spinBoxIFGain.editingFinished.emit()
            self.assertEqual(dialog.device.if_gain, 10)

            dialog.ui.spinBoxBasebandGain.setValue(15)
            dialog.ui.spinBoxBasebandGain.editingFinished.emit()
            self.assertEqual(dialog.device.baseband_gain, 15)

            dialog.ui.spinBoxFreqCorrection.setValue(40)
            dialog.ui.spinBoxFreqCorrection.editingFinished.emit()
            self.assertEqual(dialog.device.freq_correction, 40)

            self.assertEqual(dialog.ui.comboBoxDirectSampling.count(), 0)
            dialog.ui.comboBoxDirectSampling.addItem("test")
            dialog.ui.comboBoxDirectSampling.addItem("test1")
            dialog.ui.comboBoxDirectSampling.setCurrentIndex(1)
            self.assertEqual(dialog.device.direct_sampling_mode, 1)

            dialog.ui.spinBoxNRepeat.setValue(10)
            dialog.ui.spinBoxNRepeat.editingFinished.emit()
            if dialog.is_tx:
                self.assertEqual(dialog.device.num_sending_repeats, 10)
            else:
                self.assertEqual(dialog.device.num_sending_repeats, None)

            self.__close_dialog(dialog)
Пример #3
0
    def test_set_tx_parameters(self):
        tx_settings_widget = self.dialog.device_settings_tx_widget
        simulator = self.dialog.simulator

        bh = BackendContainer("test", {Backends.native}, True, True)
        self.assertTrue(bh.is_enabled)
        tx_settings_widget.backend_handler.device_backends["test"] = bh
        tx_settings_widget.ui.cbDevice.addItem("test")
        tx_settings_widget.ui.cbDevice.setCurrentText("test")
        self.assertEqual(tx_settings_widget.device.name, "test")
        self.assertEqual(tx_settings_widget.device.backend, Backends.native)

        self.__edit_spinbox_value(tx_settings_widget.ui.spinBoxFreq, 300e6)
        self.assertEqual(simulator.sender.device.frequency, 300e6)

        self.__edit_spinbox_value(tx_settings_widget.ui.spinBoxSampleRate, 5e6)
        self.assertEqual(simulator.sender.device.sample_rate, 5e6)

        self.__edit_spinbox_value(tx_settings_widget.ui.spinBoxBandwidth, 3e6)
        self.assertEqual(simulator.sender.device.bandwidth, 3e6)

        self.__edit_spinbox_value(tx_settings_widget.ui.spinBoxGain, 16)
        self.assertEqual(simulator.sender.device.gain, 16)

        self.__edit_spinbox_value(tx_settings_widget.ui.spinBoxIFGain, 13)
        self.assertEqual(simulator.sender.device.if_gain, 13)

        self.__edit_spinbox_value(tx_settings_widget.ui.spinBoxBasebandGain,
                                  10)
        self.assertEqual(simulator.sender.device.baseband_gain, 10)

        self.__edit_spinbox_value(tx_settings_widget.ui.spinBoxFreqCorrection,
                                  33)
        self.assertEqual(simulator.sender.device.freq_correction, 33)

        tx_settings_widget.ui.lineEditDeviceArgs.setText("cool send args")
        tx_settings_widget.ui.lineEditDeviceArgs.editingFinished.emit()
        self.assertEqual(simulator.sender.device.device_args, "cool send args")

        tx_settings_widget.ui.lineEditIP.setText("1.2.6.2")
        tx_settings_widget.ui.lineEditIP.editingFinished.emit()
        self.assertEqual(simulator.sender.device.ip, "1.2.6.2")