Skip to content

Commit

Permalink
Tests: F11
Browse files Browse the repository at this point in the history
  • Loading branch information
FillBk committed Dec 12, 2023
1 parent 0f40e7d commit 5707214
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/asammdf/gui/widgets/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,10 @@ def closeEvent(self, event):
count = self.files.count()
for i in range(count):
self.files.widget(i).close()
if self.fullscreen:
widget, index = self.fullscreen
widget.close()
widget.deleteLater()
event.accept()

def dragEnterEvent(self, e):
Expand Down
70 changes: 70 additions & 0 deletions test/asammdf/gui/widgets/test_PlotWidget_Shortcuts.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,82 @@
#!/usr/bin/env python
import os.path

from asammdf.gui.widgets.file import FileWidget
from asammdf.gui.widgets.main import MainWindow
from test.asammdf.gui.test_base import Pixmap
from test.asammdf.gui.widgets.test_BasePlotWidget import TestPlotWidget
from unittest import mock

from PySide6 import QtCore, QtGui, QtTest, QtWidgets


class TestShortcutsWOChannelsF(TestPlotWidget):
def setUp(self):
self.mw = MainWindow()
self.mw.showNormal()
self.processEvents()

def destroyMW(self):
if self.mw:
self.mw.close()

def openFile(self, measurement_files):
with mock.patch("asammdf.gui.widgets.main.QtWidgets.QFileDialog.getOpenFileNames") as mo_getOpenFileNames:
if measurement_files:
if isinstance(measurement_files, list):
mo_getOpenFileNames.return_value = measurement_files, ""
QtTest.QTest.keySequence(self.mw, QtGui.QKeySequence("Ctrl+O"))
else:
mo_getOpenFileNames.return_value = [measurement_files], ""
QtTest.QTest.keySequence(self.mw, QtGui.QKeySequence("Ctrl+O"))
else:
mo_getOpenFileNames.return_value = [self.measurement_file], ""
QtTest.QTest.keySequence(self.mw, QtGui.QKeySequence("Ctrl+O"))
self.processEvents()
mo_getOpenFileNames.assert_called()

def tearDown(self):
if self.mw:
self.destroyMW()

def test_Plot_Plot_Shortcut_Key_F11(self):
"""
Events:
- MainWindow is open by test "setUp" method
- Change view mode to something different from "GUI_Views.individual_files"
- Open valid file
- Load DSP File
- Send Key `F11`
- Close MainWindow
Expected:
- Method "toggle_fullscreen" should be triggered as following trigger action
- Ensure that FileWidget is closed too. No widget left open behind.
:return:
"""
# Setup

x = 5

with mock.patch.object(self.mw, "toggle_fullscreen", wraps=self.mw.toggle_fullscreen) as mock_showFullScreen:
# Event
self.openFile(measurement_files=None)
# file widget
self.widget = self.mw.files.widget(0)
# Press F11
QtTest.QTest.keyClick(self.widget, QtGui.Qt.Key_F11)
self.processEvents()
# Evaluate
# Identify Partial Object linked to save_configuration
mock_showFullScreen.assert_called()
# Close MainWindow
self.destroyMW()
self.processEvents()
# Evaluate
for widget in QtWidgets.QApplication.topLevelWidgets():
if isinstance(widget, FileWidget):
self.assertFalse(widget.isVisible())


class TestShortcutsWOChannels(TestPlotWidget):
def setUp(self):
# Open measurement file
Expand Down

0 comments on commit 5707214

Please sign in to comment.