-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport bug fixes for 7.0.1 release (#562)
* Fix errors from incorrect QImage memory management. (#546) This should stop the sporadic test failures caused by referencing memory which has been freed and used by something else. The fix is to attach the numpy array with the allocated memory to the QImage, so that the lifetime of the array is at least as long as that of the QImage. * Fix dock pane layout (#545) * Provide sizeHint to QWidget * REF : Restore qt4 conditional branch modified: pyface/ui/qt4/tasks/main_window_layout.py * TST: Test Qt dock widget has the correct size (#552) Co-authored-by: Sai Rahul Poruri <rporuri@enthought.com> Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com> * Update Changelog for 7.0.1 * Remove master only setting on Travis and Appveyor which prevent bug fix release PR from building * Update .travis.yml for Qt (#529) * Update .travis.yml to include libglu1-mesa-dev for Qt * Restore libxkbcommon-x11 and move other dependencies up * Fix package name for libsdl * Add a debug flag * Add libxcb-iccm4 * Continue the same exercise for pyside2, add libxcb-image * Giving up - let's use the same packages * Add libxml2 for osx image * Use brew manually See https://travis-ci.community/t/macos-build-fails-because-of-homebrew-bundle-unknown-command/7296/28 * Try a newer osx image * Add a comment * Is libdbus still needed? * Remove debugging flag - it is noisy and is embedded in between tests * Update install command for installing wx to match master (this is equivalent to a merge of a couple of PRs Co-authored-by: Corran Webster <cwebster@enthought.com> Co-authored-by: Pedro Rivotti <44579232+pedrorivotti@users.noreply.github.com> Co-authored-by: Sai Rahul Poruri <rporuri@enthought.com>
- Loading branch information
1 parent
ac89315
commit 99cb1f4
Showing
7 changed files
with
189 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# (C) Copyright 2005-2020 Enthought, Inc., Austin, TX | ||
# All rights reserved. | ||
# | ||
# This software is provided without warranty under the terms of the BSD | ||
# license included in LICENSE.txt and may be redistributed only under | ||
# the conditions described in the aforementioned license. The license | ||
# is also available online at http://www.enthought.com/licenses/BSD.txt | ||
# | ||
# Thanks for using Enthought open source! | ||
|
||
import unittest | ||
from unittest import mock | ||
|
||
from pyface.tasks.api import TaskLayout, PaneItem | ||
from pyface.toolkit import toolkit_object | ||
from pyface.window import Window | ||
|
||
try: | ||
from pyface.qt import QtGui | ||
from pyface.ui.qt4.tasks.main_window_layout import MainWindowLayout | ||
except ImportError: | ||
if toolkit_object.toolkit == "qt4": | ||
raise | ||
|
||
|
||
GuiTestAssistant = toolkit_object("util.gui_test_assistant:GuiTestAssistant") | ||
|
||
|
||
def create_dummy_dock_widget(parent): | ||
""" Create a dummy QDockWidget with a dummy child widget for test. | ||
Parameters | ||
---------- | ||
parent : QObject | ||
Returns | ||
------- | ||
dock_widget : QDockWidget | ||
""" | ||
dock_widget = QtGui.QDockWidget(parent) | ||
content_widget = QtGui.QWidget(parent) | ||
dock_widget.setWidget(content_widget) | ||
return dock_widget | ||
|
||
|
||
@unittest.skipIf( | ||
toolkit_object.toolkit != "qt4", | ||
"This test targets Qt specific MainWindowLayout. " | ||
"Current toolkit is not Qt." | ||
) | ||
class TestMainWindowLayout(unittest.TestCase, GuiTestAssistant): | ||
""" Test Qt specific MainWindowLayout. | ||
Note that MainWindowLayout does not have a toolkit-agnostic interface | ||
in the ``pyface.tasks`` package. Therefore this test is Qt-only. | ||
""" | ||
|
||
def setUp(self): | ||
GuiTestAssistant.setUp(self) | ||
self.window = Window(size=(500, 500)) | ||
self.window._create() | ||
|
||
def tearDown(self): | ||
if self.window.control is not None: | ||
with self.delete_widget(self.window.control): | ||
self.window.destroy() | ||
del self.window | ||
GuiTestAssistant.tearDown(self) | ||
|
||
def setup_window_with_central_widget(self): | ||
# Add a central widget to the main window. | ||
# The main window takes ownership of the child widget. | ||
central_widget = QtGui.QWidget(parent=self.window.control) | ||
self.window.control.setCentralWidget(central_widget) | ||
|
||
def test_set_pane_item_width_in_main_window_layout(self): | ||
# Test the dock pane width is as expected. | ||
|
||
self.setup_window_with_central_widget() | ||
|
||
# Set the dock widget expected width to be smaller than the window | ||
# for a meaningful test. | ||
expected_width = self.window.size[0] // 2 | ||
window_layout = MainWindowLayout(control=self.window.control) | ||
dock_layout = TaskLayout( | ||
left=PaneItem(width=expected_width) | ||
) | ||
dock_widget = create_dummy_dock_widget(parent=self.window.control) | ||
patch_get_dock_widget = mock.patch.object( | ||
MainWindowLayout, "_get_dock_widget", | ||
return_value=dock_widget, | ||
) | ||
|
||
# when | ||
with self.event_loop(): | ||
with patch_get_dock_widget: | ||
window_layout.set_layout(dock_layout) | ||
|
||
# then | ||
size = dock_widget.widget().size() | ||
self.assertEqual(size.width(), expected_width) | ||
|
||
def test_set_pane_item_height_in_main_window_layout(self): | ||
# Test the dock pane height is as expected. | ||
|
||
self.setup_window_with_central_widget() | ||
|
||
# Set the dock widget expected height to be smaller than the window | ||
# for a meaningful test. | ||
expected_height = self.window.size[1] // 2 | ||
window_layout = MainWindowLayout(control=self.window.control) | ||
dock_layout = TaskLayout( | ||
bottom=PaneItem(height=expected_height) | ||
) | ||
dock_widget = create_dummy_dock_widget(parent=self.window.control) | ||
patch_get_dock_widget = mock.patch.object( | ||
MainWindowLayout, "_get_dock_widget", | ||
return_value=dock_widget, | ||
) | ||
|
||
# when | ||
with self.event_loop(): | ||
with patch_get_dock_widget: | ||
window_layout.set_layout(dock_layout) | ||
|
||
# then | ||
size = dock_widget.widget().size() | ||
self.assertEqual(size.height(), expected_height) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters