-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for color button that setting color to transparent
will retain non-alpha color components (cherry-picked from 4089cc5)
- Loading branch information
1 parent
a66f1f8
commit 71308c7
Showing
2 changed files
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
"""QGIS Unit tests for QgsColorButtonV2. | ||
.. 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__ = '25/05/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.gui import QgsColorButtonV2 | ||
from qgis.testing import start_app, unittest | ||
from qgis.PyQt.QtGui import QColor | ||
start_app() | ||
|
||
|
||
class TestQgsColorButtonV2(unittest.TestCase): | ||
|
||
def testClearingColors(self): | ||
""" | ||
Test setting colors to transparent | ||
""" | ||
|
||
# start with a valid color | ||
button = QgsColorButtonV2() | ||
button.setAllowAlpha(True) | ||
button.setColor(QColor(255, 100, 200, 255)) | ||
self.assertEqual(button.color(), QColor(255, 100, 200, 255)) | ||
|
||
# now set to no color | ||
button.setToNoColor() | ||
# ensure that only the alpha channel has changed - not the other color components | ||
self.assertEqual(button.color(), QColor(255, 100, 200, 0)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |