Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
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))
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
 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()
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
    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()
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
    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()
Ejemplo n.º 15
0
    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()
Ejemplo n.º 16
0
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))
Ejemplo n.º 17
0
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)
Ejemplo n.º 18
0
    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)
Ejemplo n.º 19
0
    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)
Ejemplo n.º 20
0
    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()
Ejemplo n.º 21
0
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)
Ejemplo n.º 22
0
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)
Ejemplo n.º 23
0
 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)
Ejemplo n.º 24
0
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)
Ejemplo n.º 25
0
    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()
Ejemplo n.º 26
0
    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()
Ejemplo n.º 27
0
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)
Ejemplo n.º 28
0
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))
Ejemplo n.º 29
0
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()
Ejemplo n.º 30
0
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))