Files
superqt/tests/test_collapsible.py
Mustafa Al Ibrahim 789b98f892 QCollapsible for Collapsible Section Control (#37)
* Update changelog to ingnore virtual environment

* wip

* wip

* Working animation

* WIP Implement tests

* All tests are passing

* convert to camalCase

* Change function name to match functionality

* convert pyside to qtcompat

* move animation utils to main module

* remove seperators

* protect util functions

* add example

* remove seperators from test file

* suggestions

* Passing tests and ability to initialize expansion

* Ensure that the test will be passed in any screen resolution

* replace quick functions with parameters

* Update src/superqt/collapsible/_collapsible.py

Fix initial text

Co-authored-by: Talley Lambert <talley.lambert@gmail.com>

* Update src/superqt/collapsible/_collapsible.py

Remote WindowFlags to prevent compatiblity issue.

Co-authored-by: Talley Lambert <talley.lambert@gmail.com>

* merge internal expand and collapse into one function

* Update src/superqt/collapsible/_collapsible.py

* Update tests/test_collapsible.py

Co-authored-by: Talley Lambert <talley.lambert@gmail.com>
2021-11-20 09:27:26 -05:00

67 lines
1.8 KiB
Python

"""A test module for testing collapsible"""
from superqt import QCollapsible
from superqt.qtcompat.QtCore import QEasingCurve
from superqt.qtcompat.QtWidgets import QPushButton
def test_checked_initialization(qtbot):
"""Test simple collapsible"""
wdg1 = QCollapsible("Advanced analysis")
wdg1.expand(False)
assert wdg1.expanded() is True
assert wdg1._content.maximumHeight() > 0
wdg2 = QCollapsible("Advanced analysis")
wdg1.collapse(False)
assert wdg2.expanded() is False
assert wdg2._content.maximumHeight() == 0
def test_content_hide_show(qtbot):
"""Test collapsible with content"""
# Create child component
collapsible = QCollapsible("Advanced analysis")
for i in range(10):
collapsible.addWidget(QPushButton(f"Content button {i + 1}"))
collapsible.collapse(False)
assert collapsible.expanded() is False
assert collapsible._content.maximumHeight() == 0
collapsible.expand(False)
assert collapsible.expanded() is True
assert collapsible._content.maximumHeight() > 0
def test_locking(qtbot):
"""Test locking collapsible"""
wdg1 = QCollapsible()
assert wdg1.locked() is False
wdg1.setLocked(True)
assert wdg1.locked() is True
# Simulate button press
wdg1._toggle_btn.setChecked(True)
wdg1._toggle()
assert wdg1.expanded() is False
def test_changing_animation_settings(qtbot):
"""Quick test for changing animation settings"""
wdg = QCollapsible()
wdg.setDuration(600)
wdg.setEasingCurve(QEasingCurve.Type.InElastic)
assert wdg._animation.easingCurve() == QEasingCurve.Type.InElastic
assert wdg._animation.duration() == 600
def test_changing_content(qtbot):
"""Test changing the content"""
content = QPushButton()
wdg = QCollapsible()
wdg.setContent(content)
assert wdg._content == content