From 570721482d1701fe74933270b774078240562fe9 Mon Sep 17 00:00:00 2001 From: FBK Date: Tue, 12 Dec 2023 15:55:11 +0200 Subject: [PATCH] Tests: F11 --- src/asammdf/gui/widgets/main.py | 4 ++ .../gui/widgets/test_PlotWidget_Shortcuts.py | 70 +++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/src/asammdf/gui/widgets/main.py b/src/asammdf/gui/widgets/main.py index be2c4931d..b6cd2b7ea 100644 --- a/src/asammdf/gui/widgets/main.py +++ b/src/asammdf/gui/widgets/main.py @@ -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): diff --git a/test/asammdf/gui/widgets/test_PlotWidget_Shortcuts.py b/test/asammdf/gui/widgets/test_PlotWidget_Shortcuts.py index 885863e89..183171967 100644 --- a/test/asammdf/gui/widgets/test_PlotWidget_Shortcuts.py +++ b/test/asammdf/gui/widgets/test_PlotWidget_Shortcuts.py @@ -1,5 +1,8 @@ #!/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 @@ -7,6 +10,73 @@ 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