Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from andynoack/master
Browse files Browse the repository at this point in the history
hurray first test!
splotz90 authored Feb 10, 2017
2 parents 0c85e0c + 9a3075c commit 87f9fab
Showing 2 changed files with 36 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/urh/ui/SimulatorScene.py
Original file line number Diff line number Diff line change
@@ -347,6 +347,15 @@ def dropEvent(self, event: QDropEvent):
nodes_to_add.extend([file_node for file_node in file_nodes if file_node not in nodes_to_add])
protocols_to_add = [node.protocol for node in nodes_to_add]


self.add_protocols(protocols_to_add)

self.update_view()

super().dropEvent(event)


def add_protocols(self, protocols_to_add: list):
for protocol in protocols_to_add:
for message in protocol.messages:
source, destination = self.__detect_source_destination(message)
@@ -356,10 +365,6 @@ def dropEvent(self, event: QDropEvent):
self.items.append(simulator_message)
self.addItem(simulator_message)

self.update_view()

super().dropEvent(event)

def __detect_source_destination(self, message: Message):
# TODO: use SRC_ADDRESS and DST_ADDRESS labels
participants = self.controller.project_manager.participants
27 changes: 27 additions & 0 deletions tests/test_simulator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import unittest
import tests.utils_testing
from urh import constants
from urh.controller.MainController import MainController

from tests.utils_testing import get_path_for_data_file

app = tests.utils_testing.app


class TestSimulator(unittest.TestCase):
def setUp(self):
self.old_sym_len = constants.SETTINGS.value('rel_symbol_length', type=int)
constants.SETTINGS.setValue('rel_symbol_length', 0) # Disable Symbols for this Test

self.form = MainController()
self.form.add_signalfile(get_path_for_data_file("esaver.complex"))
self.sframe = self.form.signal_tab_controller.signal_frames[0]
self.sim_frame = self.form.simulator_tab_controller
self.form.ui.tabWidget.setCurrentIndex(3)

def tearDown(self):
constants.SETTINGS.setValue('rel_symbol_length', self.old_sym_len) # Restore Symbol Length

def test_add_signal(self):
self.sim_frame.ui.gvSimulator.scene().add_protocols([self.sframe.proto_analyzer])
self.assertEqual(len(self.sim_frame.ui.gvSimulator.scene().items), len(self.sframe.proto_analyzer.messages))

0 comments on commit 87f9fab

Please sign in to comment.