def test_box_highlight_on_mouseover(self): self.pw.start() try: doc = self.pw.docsearch.get_doc_from_docid("20121213_1946_26") self.pw.main_window.show_doc(doc) self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot( self, "test_main_win_show_doc_multiple_pages", sc) GLib.idle_add(self.pw.main_window.page_drawers[2].emit, 'page-selected') self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot(self, "test_main_win_show_page", sc) mouse_event = Gdk.Event.new(Gdk.EventType.MOTION_NOTIFY) mouse_event.x = 250 mouse_event.y = 356 canvas = self.pw.main_window.img['canvas'] GLib.idle_add(canvas.emit, 'motion-notify-event', mouse_event) self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot( self, "test_main_win_box_highlight_on_mouseover", sc) finally: self.pw.stop()
def test_uncheck_ocr(self): self.pw.start() try: action = self.pw.main_window.actions['open_settings'][1] GLib.idle_add(action.do) time.sleep(3) try: self.pw.wait() self.assertNotEqual(action.dialog, None) sc = pytestshot.screenshot(action.dialog.window.get_window()) pytestshot.assertScreenshot(self, "test_settings_open", sc) widget = action.dialog.ocr_settings['enabled']['gui'] GLib.idle_add(widget.set_active, False) self.pw.wait() sc = pytestshot.screenshot(action.dialog.window.get_window()) pytestshot.assertScreenshot( self, "test_settings_uncheck_ocr", sc ) GLib.idle_add( action.dialog.window.emit, 'delete-event', None ) self.pw.wait() finally: if action.dialog: GLib.idle_add(action.dialog.window.destroy) self.pw.wait() finally: self.pw.stop() config = load_config() config.read() self.assertFalse(config['ocr_enabled'].value)
def test_increase_with_zoom_manual(self): self.pw.start() try: doc = self.pw.docsearch.get_doc_from_docid("20121213_1946_26") self.pw.main_window.show_doc(doc) self.pw.wait() self.pw.main_window.set_zoom_level(0.05, auto=False) self.pw.main_window.update_page_sizes() canvas = self.pw.main_window.img['canvas'] canvas.recompute_size(upd_scrollbar_values=True) canvas.redraw() self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot( self, "test_main_win_resized_zoom_manual_before", sc) self.pw.main_window.window.set_size_request(1000, 600) self.pw.wait() # Note: The scrollbars will still to the top left sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot( self, "test_main_win_resized_zoom_manual_after", sc) finally: self.pw.stop()
def gen_import_pdf(pw): menu = pw.main_window.widget_tree.get_object("menubuttonOtherScans") pw.wait() img = pytestshot.screenshot(pw.gdk_window) save_sc("import_pdf_en_0001.png", img, menu, add_cursor=True) menu.clicked() pw.wait() img = pytestshot.screenshot(pw.gdk_window) save_sc("import_pdf_en_0002.png", img, menu, add_cursor=True) save_sc("paperwork_import.png", img, menu, add_cursor=True, crop_size=(100, 100))
def gen_new_doc(pw): img = pytestshot.screenshot(pw.gdk_window) save_sc("new_doc.png", img, pw.main_window.actions['new_doc'][0][0], crop_size=(100, 80), add_cursor=True)
def test_screenshot(self): self.app.start() try: pil_img = pytestshot.screenshot(self.app.window.get_window()) self.assertNotEqual(pil_img, None) finally: self.app.stop()
def gen_adf_access(pw): menu = pw.main_window.widget_tree.get_object("menubuttonOtherScans") menu.clicked() pw.wait() time.sleep(1) img = pytestshot.screenshot(pw.gdk_window) save_sc("adf_access.png", img, menu, add_cursor=True)
def gen_label_goto_edit(pw): doc = pw.docsearch.get_doc_from_docid("20130126_1902_26") pw.main_window.show_doc(doc) pw.wait() time.sleep(1) GLib.idle_add(pw.main_window.switch_leftpane, 'doc_properties') pw.wait() scrollbars = pw.main_window.widget_tree.get_object( "box_left_docproperties") vadj = scrollbars.get_vadjustment() GLib.idle_add(vadj.set_value, vadj.get_upper()) time.sleep(1) pw.wait() rows = pw.main_window.doc_properties_panel.widgets['labels'] row = rows.get_children()[4] row_box = row.get_children()[0] # selected, >edit_label_button<, label select_button = row_box.get_children()[1] img = pytestshot.screenshot(pw.gdk_window) save_sc("label_goto_edit.png", img, select_button, crop_size=(300, 200), add_cursor=True)
def test_main_win_start(self): self.pw.start() try: sc = pytestshot.screenshot(self.pw.gdk_window) finally: self.pw.stop() pytestshot.assertScreenshot(self, "test_main_win_start", sc)
def gen_paperwork_scan(pw): img = pytestshot.screenshot(pw.gdk_window) save_sc("paperwork_scan.png", img, pw.main_window.actions['single_scan'][0][0], crop_size=(100, 100), add_cursor=True)
def test_increase_with_zoom_auto_3(self): self.pw.start() try: doc = self.pw.docsearch.get_doc_from_docid("20121213_1946_26") self.pw.main_window.show_doc(doc) self.pw.wait() GLib.idle_add(self.pw.main_window.page_drawers[3].emit, 'page-selected') self.pw.wait() # scroll to the bottom right canvas = self.pw.main_window.img['canvas'] canvas.hadjustment.set_value(canvas.hadjustment.get_upper()) canvas.vadjustment.set_value(canvas.vadjustment.get_upper()) self.pw.wait() self.pw.main_window.window.set_size_request(1000, 600) self.pw.wait() # Note: The scrollbars will still to the botton right sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot(self, "test_main_win_resized_zoom_auto_3", sc) finally: self.pw.stop()
def gen_import_pdf4(pw): doc = pw.docsearch.get_doc_from_docid("20130126_1902_26") pw.main_window.show_doc(doc) pw.wait() time.sleep(1) img = pytestshot.screenshot(pw.gdk_window) save_sc("import_pdf_en_0004.png", img)
def gen_goto_advanced_search(pw): button = pw.main_window.actions['open_search_dialog'][0][0] img = pytestshot.screenshot(pw.gdk_window) save_sc("goto_advanced_search.png", img, button, crop_size=(150, 75), add_cursor=True)
def test_box_highlight_all(self): self.pw.start() try: doc = self.pw.docsearch.get_doc_from_docid("20121213_1946_26") self.pw.main_window.show_doc(doc) self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot( self, "test_main_win_show_doc_multiple_pages", sc) GLib.idle_add(self.pw.main_window.page_drawers[2].emit, 'page-selected') self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot(self, "test_main_win_show_page", sc) action = self.pw.main_window.actions['open_view_settings'][1] GLib.idle_add(action.do) self.pw.wait() GLib.idle_add(self._set_show_all_to_true, self.pw.main_window) self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot(self, "test_main_win_box_highlight_all", sc) self.pw.main_window.popovers['view_settings'].hide() self.pw.wait() # make sure the boxes are still highlighted when we switch to # another document doc = self.pw.docsearch.get_doc_from_docid("20130126_1833_26") self.pw.main_window.show_doc(doc) self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot(self, "test_main_win_box_highlight_all_2", sc) finally: self.pw.stop()
def test_show_page(self): self.pw.start() try: doc = self.pw.docsearch.get_doc_from_docid("20121213_1946_26") self.pw.main_window.show_doc(doc) self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot( self, "test_main_win_show_doc_multiple_pages", sc) GLib.idle_add(self.pw.main_window.page_drawers[2].emit, 'page-selected') self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot(self, "test_main_win_show_page", sc) finally: self.pw.stop()
def gen_paperwork_export(pw): menu = pw.main_window.widget_tree.get_object("menubuttonWindowAdvanced") GLib.idle_add(menu.clicked) time.sleep(1) pw.wait() img = pytestshot.screenshot(pw.gdk_window) save_sc("paperwork_export_0001.png", img, menu, add_cursor=True, crop_size=(150, 200))
def gen_paperwork_search(pw): field = pw.main_window.actions['search'][0][0] GLib.idle_add(field.set_text, "contrat") time.sleep(2) pw.wait() img = pytestshot.screenshot(pw.gdk_window) save_sc("paperwork_search.png", img, field, crop_size=(200, 100), add_cursor=True)
def test_main_win_show_doc_one_page(self): self.pw.start() try: doc = self.pw.docsearch.get_doc_from_docid("20130126_1902_26") self.pw.main_window.show_doc(doc) self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) finally: self.pw.stop() pytestshot.assertScreenshot(self, "test_main_win_show_doc_one_page", sc)
def test_show_doc_multiple_pages(self): self.pw.start() try: doc = self.pw.docsearch.get_doc_from_docid("20121213_1946_26") self.pw.main_window.show_doc(doc) self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) finally: self.pw.stop() pytestshot.assertScreenshot(self, "test_main_win_show_doc_multiple_pages", sc)
def test_scroll_to_page(self): self.pw.start() try: doc = self.pw.docsearch.get_doc_from_docid("20121213_1946_26") self.pw.main_window.show_doc(doc) self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot( self, "test_main_win_show_doc_multiple_pages", sc) self.pw.main_window.set_layout('paged') self.pw.wait() canvas = self.pw.main_window.img['canvas'] adj = canvas.get_hadjustment() self.assertEqual(adj.get_value(), 0) self.assertEqual(adj.get_lower(), 0) adj = canvas.get_vadjustment() self.assertEqual(adj.get_value(), 0) self.assertEqual(adj.get_lower(), 0) self.assertNotEqual(adj.get_upper(), 0) target = int(adj.get_upper() / 2) step = int(target / (1 / 0.05)) for pos in range(0, target, step): adj.set_value(pos) time.sleep(0.05) adj.set_value(target) self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot(self, "test_main_win_scroll_to_page", sc) finally: self.pw.stop()
def gen_settings_disable_ocr(pw): action = pw.main_window.actions['open_settings'][1] GLib.idle_add(action.do) time.sleep(3) try: sources = action.dialog.ocr_settings['enabled']['gui'] img = pytestshot.screenshot(action.dialog.window.get_window()) save_sc("settings_disable_ocr.png", img, sources, add_cursor=True, crop_size=(250, 100)) finally: GLib.idle_add(action.dialog.window.destroy)
def gen_import_pdf3(pw): action = pw.main_window.actions['import'][1] GLib.idle_add(action.do) pw.wait() try: dirpath = os.path.abspath("orig_data/20130126_1833_26") action._select_file_dialog.select_filename( os.path.join(dirpath, "doc.pdf")) pw.wait() img = pytestshot.screenshot(action._select_file_dialog.get_window()) save_sc("import_pdf_en_0003.png", img, add_cursor=(600, 160)) finally: GLib.idle_add(action._select_file_dialog.destroy)
def test_open(self): self.pw.start() try: action = self.pw.main_window.actions['open_settings'][1] GLib.idle_add(action.do) time.sleep(3) try: self.pw.wait() self.assertNotEqual(action.dialog, None) sc = pytestshot.screenshot(action.dialog.window.get_window()) finally: if action.dialog: GLib.idle_add(action.dialog.window.destroy) finally: self.pw.stop() pytestshot.assertScreenshot(self, "test_settings_open", sc)
def gen_adf_settings(pw): action = pw.main_window.actions['open_settings'][1] GLib.idle_add(action.do) time.sleep(3) try: sources = action.dialog.device_settings['source']['gui'] GLib.idle_add(sources.popup) pw.wait() img = pytestshot.screenshot(action.dialog.window.get_window()) save_sc("adf_settings.png", img, sources, add_cursor=True, crop_size=(250, 150)) finally: GLib.idle_add(action.dialog.window.destroy)
def test_show_doc_properties(self): self.pw.start() try: doc = self.pw.docsearch.get_doc_from_docid("20090215_1952_46") self.pw.main_window.show_doc(doc) self.pw.wait() GLib.idle_add(self.pw.main_window.switch_leftpane, 'doc_properties') self.pw.wait() sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot(self, "test_main_win_doc_properties_show", sc) finally: self.pw.stop()
def test_increase_with_zoom_auto(self): self.pw.start() try: doc = self.pw.docsearch.get_doc_from_docid("20130126_1833_26") self.pw.main_window.show_doc(doc) self.pw.wait() self.pw.main_window.window.set_size_request(1000, 600) self.pw.wait() # Note: The scrollbars should stick to (0, 0) sc = pytestshot.screenshot(self.pw.gdk_window) pytestshot.assertScreenshot(self, "test_main_win_resized_zoom_auto", sc) finally: self.pw.stop()
def gen_goto_labels_and_memo(pw): doc = pw.docsearch.get_doc_from_docid("20130126_1902_26") pw.main_window.show_doc(doc) pw.wait() time.sleep(1) doclist = pw.main_window.doclist.gui['list'] row = doclist.get_selected_rows()[0] row_children = row.get_children()[0].get_children() buttons = row_children[2] # thumbnail, docname+labels, >buttons< button = buttons.get_children()[0] img = pytestshot.screenshot(pw.gdk_window) save_sc("paperwork_goto_labels_and_memo.png", img, button, add_cursor=True, crop_size=(220, 150), cursor_offset=2)
def gen_label_and_memo(pw): doc = pw.docsearch.get_doc_from_docid("20130126_1902_26") pw.main_window.show_doc(doc) pw.wait() time.sleep(1) GLib.idle_add(pw.main_window.switch_leftpane, 'doc_properties') pw.wait() scrollbars = pw.main_window.widget_tree.get_object( "box_left_docproperties") vadj = scrollbars.get_vadjustment() GLib.idle_add(vadj.set_value, vadj.get_upper()) pw.wait() memo = pw.main_window.doc_properties_panel.widgets['extra_keywords'] img = pytestshot.screenshot(pw.gdk_window) save_sc("paperwork_label_and_memo.png", img, memo, crop_size=(300, 200))
def gen_adf_multiscan(pw): doc = pw.docsearch.get_doc_from_docid("20121213_1946_26") pw.main_window.show_doc(doc) pw.wait() action = pw.main_window.actions['multi_scan'][1] GLib.idle_add(action.do) pw.wait() try: GLib.idle_add(action.dialog.actions['add_doc'][1].do) pw.wait() treeview = action.dialog.lists['docs']['gui'] treeview.get_selection().select_path([1]) pw.wait() img = pytestshot.screenshot(action.dialog.window.get_window()) save_sc("adf_multiscan.png", img, add_cursor=(500, 75)) finally: GLib.idle_add(action.dialog.window.destroy) pw.wait()
def gen_paperwork_export3(pw): doc = pw.docsearch.get_doc_from_docid("20121213_1946_26") pw.main_window.show_doc(doc) pw.wait() action = pw.main_window.actions['open_export_page_dialog'][1] GLib.idle_add(action.do) time.sleep(3) pw.wait() GLib.idle_add(pw.main_window.export['export_path'].set_text, "Documents/out.png") GLib.idle_add(pw.main_window.export['buttons']['ok'].set_sensitive, True) pw.wait() img = pytestshot.screenshot(pw.gdk_window) save_sc("paperwork_export_0003.png", img, pw.main_window.export['buttons']['ok'], add_cursor=True, crop_size=(550, 250))