Exemplo n.º 1
0
def test_get_text_dialog_accept(qtbot):
    w = custom_dialogs.TextInputWidget(
        message="Message", placeholder="Placeholder", default_text="Default"
    )
    d = custom_dialogs.GreyedDialog(w, title="Title", parent=None)
    d.closing.connect(w.on_closing)
    w.accepted.connect(d.accept)

    def _on_finished(return_code, text):
        assert return_code == QtWidgets.QDialog.Accepted
        assert text == "test"
        assert w.isVisible() is False

    w.finished.connect(_on_finished)
    qtbot.addWidget(d)
    d.show()

    assert d.isVisible() is True
    assert w.isVisible() is True
    assert d.label_title.text() == "Title"
    assert w.label_message.text() == "Message"
    assert w.line_edit_text.placeholderText() == "Placeholder"
    assert w.line_edit_text.text() == "Default"
    w.line_edit_text.setText("")
    qtbot.keyClicks(w.line_edit_text, "test")
    qtbot.mouseClick(w.button_ok, QtCore.Qt.LeftButton)
Exemplo n.º 2
0
def test_get_text_dialog_close(qtbot):
    w = custom_dialogs.TextInputWidget(message="Message")
    d = custom_dialogs.GreyedDialog(w, title="Title", parent=None)
    qtbot.addWidget(d)
    d.show()

    assert d.isVisible() is True
    assert w.isVisible() is True
    assert d.label_title.text() == "Title"
    assert w.label_message.text() == "Message"
    assert w.line_edit_text.placeholderText() == ""
    assert w.line_edit_text.text() == ""
    qtbot.mouseClick(d.button_close, QtCore.Qt.LeftButton)
    assert d.result() == QtWidgets.QDialog.Rejected
    assert w.text == ""
    assert w.isVisible() is False
Exemplo n.º 3
0
def test_ask_question_close(qtbot):
    w = custom_dialogs.QuestionWidget(message="Message", button_texts=["YES", "NO"])
    d = custom_dialogs.GreyedDialog(w, title="Title", parent=None)
    d.closing.connect(w.on_closing)
    w.accepted.connect(d.accept)

    def _on_finished(return_code, answer):
        assert return_code == QtWidgets.QDialog.Rejected
        assert answer == ""
        assert w.isVisible() is False

    w.finished.connect(_on_finished)
    qtbot.addWidget(d)

    d.show()
    assert d.isVisible() is True
    assert w.isVisible() is True
    assert d.label_title.text() == "Title"
    assert w.label_message.text() == "Message"
    qtbot.mouseClick(d.button_close, QtCore.Qt.LeftButton)