← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

Re: [Merge] lp:~carla-sella/ubuntu-docviewer-app/test-toc into lp:ubuntu-docviewer-app

 

Here's the log: http://paste.ubuntu.com/10971013/

I think I found out the issue.
When you run the test, where is the DocViewer window on the screen?

If the window is anchored on the bottom-right corner, the suite runs well with no failure, but if the window is floating in the middle of the screen, ToC tests return a failure.

Having a look at what happens on the screen, it seems that depends on the WM.

I've seen that in the former case, the mouse cursor does not change its hint and it's not possible to resize the window from its bottom edge, since the cursor can not reach the border of the window.

In the latter that's possible, and the window is resized.

The 0.3 second delay makes the tests working, so I suppose that the coordinate for the bottomEdgeTip are wrong.
Without the delay, the mouse cursor is moved to y=659, with the delay to y=644. The difference is 15px. If it may be useful, 15px = units.gu(1.875).

Diff comments:

> === modified file 'po/com.ubuntu.docviewer.pot'
> --- po/com.ubuntu.docviewer.pot	2015-04-27 16:02:40 +0000
> +++ po/com.ubuntu.docviewer.pot	2015-05-02 10:27:39 +0000
> @@ -8,7 +8,7 @@
>  msgstr ""
>  "Project-Id-Version: \n"
>  "Report-Msgid-Bugs-To: \n"
> -"POT-Creation-Date: 2015-04-27 18:02+0200\n"
> +"POT-Creation-Date: 2015-05-01 16:54+0200\n"
>  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
>  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
>  "Language-Team: LANGUAGE <LL@xxxxxx>\n"
> @@ -34,7 +34,7 @@
>  
>  #: ../src/app/docviewer-application.cpp:164
>  #: ../src/app/qml/documentPage/DocumentPage.qml:25
> -#: /home/stefano/tmp/build-ch-imported-documents-name-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
> +#: /home/letozaf/autopilot-tests/build-ubuntu-docviewer-app-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
>  msgid "Document Viewer"
>  msgstr ""
>  
> @@ -257,12 +257,12 @@
>  msgstr ""
>  
>  #. TRANSLATORS: "Contents" refers to the "Table of Contents" of a PDF document.
> -#: ../src/app/qml/pdfView/PdfContentsPage.qml:26
> +#: ../src/app/qml/pdfView/PdfContentsPage.qml:31
>  #: ../src/app/qml/pdfView/PdfView.qml:37
>  msgid "Contents"
>  msgstr ""
>  
> -#: ../src/app/qml/pdfView/PdfContentsPage.qml:32
> +#: ../src/app/qml/pdfView/PdfContentsPage.qml:37
>  msgid "Hide table of contents"
>  msgstr ""
>  
> @@ -319,6 +319,6 @@
>  msgid "Open"
>  msgstr ""
>  
> -#: /home/stefano/tmp/build-ch-imported-documents-name-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
> +#: /home/letozaf/autopilot-tests/build-ubuntu-docviewer-app-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
>  msgid "documents;viewer;pdf;reader;"
>  msgstr ""
> 
> === modified file 'src/app/qml/pdfView/PdfContentsPage.qml'
> --- src/app/qml/pdfView/PdfContentsPage.qml	2015-04-16 12:58:29 +0000
> +++ src/app/qml/pdfView/PdfContentsPage.qml	2015-05-02 10:27:39 +0000
> @@ -22,6 +22,11 @@
>  import "../upstreamComponents"
>  
>  Page {
> +    id: pdfContents
> +    objectName: "pdfcontents"
> +
> +    property string testProperty: "for page name issue"

I never heard about the bug, so thanks for pointing out the bug report and adding a comment in the source code.

> +
>      // TRANSLATORS: "Contents" refers to the "Table of Contents" of a PDF document.
>      title: i18n.tr("Contents")
>  
> @@ -57,6 +62,7 @@
>  
>      ListView {
>          id: view
> +        objectName: "view"
>          anchors.fill: parent
>          clip: true
>  
> @@ -64,6 +70,7 @@
>  
>          delegate: ListItemWithActions {
>              id: delegate
> +            objectName: "delegate" + index
>  
>              width: parent.width
>              height: (model.level === 0) ? units.gu(7) : units.gu(6)
> @@ -73,6 +80,7 @@
>                                                        : Theme.palette.normal.background
>  
>              AbstractButton {
> +                objectName: "abstractbutton"
>                  anchors.fill: parent
>  
>                  onClicked: {
> @@ -91,6 +99,7 @@
>                  spacing: units.gu(1)
>  
>                  Label {
> +                    objectName: "content"
>                      Layout.fillWidth: true
>  
>                      text: model.title
> @@ -102,6 +111,7 @@
>                  }
>  
>                  Label {
> +                    objectName: "pageindex"
>                      text: model.pageIndex + 1
>                      font.weight: model.level == 0 ? Font.DemiBold : Font.Normal
>                      color: (model.level === 0) ? UbuntuColors.midAubergine
> 
> === modified file 'tests/autopilot/ubuntu_docviewer_app/__init__.py'
> --- tests/autopilot/ubuntu_docviewer_app/__init__.py	2015-04-14 15:37:06 +0000
> +++ tests/autopilot/ubuntu_docviewer_app/__init__.py	2015-05-02 10:27:39 +0000
> @@ -20,6 +20,7 @@
>  from autopilot import logging as autopilot_logging
>  logger = logging.getLogger(__name__)
>  
> +from autopilot.introspection import dbus
>  import ubuntuuitoolkit
>  
>  
> @@ -58,10 +59,20 @@
>          return self.wait_select_single(PdfView)
>  
>      @autopilot_logging.log_action(logger.info)
> +    def open_PdfContentsPage(self):
> +        """Open the PdfContents Page.
> +
> +        :return the PdfContents Page
> +
> +        """
> +        return self.wait_select_single(PdfContentsPage)
> +
> +    @autopilot_logging.log_action(logger.info)
>      def get_PdfViewGotoDialog(self):
>          """Return a dialog emulator"""
>          return self.wait_select_single(objectName="PdfViewGotoDialog")
>  
> +    @autopilot_logging.log_action(logger.info)
>      def go_to_page_from_dialog(self, page_no):
>          """ Go to page from get_PfdViewGotoDialog """
>          textfield = self.wait_select_single(
> @@ -70,6 +81,12 @@
>          go_button = self.wait_select_single("Button", objectName="GOButton")
>          self.pointing_device.click_object(go_button)
>  
> +    @autopilot_logging.log_action(logger.info)
> +    def click_go_to_page_button(self):
> +        """Click the go_to_page header button."""
> +        header = self.get_header()
> +        header.click_action_button('gotopage')
> +
>  
>  class Page(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
>  
> @@ -82,15 +99,88 @@
>          self.main_view = self.get_root_instance().select_single(MainView)
>  
>  
> -class PdfView(Page):
> +class PageWithBottomEdge(MainView):
> +    """
> +    An emulator class that makes it easy to interact with the bottom edge
> +    swipe page
> +    """
> +    def __init__(self, *args):
> +        super(PageWithBottomEdge, self).__init__(*args)
> +
> +    def reveal_bottom_edge_page(self):
> +        """Bring the bottom edge page to the screen"""
> +        self.bottomEdgePageLoaded.wait_for(True)
> +        try:
> +            action_item = self.wait_select_single(objectName='bottomEdgeTip')
> +            action_item.visible.wait_for(True)
> +            start_x = (action_item.globalRect.x +
> +                       (action_item.globalRect.width * 0.5))
> +            start_y = (action_item.globalRect.y +
> +                       (action_item.height * 0.5))
> +            stop_y = start_y - (self.height * 0.7)
> +            self.pointing_device.drag(start_x, start_y,
> +                                      start_x, stop_y, rate=2)
> +            self.isReady.wait_for(True)
> +        except dbus.StateNotFoundError:
> +            logger.error('BottomEdge element not found.')
> +            raise
> +
> +
> +class PdfView(PageWithBottomEdge):
>      """Autopilot helper for PdfView page."""
>  
>      @autopilot_logging.log_action(logger.info)
>      def toggle_header_visibility(self):
>          """Show/hide page header by clicking on the center of main view"""
> -        self.pointing_device.click_object(self.main_view)
> -
> -    def click_go_to_page_button(self):
> -        """Click the go_to_page header button."""
> -        header = self.main_view.get_header()
> -        header.click_action_button('gotopage')
> +        self.pointing_device.click_object(self)
> +
> +    def get_currentpage_number(self):
> +        """return the value of the currentPage property"""
> +        logger.warn(self.currentPage)
> +        return self.currentPage
> +
> +
> +class PdfContentsPage(Page):
> +    """Autopilot helper for PdfContents page."""
> +
> +    @autopilot_logging.log_action(logger.info)
> +    def get_content_and_line_pageindex(self, labelText):
> +        content_line, page_no = self._get_listitem(labelText)
> +        return content_line, page_no
> +
> +    def _get_listitem(self, labelText):
> +        list_items_count = self.select_single(
> +            "QQuickListView", objectName="view").count
> +
> +        index = 0
> +        for index in range(list_items_count):
> +            while True:
> +                try:
> +                    list_item = self.select_single(
> +                        "ListItemWithActions", objectName="delegate{}".
> +                        format(index))
> +                    break
> +                except dbus.StateNotFoundError:
> +                    self.scroll_pdfcontentspage()
> +            label = list_item.select_single("Label", objectName="content")
> +            if label.text == labelText:
> +                page_no = list_item.select_single(
> +                    "Label", objectName="pageindex").text
> +                return label, page_no
> +                break
> +
> +    @autopilot_logging.log_action(logger.info)
> +    def click_content_line(self, content_line):
> +        self.pointing_device.click_object(content_line)
> +
> +    @autopilot_logging.log_action(logger.info)
> +    def scroll_pdfcontentspage(self):
> +        action_item = self.select_single("QQuickListView")
> +        start_x = (self.globalRect.x +
> +                   (self.globalRect.width * 0.5))
> +        start_y = (self.globalRect.y +
> +                   (self.height * 0.7))
> +        stop_y = start_y - (self.height * 0.8)
> +        self.pointing_device.drag(start_x, start_y,
> +                                  start_x, stop_y, rate=2)
> +        action_item.moving.wait_for(False)
> 
> === added file 'tests/autopilot/ubuntu_docviewer_app/files/serverguide.pdf'
> Binary files tests/autopilot/ubuntu_docviewer_app/files/serverguide.pdf	1970-01-01 00:00:00 +0000 and tests/autopilot/ubuntu_docviewer_app/files/serverguide.pdf	2015-05-02 10:27:39 +0000 differ
> === modified file 'tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py'
> --- tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py	2015-04-14 15:37:06 +0000
> +++ tests/autopilot/ubuntu_docviewer_app/tests/test_docviewer.py	2015-05-02 10:27:39 +0000
> @@ -60,7 +60,7 @@
>          self.launch_app()
>          pdf = self.app.main_view.open_PdfView()
>          pdf.toggle_header_visibility()
> -        pdf.click_go_to_page_button()
> +        self.app.main_view.click_go_to_page_button()
>          self.go_to_page_no(page_no)
>  
>          self.assertThat(
> 
> === added file 'tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py'
> --- tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py	1970-01-01 00:00:00 +0000
> +++ tests/autopilot/ubuntu_docviewer_app/tests/test_toc.py	2015-05-02 10:27:39 +0000
> @@ -0,0 +1,49 @@
> +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
> +# Copyright 2013 Canonical
> +#
> +# This program is free software: you can redistribute it and/or modify it
> +# under the terms of the GNU General Public License version 3, as published
> +# by the Free Software Foundation.
> +
> +"""Docviewer app autopilot tests."""
> +
> +from ubuntu_docviewer_app.tests import DocviewerAppTestCase
> +
> +import logging
> +logger = logging.getLogger(__name__)
> +
> +
> +class TestMainWindow(DocviewerAppTestCase):
> +
> +    """Tests the TOC features"""
> +    scenarios = [
> +        ('Chapter 1',
> +            {'content_label': 'Chapter 1. Introduction'
> +             }),
> +
> +        ('Chapter 3',
> +            {'content_label': 'Chapter 3. Package Management',
> +             })
> +    ]
> +
> +    def setUp(self):
> +        super(TestMainWindow, self).setUp()
> +
> +    def test_go_to_chapters_in_toc(self):
> +        """" Testing going to chapters from Table Of Contents     """
> +        self.filepath = 'ubuntu_docviewer_app/files/serverguide.pdf'
> +
> +        self.launch_app()
> +        pdf = self.app.main_view.open_PdfView()
> +        pdf.reveal_bottom_edge_page()
> +        contents_page = self.app.main_view.open_PdfContentsPage()
> +        content_line, page_no = contents_page.\
> +            get_content_and_line_pageindex(self.content_label)
> +        logger.warn(page_no)
> +        contents_page.click_content_line(content_line)
> +
> +        word_in_currentpage = pdf.get_currentpage_number().split()
> +        pdfview_currentpage = word_in_currentpage[1]
> +        logger.warn(pdfview_currentpage)
> +
> +        self.assertEquals(pdfview_currentpage, page_no)
> 


-- 
https://code.launchpad.net/~carla-sella/ubuntu-docviewer-app/test-toc/+merge/258082
Your team Ubuntu Document Viewer Developers is subscribed to branch lp:ubuntu-docviewer-app.


References