Skip to content

Commit

Permalink
Add Functionnal test
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeldelucena committed Oct 24, 2018
1 parent f69f580 commit 626381a
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests-functionnal/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ def start_dialog(self,btn_name):

def get_status_text(self):
return self.funq.widget(path='mainWindow::statusBar::QLabel').properties()['text']


class QmlAppTestCase(FunqTestCase):
__app_config_name__ = 'qml_app_test'
10 changes: 10 additions & 0 deletions tests-functionnal/funq.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@ aliases = app_test.alias
executable_stdout = NULL
executable_stderr = NULL
screenshot_on_error = 1

[qml_app_test]
executable = /usr/bin/qmlscene
args = qml/Children.qml
funq_port = 9999
cwd = .
aliases = qml_app_test.alias
executable_stdout = NULL
executable_stderr = NULL
screenshot_on_error = 1
20 changes: 20 additions & 0 deletions tests-functionnal/qml/Children.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import QtQuick 2.0

Item {
id: main
Text {
text: "Parent"
}

Item {
Text {
text: "Child"
}

Item {
Text {
text: "Grandchild"
}
}
}
}
55 changes: 55 additions & 0 deletions tests-functionnal/test_qml_item_children.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-

# Copyright: SCLE SFE
# Contributor: Rafael de Lucena Valle <rafaeldelucena@gmail.com>
#
# This software is a computer program whose purpose is to test graphical
# applications written with the QT framework (http://qt.digia.com/).
#
# This software is governed by the CeCILL v2.1 license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL v2.1 license and that you accept its terms.

from base import QmlAppTestCase
from funq.client import FunqClient

class TestQmlItemChilden(QmlAppTestCase):

def get_children_by_property(self, prop, recursive=False):
self.funq = FunqClient()
widget = self.funq.active_widget()
item = widget.item(id='main')
children = item.children(recursive=recursive)
return [child.properties().get(prop) for child in children.iter() if prop in child.properties()]

def test_non_recursive_children(self):
children = self.get_children_by_property('text')
self.assertIn('Parent', children)

def test_recursive_children(self):
children = self.get_children_by_property('text', recursive=True)
self.assertIn('Parent', children)
self.assertIn('Child', children)
self.assertIn('Grandchild', children)

0 comments on commit 626381a

Please sign in to comment.