aboutsummaryrefslogtreecommitdiffstats
path: root/squishtests
diff options
context:
space:
mode:
authorSven Kroemeke <skroemeke@luxoft.com>2019-04-03 16:23:06 +0200
committerSvenKa Roem <skroemeke@luxoft.com>2019-04-08 14:47:24 +0000
commitbb00de39ac1c93b607b2ad9cb968560e4bb4ee33 (patch)
treedea5dc8487cba2adac608c8ba2840c03ac6d6844 /squishtests
parent91bcf5460cb222680cde91169be3214ae4c470e3 (diff)
[squish] add simple phone widget test
The phone widget has a short list of numbers to call, mainly it's the same as phone app. Hence a new test is introduced, common steps of phone moved to a new file, and a (later to be moved) general list function had to be added. From the favorites short view, persons can be called by giving the name. Change-Id: I6034fd57d6c557aab49bc7e6f7c53a28baa05942 Reviewed-by: Bramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com>
Diffstat (limited to 'squishtests')
-rw-r--r--squishtests/suite_neptune3/shared/scripts/bdd_hooks.py44
-rw-r--r--squishtests/suite_neptune3/shared/scripts/common/qml_names.py3
-rw-r--r--squishtests/suite_neptune3/shared/steps/common_phone.py65
-rw-r--r--squishtests/suite_neptune3/tst_app_phone/steps/app_phone.py28
-rw-r--r--squishtests/suite_neptune3/tst_widget_phone/steps/widget_phone.py96
-rw-r--r--squishtests/suite_neptune3/tst_widget_phone/test.feature15
-rw-r--r--squishtests/suite_neptune3/tst_widget_phone/test.py42
7 files changed, 265 insertions, 28 deletions
diff --git a/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py b/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py
index b0f3e354..9290c938 100644
--- a/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py
+++ b/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py
@@ -35,6 +35,7 @@
import math
import os # needed for app identification path
+import __builtin__ as builtins # python types (not squish)
import common.settings as settings
import common.app as app
@@ -249,6 +250,49 @@ def find_object_name_recursively(obj, obj_name, max_depth):
return None
+def find_same_prefix_list(obj, list_prefix, max_depth):
+ """Find a (child) listlist of object with same prefix,
+ which are in same level (siblings)
+ to max depth levels of the starting object.
+ The staring child 0 has to exist, and also we assume
+ that digits for low number don't have 001 or 01."""
+ return_obj_list = None
+ if max_depth > 0:
+ zero_element_name = list_prefix + "0"
+ zero_element = find_object_name_recursively(obj, zero_element_name,
+ max_depth)
+ if zero_element is not None:
+ parent = object.parent(zero_element)
+ if parent is not None:
+ # now check all children for same prefix and add
+ chdl = object.children(parent)
+ for chd in chdl:
+ if not hasattr(chd, "objectName"):
+ continue
+ full_obj_name = str(chd.objectName)
+ suffix = full_obj_name.replace(list_prefix, "")
+ # test that removing prefix doesn't
+ # do anything
+ if suffix == full_obj_name:
+ continue
+ _try_number = 0
+ try:
+ _try_number = builtins.int(suffix)
+ except ValueError:
+ continue
+ # here it should be ok
+ # one could check, if it is a counting up
+ # number (to before) or if it is +1 always
+ # ... this will be a first cheap version,
+ # taking anything that fits
+ if return_obj_list is None:
+ # first entry
+ return_obj_list = [chd]
+ else:
+ return_obj_list.append(chd)
+ return return_obj_list
+
+
def get_position_item(itemObjectOrName):
"""Gets the position of the given object in the coordinates of the
root object"""
diff --git a/squishtests/suite_neptune3/shared/scripts/common/qml_names.py b/squishtests/suite_neptune3/shared/scripts/common/qml_names.py
index 310d5d7d..54134b70 100644
--- a/squishtests/suite_neptune3/shared/scripts/common/qml_names.py
+++ b/squishtests/suite_neptune3/shared/scripts/common/qml_names.py
@@ -52,4 +52,7 @@ viewPhoneButtons = ['recents',
phone_contactView_prefix = "contactNr_"
phone_contactView_button_prefix = "callButtonContactNr_"
phone_contactView_caller_prefix = "contactNameOfNr_"
+phone_shortcall_prefix = "favoritesShortCall_"
+phone_shortcall_name = "shortCallName"
+phone_shortcall_button = "shortCallButton"
app_downloads_prefix = "itemDownloadApp_"
diff --git a/squishtests/suite_neptune3/shared/steps/common_phone.py b/squishtests/suite_neptune3/shared/steps/common_phone.py
new file mode 100644
index 00000000..465ea411
--- /dev/null
+++ b/squishtests/suite_neptune3/shared/steps/common_phone.py
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+
+############################################################################
+##
+## Copyright (C) 2019 Luxoft Sweden AB
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the Neptune 3 IVI UI.
+##
+## $QT_BEGIN_LICENSE:GPL-QTAS$
+## Commercial License Usage
+## Licensees holding valid commercial Qt Automotive Suite licenses may use
+## this file in accordance with the commercial license agreement provided
+## with the Software or, alternatively, in accordance with the terms
+## contained in a written agreement between you and The Qt Company. For
+## licensing terms and conditions see https://www.qt.io/terms-conditions.
+## For further information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 or (at your option) any later version
+## approved by the KDE Free Qt Foundation. The licenses are as published by
+## the Free Software Foundation and appearing in the file LICENSE.GPL3
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+## SPDX-License-Identifier: GPL-3.0
+##
+############################################################################
+
+import squish
+import names
+
+import common.app as app
+
+
+@Then("number from entry '|word|' should be called")
+def step(context, views):
+ if not context.userData:
+ context.userData = {}
+ calling_name = context.userData['calling']
+
+ # use a natural numbering, so +1 since entry 0 is entry 1
+ squish.snooze(0.25)
+ # switch and wait a little
+ app.switch_to_app('phone')
+ squish.snooze(0.25)
+
+ caller_name_obj = squish.waitForObject(names.phoneCallerLabel)
+
+ caller_name = None
+ if caller_name_obj is not None:
+ caller_name = str(caller_name_obj.text)
+ # end call before comparing
+ end_call_button = squish.waitForObject(names.phoneCallerEndButton)
+ squish.tapObject(end_call_button)
+
+ app.compare(calling_name, caller_name, "calling the right name")
+
+ # switch to main before new command
+ app.switch_to_main_app()
+ squish.snooze(0.2)
diff --git a/squishtests/suite_neptune3/tst_app_phone/steps/app_phone.py b/squishtests/suite_neptune3/tst_app_phone/steps/app_phone.py
index 3d7dc918..4e14fb6d 100644
--- a/squishtests/suite_neptune3/tst_app_phone/steps/app_phone.py
+++ b/squishtests/suite_neptune3/tst_app_phone/steps/app_phone.py
@@ -164,31 +164,3 @@ def step(context, view_name, entry_number):
# switch to main before new command
app.switch_to_main_app()
squish.snooze(0.2)
-
-
-@Then("number from entry '|word|' should be called")
-def step(context, views):
- if not context.userData:
- context.userData = {}
- calling_name = context.userData['calling']
-
- # use a natural numbering, so +1 since entry 0 is entry 1
- squish.snooze(0.25)
- # switch and wait a little
- app.switch_to_app('phone')
- squish.snooze(0.25)
-
- caller_name_obj = squish.waitForObject(names.phoneCallerLabel)
-
- caller_name = None
- if caller_name_obj is not None:
- caller_name = str(caller_name_obj.text)
- # end call before comparing
- end_call_button = squish.waitForObject(names.phoneCallerEndButton)
- squish.tapObject(end_call_button)
-
- app.compare(calling_name, caller_name, "calling the right name")
-
- # switch to main before new command
- app.switch_to_main_app()
- squish.snooze(0.2)
diff --git a/squishtests/suite_neptune3/tst_widget_phone/steps/widget_phone.py b/squishtests/suite_neptune3/tst_widget_phone/steps/widget_phone.py
new file mode 100644
index 00000000..2db9df28
--- /dev/null
+++ b/squishtests/suite_neptune3/tst_widget_phone/steps/widget_phone.py
@@ -0,0 +1,96 @@
+# -*- coding: utf-8 -*-
+
+############################################################################
+##
+## Copyright (C) 2019 Luxoft Sweden AB
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the Neptune 3 IVI UI.
+##
+## $QT_BEGIN_LICENSE:GPL-QTAS$
+## Commercial License Usage
+## Licensees holding valid commercial Qt Automotive Suite licenses may use
+## this file in accordance with the commercial license agreement provided
+## with the Software or, alternatively, in accordance with the terms
+## contained in a written agreement between you and The Qt Company. For
+## licensing terms and conditions see https://www.qt.io/terms-conditions.
+## For further information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 or (at your option) any later version
+## approved by the KDE Free Qt Foundation. The licenses are as published by
+## the Free Software Foundation and appearing in the file LICENSE.GPL3
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+## SPDX-License-Identifier: GPL-3.0
+##
+############################################################################
+
+
+import names
+import common.app as app
+import common.qml_names as qml
+
+
+@OnFeatureStart
+def hook(context):
+ start_neptune_ui_app_w_focus("console")
+
+
+@Given("call '|word|' '|word|' on the phone widget short list")
+def step(context, firstname, lastname):
+ if not context.userData:
+ context.userData = {}
+
+ app.switch_to_app('phone')
+
+ # concat names
+ name = firstname + " " + lastname
+
+ start_search = squish.waitForObject(
+ names.phonefavoritesView_FavoritesWidgetView)
+ short_list = find_same_prefix_list(start_search,
+ qml.phone_shortcall_prefix,
+ 4)
+ success = False
+ if short_list is not None:
+ for item in short_list:
+ name_obj = find_object_name_recursively(item,
+ qml.phone_shortcall_name,
+ 5)
+ if name_obj is not None:
+ full_name = str(name_obj.text)
+ if full_name == name:
+ # after name has matched, search the button
+ # and call
+ call_button = find_object_name_recursively(
+ item,
+ qml.phone_shortcall_button,
+ 5)
+ if call_button is not None:
+ squish.tapObject(call_button)
+ success = True
+ context.userData['calling'] = name
+ break
+ else:
+ test.fail("name '"
+ + name
+ + "' found but not the button")
+ else:
+ test.fail("listitem's descendant must contain '"
+ + qml.phone_shortcall_name
+ + "'!")
+ else:
+ test.fail("should not happen: '"
+ + qml.phone_shortcall_prefix
+ + "' list in phone not found!")
+ # check if a correct item was found
+ app.compare(success, True, "name " + name
+ + (" was found!" if success else " was not found!"))
+ # back to main
+ app.switch_to_main_app()
diff --git a/squishtests/suite_neptune3/tst_widget_phone/test.feature b/squishtests/suite_neptune3/tst_widget_phone/test.feature
new file mode 100644
index 00000000..b889e23b
--- /dev/null
+++ b/squishtests/suite_neptune3/tst_widget_phone/test.feature
@@ -0,0 +1,15 @@
+Feature: Test phone widget functionality
+
+ Test some features of the phone widget.
+
+
+ Scenario Outline: Call some people on the phone widget short list
+
+ Given main menu is open
+ And call '<firstnames>' '<lastnames>' on the phone widget short list
+ Then number from entry 'favorites' should be called
+
+ Examples:
+ | firstnames | lastnames |
+ | Jody | Smith |
+ | Edward | Jackson |
diff --git a/squishtests/suite_neptune3/tst_widget_phone/test.py b/squishtests/suite_neptune3/tst_widget_phone/test.py
new file mode 100644
index 00000000..8a8d9be2
--- /dev/null
+++ b/squishtests/suite_neptune3/tst_widget_phone/test.py
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+
+############################################################################
+##
+## Copyright (C) 2019 Luxoft Sweden AB
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the Neptune 3 IVI UI.
+##
+## $QT_BEGIN_LICENSE:GPL-QTAS$
+## Commercial License Usage
+## Licensees holding valid commercial Qt Automotive Suite licenses may use
+## this file in accordance with the commercial license agreement provided
+## with the Software or, alternatively, in accordance with the terms
+## contained in a written agreement between you and The Qt Company. For
+## licensing terms and conditions see https://www.qt.io/terms-conditions.
+## For further information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 or (at your option) any later version
+## approved by the KDE Free Qt Foundation. The licenses are as published by
+## the Free Software Foundation and appearing in the file LICENSE.GPL3
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+## SPDX-License-Identifier: GPL-3.0
+##
+############################################################################
+source(findFile('scripts', 'python/bdd.py'))
+source(findFile('scripts', '../shared/scripts/common/__init__.py'))
+
+setupHooks('../shared/scripts/bdd_hooks.py')
+collectStepDefinitions('./steps', '../shared/steps')
+
+
+def main():
+ testSettings.throwOnFailure = True
+ runFeatureFile('test.feature')