Пример #1
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
Пример #2
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)
    w.dialog = d
    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)
    assert d.result() == QtWidgets.QDialog.Accepted
    assert w.text == "test"
    assert w.isVisible() is False