-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New method to find parent QgsPanelWidget for a widget
(cherry-picked from a2fe4c4)
- Loading branch information
1 parent
7e680b0
commit 9bd1e75
Showing
5 changed files
with
88 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
"""QGIS Unit tests for QgsPanelWidget. | ||
.. note:: This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
""" | ||
__author__ = 'Nyall Dawson' | ||
__date__ = '16/08/2016' | ||
__copyright__ = 'Copyright 2016, The QGIS Project' | ||
# This will get replaced with a git SHA1 when you do a git archive | ||
__revision__ = '$Format:%H$' | ||
|
||
import qgis # NOQA | ||
|
||
from qgis.PyQt.QtWidgets import QWidget | ||
from qgis.gui import QgsPanelWidget | ||
from qgis.testing import start_app, unittest | ||
|
||
start_app() | ||
|
||
|
||
class TestQgsPanelWidget(unittest.TestCase): | ||
|
||
def testFindParentPanel(self): | ||
""" test QgsPanelWidget.findParentPanel """ | ||
|
||
# no widget | ||
self.assertFalse(QgsPanelWidget.findParentPanel(None)) | ||
|
||
# widget with no parent | ||
w = QWidget() | ||
self.assertFalse(QgsPanelWidget.findParentPanel(w)) | ||
|
||
# widget with no panel parent | ||
w2 = QWidget(w) | ||
self.assertFalse(QgsPanelWidget.findParentPanel(w2)) | ||
|
||
# panel widget itself | ||
w3 = QgsPanelWidget() | ||
self.assertEqual(QgsPanelWidget.findParentPanel(w3), w3) | ||
|
||
# widget with direct QgsPanelWidget parent | ||
w4 = QWidget(w3) | ||
self.assertEqual(QgsPanelWidget.findParentPanel(w4), w3) | ||
|
||
# widget with QgsPanelWidget grandparent | ||
w5 = QWidget(w4) | ||
self.assertEqual(QgsPanelWidget.findParentPanel(w5), w3) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |