Skip to content

Commit

Permalink
Fix logview unit tests to work around the threading logic
Browse files Browse the repository at this point in the history
(cherry picked from commit 09446bbe5f0c631c74525cbc78b0e60ce114a2e2)
  • Loading branch information
FermiPerumal authored and DiegoTavares committed Dec 18, 2020
1 parent a10c80e commit 07a10b0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cuegui/tests/plugins/LogViewPlugin_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,20 @@ def setUp(self):

def test_shouldDisplayFirstLogFile(self):
PySide2.QtGui.qApp.display_log_file_content.emit([self.logPath1, self.logPath2])

self.logViewPlugin.logview_widget._receive_log_results(_LOG_TEXT_1, 0)
self.assertEqual(_LOG_TEXT_1, self.logViewPlugin.logview_widget._content_box.toPlainText())

def test_shouldUpdateLogFile(self):
PySide2.QtGui.qApp.display_log_file_content.emit([self.logPath1, self.logPath2])
self.logViewPlugin.logview_widget._receive_log_results(_LOG_TEXT_1, 0)
new_contents = _LOG_TEXT_1 + '\nanother line at the end'
self.log1.set_contents(new_contents)
PySide2.QtGui.qApp.display_log_file_content.emit([self.logPath1, self.logPath2])

self.logViewPlugin.logview_widget._receive_log_results(new_contents, 0)
self.assertEqual(new_contents, self.logViewPlugin.logview_widget._content_box.toPlainText())

def test_shouldHighlightAllSearchResults(self):
PySide2.QtGui.qApp.display_log_file_content.emit([self.logPath1, self.logPath2])
self.logViewPlugin.logview_widget._receive_log_results(_LOG_TEXT_1, 0)
self.logViewPlugin.logview_widget._case_stv_checkbox.setCheckState(PySide2.QtCore.Qt.CheckState.Unchecked)

self.logViewPlugin.logview_widget._search_box.setText('lorem')
Expand All @@ -90,7 +91,7 @@ def test_shouldHighlightAllSearchResults(self):
self.assertTrue(self.__isHighlighted(self.logViewPlugin.logview_widget._content_box, matches[1][0], matches[1][1]))

def test_shouldMoveCursorToSecondSearchResult(self):
PySide2.QtGui.qApp.display_log_file_content.emit([self.logPath1, self.logPath2])
self.logViewPlugin.logview_widget._receive_log_results(_LOG_TEXT_1, 0)
self.logViewPlugin.logview_widget._case_stv_checkbox.setCheckState(PySide2.QtCore.Qt.CheckState.Unchecked)

self.logViewPlugin.logview_widget._search_box.setText('lorem')
Expand All @@ -103,7 +104,7 @@ def test_shouldMoveCursorToSecondSearchResult(self):
self.assertEqual(132, self.logViewPlugin.logview_widget._cursor.position())

def test_shouldMoveCursorLastSearchResult(self):
PySide2.QtGui.qApp.display_log_file_content.emit([self.logPath1, self.logPath2])
self.logViewPlugin.logview_widget._receive_log_results(_LOG_TEXT_1, 0)
self.logViewPlugin.logview_widget._case_stv_checkbox.setCheckState(PySide2.QtCore.Qt.CheckState.Unchecked)

self.logViewPlugin.logview_widget._search_box.setText('lorem')
Expand All @@ -116,7 +117,7 @@ def test_shouldMoveCursorLastSearchResult(self):
self.assertEqual(132, self.logViewPlugin.logview_widget._cursor.position())

def test_shouldPerformCaseInsensitiveSearch(self):
PySide2.QtGui.qApp.display_log_file_content.emit([self.logPath1, self.logPath2])
self.logViewPlugin.logview_widget._receive_log_results(_LOG_TEXT_1, 0)
self.logViewPlugin.logview_widget._case_stv_checkbox.setCheckState(PySide2.QtCore.Qt.CheckState.Checked)

self.logViewPlugin.logview_widget._search_box.setText('lorem')
Expand Down

0 comments on commit 07a10b0

Please sign in to comment.