Esempio n. 1
0
 def test_hookup(self, main_win: MainWindow, qtbot):
     main_win.show()
     qtbot.addWidget(main_win)
     main_win.show_find_and_replace_dialog = MagicMock()
     qtbot.keyClick(main_win.text_edit, Qt.Key_F, modifier=Qt.ControlModifier)
     qtbot.keyClick(main_win.text_edit, Qt.Key_J, modifier=(Qt.ControlModifier | Qt.ShiftModifier))
     assert main_win.show_find_and_replace_dialog.call_count == 2
Esempio n. 2
0
 def test_del_missing_word(self, main_win: MainWindow, qtbot):
     main_win.show()
     qtbot.addWidget(main_win)
     main_win.delete_word_act.trigger()
     vd = main_win.findChildren(ValidatingDialog)[-1]
     qtbot.keyClicks(vd.line_edit, 'mat')
     qtbot.keyClick(vd, Qt.Key_Enter)
     assert not main_win.dict_modified
Esempio n. 3
0
 def test_basic(self, main_win: MainWindow, qtbot):
     main_win.show()
     qtbot.addWidget(main_win)
     main_win.print_ = MagicMock()
     main_win.update_markdown_viewer = MagicMock()
     main_win.print_preview_markdown_act.trigger()
     assert main_win.print_.call_args.args[1] == main_win.md_text_edit
     assert main_win.print_.call_count == 1
     assert main_win.update_markdown_viewer.call_count == 1
Esempio n. 4
0
 def test_clear_recent(self, mainwin_recentfiles: MainWindow, qtbot):
     mainwin_recentfiles.show()
     qtbot.addWidget(mainwin_recentfiles)
     mainwin_recentfiles.clear_recent_files_act.trigger()
     for act in mainwin_recentfiles.recent_file_acts:
         assert not act.isVisible()
     for widget in QApplication.topLevelWidgets():
         if isinstance(widget, MainWindow):
             assert not widget.clear_recent_files_act.isEnabled()
Esempio n. 5
0
 def test_open_recent_hookup(self, mainwin_recentfiles: MainWindow, qtbot):
     MainWindow.open_file = MagicMock()
     mainwin_recentfiles.show()
     qtbot.addWidget(mainwin_recentfiles)
     win3: MainWindow = MainWindow.window_list[1]
     win3.close()
     assert not win3.isVisible()
     mainwin_recentfiles.recent_file_acts[1].trigger()  # ref: prior test
     MainWindow.open_file.assert_called_once_with(win3.cur_file)
Esempio n. 6
0
 def test_hookup(self, main_win: MainWindow, qtbot):
     main_win.show()
     qtbot.addWidget(main_win)
     main_win.print_ = MagicMock()
     main_win.update_markdown_viewer = MagicMock()
     qtbot.keyClick(main_win.text_edit, Qt.Key_P, modifier=(Qt.ControlModifier | Qt.ShiftModifier))
     qtbot.keyClick(main_win.text_edit, Qt.Key_R, modifier=(Qt.ControlModifier | Qt.ShiftModifier))
     assert main_win.print_.call_args.args[1] == main_win.md_text_edit
     assert main_win.print_.call_count == 2
     assert main_win.update_markdown_viewer.call_count == 2
Esempio n. 7
0
 def test_dock_updates_markdown_when_its_made_visible(self, main_win: MainWindow, qtbot):
     main_win.show()
     qtbot.addWidget(main_win)
     main_win.update_markdown_viewer = MagicMock()
     dock = main_win.findChild(QDockWidget)
     qtbot.keyClick(main_win.text_edit, Qt.Key_M)
     qtbot.keyClick(main_win.text_edit, Qt.Key_M, modifier=(Qt.ControlModifier | Qt.ShiftModifier))
     assert dock.isVisible()
     qtbot.keyClick(main_win.text_edit, Qt.Key_M)
     qtbot.keyClick(main_win.text_edit, Qt.Key_C, modifier=(Qt.ControlModifier | Qt.ShiftModifier))
     qtbot.keyClick(main_win.text_edit, Qt.Key_M)
     assert not dock.isVisible()
     assert main_win.update_markdown_viewer.call_count == 1
Esempio n. 8
0
def main():
    app = QApplication([])

    QApplication.setApplicationName("OneHandTextEdit")
    QApplication.setOrganizationName("PMA")

    file_name = 'regex_map.json'
    dict_src: str = QStandardPaths.locate(QStandardPaths.AppDataLocation, file_name)
    if not dict_src:
        dict_src = file_name  # TODO Change to app's packaged resource for deploy.
    with open(dict_src) as f:
        regex_map: dict = json.load(f)

    app.aboutToQuit.connect(functools.partial(save_dictionary, file_name, dict_src, regex_map))

    main_win = MainWindow(regex_map, dict_src=dict_src)
    main_win.show()
    sys.exit(app.exec_())
Esempio n. 9
0
 def test_inactive_clear_recent(self, mainwin_recentfiles: MainWindow, qtbot):
     mainwin_recentfiles.show()
     qtbot.addWidget(mainwin_recentfiles)
     assert not mainwin_recentfiles.clear_recent_files_act.isEnabled()
Esempio n. 10
0
 def test_doesnt_exceed_max_md_textedit_position(self, main_win: MainWindow, qtbot):
     main_win.show()
     qtbot.addWidget(main_win)
     qtbot.keyClicks(main_win.text_edit, "# hi")
     main_win.update_markdown_viewer()
     assert main_win.md_text_edit.textCursor().position() == 2