aboutsummaryrefslogtreecommitdiffstats
path: root/squishtests
diff options
context:
space:
mode:
authorSven Kroemeke <skroemeke@luxoft.com>2019-03-07 16:22:08 +0100
committerSvenKa Roem <skroemeke@luxoft.com>2019-03-20 07:58:54 +0000
commit50934d21d4dcd5dd002ba1a8b1095217916ad472 (patch)
treee83f5aefc7f7130f8a2d25ca3d1c5564bf20ce09 /squishtests
parente72a99b1513ba72abd44fb3c2f962830f2528b8b (diff)
[squish] add simple settings app tests
For settings app there are some simple tests: - Date am/pm to 24h display switch - Language switch to German - Theme toggle Color is missing due to geometry issues in testing, and clicking correctly is not that simple. Also, due to simplification with more apps to come the container switch was changed. Change-Id: Ia1a154ed85ce929a88783e1b51eb9fccaa0ddaab Reviewed-by: Bramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com>
Diffstat (limited to 'squishtests')
-rw-r--r--squishtests/suite_neptune3/shared/scripts/bdd_hooks.py6
-rw-r--r--squishtests/suite_neptune3/shared/scripts/common/qml_names.py2
-rw-r--r--squishtests/suite_neptune3/shared/scripts/names.py72
-rw-r--r--squishtests/suite_neptune3/suite.conf2
-rw-r--r--squishtests/suite_neptune3/tst_app_settings/steps/app_settings.py195
-rw-r--r--squishtests/suite_neptune3/tst_app_settings/test.feature45
-rw-r--r--squishtests/suite_neptune3/tst_app_settings/test.py42
7 files changed, 336 insertions, 28 deletions
diff --git a/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py b/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py
index ff0e0ccc..b0f3e354 100644
--- a/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py
+++ b/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py
@@ -117,9 +117,9 @@ def start_neptune_ui_app_w_focus(window):
# if it is multi process, change search container for
# all according apps
if settings.G_MULTI_PROCESS:
- # change search container
- names.change_ref_climate_app(names.multi_process_container)
- names.change_ref_calendar_app(names.multi_process_container)
+ # change for all known apps the search container
+ for change_app in names.apps_change_collection:
+ change_app(names.multi_process_container)
# to be able to focus window we need the neptune main app
app.switch_to_main_app()
diff --git a/squishtests/suite_neptune3/shared/scripts/common/qml_names.py b/squishtests/suite_neptune3/shared/scripts/common/qml_names.py
index 1ded0b06..87aeaa08 100644
--- a/squishtests/suite_neptune3/shared/scripts/common/qml_names.py
+++ b/squishtests/suite_neptune3/shared/scripts/common/qml_names.py
@@ -41,3 +41,5 @@ home_widget = "homeWidget_"
calendar_view = {'events': 'eventList',
'year': 'calendarGridPanel',
'next': 'nextCalendarPanel'}
+prefix_language = "language_"
+prefix_themes = "themeNr_"
diff --git a/squishtests/suite_neptune3/shared/scripts/names.py b/squishtests/suite_neptune3/shared/scripts/names.py
index 98be1aa4..9568cf4a 100644
--- a/squishtests/suite_neptune3/shared/scripts/names.py
+++ b/squishtests/suite_neptune3/shared/scripts/names.py
@@ -35,22 +35,6 @@
from objectmaphelper import *
import referencer
-o_QVariant = {"type": "QVariant"}
-neptune_UI_Center_Console = {"title": "Neptune 3 UI - Center Console", "type": "QQuickWindowQmlImpl", "unnamed": 1, "visible": True}
-o_QtAM_ApplicationManagerWindow = {"type": "QtAM::ApplicationManagerWindow", "unnamed": 1, "visible": True}
-
-# we need a copy and not reference
-multi_process_container = o_QtAM_ApplicationManagerWindow.copy()
-climate_single_process_container = neptune_UI_Center_Console.copy()
-calendar_single_process_container = neptune_UI_Center_Console.copy()
-
-# define for each app an own starting-to-search container,
-# they all might look the same and could maybe be simplified
-# but we can leave this option open, if in case, one of the
-# apps cannot simply be replaced by the "center-console"-container
-container_climate = climate_single_process_container.copy()
-container_calendar = calendar_single_process_container.copy()
-
# stores all containers
apps_reference_container = {}
@@ -64,18 +48,48 @@ def container_getter(identifier):
return apps_reference_container[identifier]
-apps_reference_container = {'container_climate': container_climate,
- 'container_calendar': container_calendar}
+o_QVariant = {"type": "QVariant"}
+neptune_UI_Center_Console = {"title": "Neptune 3 UI - Center Console", "type": "QQuickWindowQmlImpl", "unnamed": 1, "visible": True}
+o_QtAM_ApplicationManagerWindow = {"type": "QtAM::ApplicationManagerWindow", "unnamed": 1, "visible": True}
-change_ref_climate_app = referencer.Referencer('container_climate',
- container_getter,
- container_setter)
-change_ref_calendar_app = referencer.Referencer('container_calendar',
- container_getter,
- container_setter)
+# Todo: there might be a rather simple and more effective
+# way of switching container as python's way of
+# using references, and (shallow/deep) copy should be
+# much simpler than the below strategy.
+# we need a copy and not reference
+# Use container for each, at this point they are
+# the same, but in the future an app container
+# in single process might be somewhere else in
+# the object tree of Neptune3 UI.
+multi_process_container = o_QtAM_ApplicationManagerWindow.copy()
+climate_single_process_container = neptune_UI_Center_Console.copy()
+calendar_single_process_container = neptune_UI_Center_Console.copy()
+settings_single_process_container = neptune_UI_Center_Console.copy()
+# define for each app an own starting-to-search container,
+# they all might look the same and could maybe be simplified
+# but we can leave this option open, if in case, one of the
+# apps cannot simply be replaced by the "center-console"-container
+container_climate = climate_single_process_container.copy()
+container_calendar = calendar_single_process_container.copy()
+container_settings = settings_single_process_container.copy()
+# contains the changer
+apps_reference_container = {'container_climate': container_climate,
+ 'container_calendar': container_calendar,
+ 'container_settings': container_settings}
+
+# create an array of all changers, they will be used not singled out
+# but rather as the whole collection if mode is multi-process
+apps_change_collection = []
+for app_ref_str in apps_reference_container.keys():
+ app_referencer = referencer.Referencer(app_ref_str,
+ container_getter,
+ container_setter)
+ apps_change_collection.append(app_referencer)
+
+# ###########################################################################
neptune_UI_Center_Console_grid_GridView = {"container": neptune_UI_Center_Console, "id": "grid", "type": "GridView", "unnamed": 1, "visible": True}
neptune_UI_Instrument_Cluster_QQuickWindowQmlImpl = {"title": "Neptune 3 UI - Instrument Cluster", "type": "QQuickWindowQmlImpl", "unnamed": 1, "visible": True, "window": o_QVariant}
grid_Item = {"container": neptune_UI_Center_Console_grid_GridView, "type": "Item", "unnamed": 1, "visible": True}
@@ -112,3 +126,13 @@ recirculation_Button = {"checkable": True, "container": container_climate, "obje
seat_heater_driver_Button = {"checkable": True, "container": container_climate, "objectName": "seat_heater_driver", "type": "Button", "visible": True}
steering_wheel_heat_Button = {"checkable": True, "container": container_climate, "objectName": "steering_wheel_heat", "type": "Button", "visible": True}
seat_heater_passenger_Button = {"checkable": True, "container": container_climate, "objectName": "seat_heater_passenger", "type": "Button", "visible": True}
+languageViewButton_ToolButton = {"container": container_settings, "objectName": "languageViewButton", "type": "ToolButton", "visible": True}
+dateViewButton_ToolButton = {"container": container_settings, "objectName": "dateViewButton", "type": "ToolButton", "visible": True}
+themesViewButton_ToolButton = {"container": container_settings, "objectName": "themesViewButton", "type": "ToolButton", "visible": True}
+colorsViewButton_ToolButton = {"container": container_settings, "objectName": "colorsViewButton", "type": "ToolButton", "visible": True}
+languagePanel_LanguagePanel = {"container": container_settings, "objectName": "languagePanel", "type": "LanguagePanel"}
+datePanel_DateTimePanel = {"container": container_settings, "objectName": "datePanel", "type": "DateTimePanel"}
+colorsPanel_ColorsPanel = {"container": container_settings, "objectName": "colorsPanel", "type": "ColorsPanel"}
+themesPanel_ThemesPanel = {"container": container_settings, "objectName": "themesPanel", "type": "ThemesPanel"}
+dateTimeSwitch_SwitchDelegate = {"container": container_settings, "objectName": "dateTimeSwitch", "type": "SwitchDelegate"}
+dateAndTime = {"container": neptune_UI_Center_Console, "type": "DateAndTime", "objectName": "dateAndTime", "visible": True}
diff --git a/squishtests/suite_neptune3/suite.conf b/squishtests/suite_neptune3/suite.conf
index db153250..dc06ab8c 100644
--- a/squishtests/suite_neptune3/suite.conf
+++ b/squishtests/suite_neptune3/suite.conf
@@ -5,6 +5,6 @@ HOOK_SUB_PROCESSES=true
IMPLICITAUTSTART=0
LANGUAGE=Python
OBJECTMAPSTYLE=script
-TEST_CASES=tst_home_screen tst_volume tst_launcher tst_app_common tst_app_calendar
+TEST_CASES=tst_home_screen tst_volume tst_launcher tst_app_common tst_app_calendar tst_app_settings
VERSION=3
WRAPPERS=Qt
diff --git a/squishtests/suite_neptune3/tst_app_settings/steps/app_settings.py b/squishtests/suite_neptune3/tst_app_settings/steps/app_settings.py
new file mode 100644
index 00000000..b065de33
--- /dev/null
+++ b/squishtests/suite_neptune3/tst_app_settings/steps/app_settings.py
@@ -0,0 +1,195 @@
+# -*- 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
+##
+############################################################################
+
+# squish dependent
+import names
+import common.app as app
+import common.qml_names as qml
+
+
+# number of themes, currently only light/dark
+NR_THEMES = 2
+
+
+@OnFeatureStart
+def hook(context):
+ start_neptune_ui_app_w_focus("console")
+
+
+@Given("tap '|word|' button")
+def step(context, view_name):
+ app.switch_to_app('settings')
+ squish.snooze(0.2)
+ if view_name == "language":
+ view_object_name = names.languageViewButton_ToolButton
+ elif view_name == "date":
+ view_object_name = names.dateViewButton_ToolButton
+ elif view_name == "themes":
+ view_object_name = names.themesViewButton_ToolButton
+ else: # view_name == "color":
+ view_object_name = names.colorsViewButton_ToolButton
+
+ events_button = squish.waitForObject(view_object_name)
+ squish.tapObject(events_button)
+
+
+@Then("settings view '|word|' should be displayed")
+def step(context, view_name):
+ if view_name == "language":
+ visible_object = names.languagePanel_LanguagePanel
+ elif view_name == "date":
+ visible_object = names.datePanel_DateTimePanel
+ elif view_name == "themes":
+ visible_object = names.themesPanel_ThemesPanel
+ else: # color
+ visible_object = names.colorsPanel_ColorsPanel
+ test_object = squish.waitForObject(visible_object)
+ test.compare(test_object.visible, True, "settings views")
+
+
+@When("remember date format and tap date switch")
+def step(context):
+ if not context.userData:
+ context.userData = {}
+
+ squish.snooze(0.25)
+ app.switch_to_main_app()
+ date_object = squish.waitForObject(names.dateAndTime)
+ test_text = str(date_object.text)
+ # cheap comparison, only text and searching for 'm'
+ # whether 'am' or 'pm'
+ is_24h_format = not ('m' in test_text)
+ context.userData['isDateFormat24h'] = is_24h_format
+
+ test.log("'" + test_text + "' was " + ("24h" if is_24h_format
+ else "am/pm"))
+
+ app.switch_to_app('settings')
+ squish.snooze(0.25)
+ switch = squish.waitForObject(names.dateTimeSwitch_SwitchDelegate)
+ squish.tapObject(switch)
+
+
+@Then("home screen should show have toggled date format")
+def step(context):
+ if not context.userData:
+ context.userData = {}
+
+ was_24h_format = context.userData['isDateFormat24h']
+ squish.snooze(0.5)
+ app.switch_to_main_app()
+ squish.snooze(0.5)
+ date_object = squish.waitForObject(names.dateAndTime)
+ test_text = str(date_object.text)
+ squish.snooze(0.5)
+ app.switch_to_app('settings')
+ squish.snooze(0.5)
+
+ # search for 'm' is a cheap test, and
+ # should be replaced. 'm' because 'am' and
+ # 'pm' both contain 'm'
+ is_now_24h_format = not ("m" in test_text)
+ test.log("'" + test_text + "' is " + ("24h" if is_now_24h_format
+ else "am/pm"))
+
+ test.compare(was_24h_format, not is_now_24h_format, "date format")
+
+ # switch back
+ app.switch_to_main_app()
+
+
+@When("tap language '|word|' button")
+def step(context, language):
+ squish.snooze(0.5)
+ app.switch_to_app('settings')
+ squish.snooze(0.5)
+
+ test.log("1")
+ language_name = qml.prefix_language + language
+ language_panel = squish.waitForObject(names.languagePanel_LanguagePanel)
+ language_item = find_object_name_recursively(
+ language_panel,
+ language_name, 5)
+ if language_item is None:
+ test.fail("The language abbreviation '"
+ + language + "'"
+ + ' is not known!!')
+ else:
+ ui_item = squish.waitForObject(language_item)
+ squish.tapObject(ui_item)
+ squish.snooze(1.1)
+
+
+@Then("language should switch to '|word|'")
+def step(context, language_abbr):
+ squish.snooze(0.5)
+ app.switch_to_main_app()
+ squish.snooze(0.5)
+ centerc_object = squish.waitForObject(names.neptune_UI_Center_Console)
+ current_lang_abbr = str(centerc_object.store.uiSettings.language)
+ test.compare(language_abbr, current_lang_abbr,
+ "current and wanted language abbreviation")
+
+
+@When("remember current theme and tap non-selected")
+def step(context, ):
+ if not context.userData:
+ context.userData = {}
+ # store current / soon "old" theme
+ theme_panel = squish.waitForObject(names.themesPanel_ThemesPanel)
+ current_theme = theme_panel.currentTheme
+ context.userData['old_theme'] = current_theme
+
+ # tap on next theme
+ tap_theme_index = (current_theme + 1) % NR_THEMES
+ tap_theme_name = qml.prefix_themes + str(tap_theme_index)
+ tap_theme_ui = find_object_name_recursively(theme_panel,
+ tap_theme_name,
+ 5)
+ if tap_theme_ui is not None:
+ ui_theme = squish.waitForObject(tap_theme_ui)
+ squish.tapObject(ui_theme)
+ else:
+ test.fail("toggle theme ui object not found!")
+
+
+@Then("theme should have toggled")
+def step(context):
+ # get current theme
+ theme_panel = squish.waitForObject(names.themesPanel_ThemesPanel)
+ current_theme = theme_panel.currentTheme
+ old_theme = context.userData['old_theme']
+ test.compare(old_theme, (current_theme - 1) % NR_THEMES,
+ "should be the previous theme")
+ # switch back to main context
+ app.switch_to_main_app()
diff --git a/squishtests/suite_neptune3/tst_app_settings/test.feature b/squishtests/suite_neptune3/tst_app_settings/test.feature
new file mode 100644
index 00000000..31b0e96b
--- /dev/null
+++ b/squishtests/suite_neptune3/tst_app_settings/test.feature
@@ -0,0 +1,45 @@
+Feature: Test settings app functionality
+
+ Test some features of the settings app.
+
+
+ Scenario: Open settings app from launcher bar and check
+ some common settings
+
+ Given main menu is open
+ And 'settings' app from launcher tapped
+ And switch app to 'settings'
+ Then wait '1' seconds and 'settings' app is active
+
+
+ Scenario: Test 24/12h switch
+
+ Given main menu is open
+ And 'settings' app from launcher tapped
+ And switch app to 'settings'
+ And tap 'date' button
+ Then settings view 'date' should be displayed
+ When remember date format and tap date switch
+ Then home screen should show have toggled date format
+
+
+ Scenario: Test language change
+
+ Given main menu is open
+ And 'settings' app from launcher tapped
+ And switch app to 'settings'
+ And tap 'language' button
+ Then settings view 'language' should be displayed
+ When tap language 'de_DE' button
+ Then language should switch to 'de_DE'
+
+
+Scenario: Test theme change
+
+ Given main menu is open
+ And 'settings' app from launcher tapped
+ And switch app to 'settings'
+ And tap 'themes' button
+ Then settings view 'themes' should be displayed
+ When remember current theme and tap non-selected
+ Then theme should have toggled
diff --git a/squishtests/suite_neptune3/tst_app_settings/test.py b/squishtests/suite_neptune3/tst_app_settings/test.py
new file mode 100644
index 00000000..8a8d9be2
--- /dev/null
+++ b/squishtests/suite_neptune3/tst_app_settings/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')