diff options
Diffstat (limited to 'src/components/qt_hmi')
48 files changed, 2474 insertions, 69 deletions
diff --git a/src/components/qt_hmi/CMakeLists.txt b/src/components/qt_hmi/CMakeLists.txt index e77a1e23b8..ee30f2b468 100644 --- a/src/components/qt_hmi/CMakeLists.txt +++ b/src/components/qt_hmi/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2013, Ford Motor Company +# Copyright (c) 2014, Ford Motor Company # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -36,3 +36,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "QNX") else () add_subdirectory(./qml_model_qt5) endif () + +if(HMI STREQUAL "qt" AND BUILD_TESTS) + add_subdirectory(test) +endif()
\ No newline at end of file diff --git a/src/components/qt_hmi/References/Work/bananasnacks/qtquick2applicationviewer/qtquick2applicationviewer.h b/src/components/qt_hmi/References/Work/bananasnacks/qtquick2applicationviewer/qtquick2applicationviewer.h index baf67f2479..bd6c50f54f 100644 --- a/src/components/qt_hmi/References/Work/bananasnacks/qtquick2applicationviewer/qtquick2applicationviewer.h +++ b/src/components/qt_hmi/References/Work/bananasnacks/qtquick2applicationviewer/qtquick2applicationviewer.h @@ -6,7 +6,7 @@ handled here. It is recommended not to modify this file, since newer versions of Qt Creator may offer an updated version of it. -*/ + */ #ifndef QTQUICK2APPLICATIONVIEWER_H #define QTQUICK2APPLICATIONVIEWER_H diff --git a/src/components/qt_hmi/qml_model_qt5/controls/SoftButton.qml b/src/components/qt_hmi/qml_model_qt5/controls/SoftButton.qml index 0f3cfd7140..b1b7f71799 100644 --- a/src/components/qt_hmi/qml_model_qt5/controls/SoftButton.qml +++ b/src/components/qt_hmi/qml_model_qt5/controls/SoftButton.qml @@ -49,7 +49,7 @@ OvalButton { highlighted: button ? button.isHighlighted : false onPressed: { actionOrder = SoftButton.Action.doOnClicked - sdlButtons.onButtonEvent(Common.ButtonName.CUSTOM_BUTTON, Common.ButtonEventMode.BUTTONDOWN, button.softButtonID) + sdlButtons.onButtonEvent(Common.ButtonName.CUSTOM_BUTTON, Common.ButtonEventMode.BUTTONDOWN, button.softButtonID, appId) } onReleased: { @@ -67,11 +67,11 @@ OvalButton { } } - sdlButtons.onButtonEvent(Common.ButtonName.CUSTOM_BUTTON, Common.ButtonEventMode.BUTTONUP, button.softButtonID) + sdlButtons.onButtonEvent(Common.ButtonName.CUSTOM_BUTTON, Common.ButtonEventMode.BUTTONUP, button.softButtonID, appId) } onClicked: { - sdlButtons.onButtonPress(Common.ButtonName.CUSTOM_BUTTON, Common.ButtonPressMode.SHORT, button.softButtonID); + sdlButtons.onButtonPress(Common.ButtonName.CUSTOM_BUTTON, Common.ButtonPressMode.SHORT, button.softButtonID, appId); switch (button.systemAction) { case Common.SystemAction.DEFAULT_ACTION: defaultAction(); @@ -87,7 +87,7 @@ OvalButton { onPressAndHold: { actionOrder = SoftButton.Action.doOnReleased; // action should be triggered on release - sdlButtons.onButtonPress(Common.ButtonName.CUSTOM_BUTTON, Common.ButtonPressMode.LONG, button.softButtonID); + sdlButtons.onButtonPress(Common.ButtonName.CUSTOM_BUTTON, Common.ButtonPressMode.LONG, button.softButtonID, appId); } onButtonChanged: { diff --git a/src/components/qt_hmi/qml_model_qt5/hmi_api/UI.qml b/src/components/qt_hmi/qml_model_qt5/hmi_api/UI.qml index d89747c3c0..659b7842c6 100644 --- a/src/components/qt_hmi/qml_model_qt5/hmi_api/UI.qml +++ b/src/components/qt_hmi/qml_model_qt5/hmi_api/UI.qml @@ -203,6 +203,7 @@ Item { "updateMode": Internal.MediaClockUpdateMode.MCU_COUNTUP, "runningMode": Internal.MediaClockRunningMode.MCR_STOPPED, "magic": Internal.stringToHmsTime(fieldSubstrings[Common.TextFieldName.mediaClock]), + "startTime": Internal.stringToHmsTime(fieldSubstrings[Common.TextFieldName.mediaClock]), "startTimeForProgress": -1 } } @@ -339,7 +340,11 @@ Item { break } newStartTime = Internal.hmsTime(startTime.hours, startTime.minutes, startTime.seconds) - newEndTime = endTime ? Internal.hmsTime(endTime.hours, endTime.minutes, endTime.seconds) : -1 + newEndTime = endTime ? Internal.hmsTime(endTime.hours, + endTime.minutes, + endTime.seconds) + : dataContainer.currentApplication.mediaClock.upperTimeLimit + newUpdateMode = Internal.MediaClockUpdateMode.MCU_COUNTUP newRunningMode = Internal.MediaClockRunningMode.MCR_RUNNING newStartTimeForProgress = Internal.hmsTime(startTime.hours, startTime.minutes, startTime.seconds) @@ -353,7 +358,7 @@ Item { break } newStartTime = Internal.hmsTime(startTime.hours, startTime.minutes, startTime.seconds) - newEndTime = endTime ? Internal.hmsTime(endTime.hours, endTime.minutes, endTime.seconds) : -1 + newEndTime = endTime ? Internal.hmsTime(endTime.hours, endTime.minutes, endTime.seconds) : 0 newUpdateMode = Internal.MediaClockUpdateMode.MCU_COUNTDOWN newRunningMode = Internal.MediaClockRunningMode.MCR_RUNNING newStartTimeForProgress = Internal.hmsTime(startTime.hours, startTime.minutes, startTime.seconds) @@ -372,7 +377,7 @@ Item { newEndTime = app.mediaClock.endTime newRunningMode = Internal.MediaClockRunningMode.MCR_STOPPED newUpdateMode = app.mediaClock.updateMode - newStartTimeForProgress = app.mediaClock.startTime + newStartTimeForProgress = app.mediaClock.startTimeForProgress resultCode = Common.Result.SUCCESS break @@ -387,7 +392,7 @@ Item { newStartTime = app.mediaClock.startTime newEndTime = app.mediaClock.endTime newRunningMode = Internal.MediaClockRunningMode.MCR_RUNNING - newStartTimeForProgress = app.mediaClock.startTime + newStartTimeForProgress = app.mediaClock.startTimeForProgress newUpdateMode = app.mediaClock.updateMode resultCode = Common.Result.SUCCESS break @@ -631,7 +636,7 @@ Item { } } - function performAudioPassThru (audioPassThruDisplayTexts, timeout, appID) { + function performAudioPassThru (appID, audioPassThruDisplayTexts, timeout) { var displayTextsLog = ""; if (audioPassThruDisplayTexts) { for (var i = 0; i < audioPassThruDisplayTexts.length; i++) { diff --git a/src/components/qt_hmi/qml_model_qt5/hmi_api/VR.qml b/src/components/qt_hmi/qml_model_qt5/hmi_api/VR.qml index 8a426197e2..8158b3271e 100644 --- a/src/components/qt_hmi/qml_model_qt5/hmi_api/VR.qml +++ b/src/components/qt_hmi/qml_model_qt5/hmi_api/VR.qml @@ -34,7 +34,6 @@ import QtQuick 2.0 import "Common.js" as Common - Item { function isReady() { console.log("Message Received - {method: 'VR.IsReady'}") @@ -43,7 +42,7 @@ Item { } } - function addCommand(cmdID, vrCommands, appID) { + function addCommand(cmdID, vrCommands, type, grammarID, appID) { var vrCommandsLog = ""; if (vrCommands) { for (var i = 0; i < vrCommands.length; i++) { @@ -53,14 +52,29 @@ Item { console.log("Message Received - {method: 'VR.AddCommand', params:{ " + "vrCommands: [" + vrCommandsLog + "], " + "cmdID: " + cmdID + ", " + - "appID: " + appID + + "appID: " + appID + ", " + + "type: " + type + ", " + + "grammarID: " + grammarID + "}}") for (var i = 0; i < vrCommands.length; ++i) { - dataContainer.vrCommands.append({ + if (type === Common.VRCommandType.Command) { + dataContainer.vrCommands.append({ cmdID: cmdID, command: vrCommands[i], appID: appID === undefined ? 0 : appID, + type: type, + grammarID: grammarID, }); + } + else { + dataContainer.choicesVrCommands.append({ + cmdID: cmdID, + command: vrCommands[i], + appID: appID === undefined ? 0 : appID, + type: type, + grammarID: grammarID, + }); + } } console.log("exit") } @@ -111,4 +125,46 @@ Item { dataContainer.changeRegistrationTTSVR(language, appID); console.debug("exit"); } + function ttsChunksToString(ttsChunks){ + return ttsChunks.map(function(str) { return str.text }).join('\n') + } + function performInteraction(helpPrompt, initialPrompt, timeoutPrompt, timeout, grammarID) { + console.debug("enter"); + var helpttsChunksLog = "", + initialttsChunkLog = "", + timeoutttsChunkLog = "", + grammarIDLog =""; + + if (helpPrompt) { + for (var i = 0; i < helpPrompt.length; i++) { + helpttsChunksLog += "{type: " + helpPrompt[i].type + ", " + + "text: '" + helpPrompt[i].text + "'}, "; + } + } + if (initialPrompt) { + for (var i = 0; i < initialPrompt.length; i++) { + initialttsChunkLog += "{type: " + initialPrompt[i].type + ", " + + "text: '" + initialPrompt[i].text + "'}, "; + } + } + if (timeoutPrompt) { + for (var i = 0; i < timeoutPrompt.length; i++) { + timeoutttsChunkLog += "{type: " + timeoutPrompt[i].type + ", " + + "text: '" + timeoutPrompt[i].text + "'}, "; + } + } + console.log("Message Received - {method: 'TTS.PerformInteraction', params:{ " + + "helpPrompt: [" + helpttsChunksLog + "], " + + "initialPrompt: [" + initialttsChunkLog + "], " + + "timeoutPrompt: [" + timeoutttsChunkLog + "], " + + "timeout: " + timeout + + "}}") + + ttsPopUp.performInteraction(ttsChunksToString(helpPrompt), + ttsChunksToString(initialPrompt), + ttsChunksToString(timeoutPrompt), + timeout) + interactionPopup.grammarID = grammarID + console.debug("exit"); + } } diff --git a/src/components/qt_hmi/qml_model_qt5/models/DataStorage.qml b/src/components/qt_hmi/qml_model_qt5/models/DataStorage.qml index 659a8eabd7..e3785bdf19 100644 --- a/src/components/qt_hmi/qml_model_qt5/models/DataStorage.qml +++ b/src/components/qt_hmi/qml_model_qt5/models/DataStorage.qml @@ -442,7 +442,8 @@ QtObject { property ListModel deviceList: ListModel { } property ListModel applicationList: ListModel { } property ListModel stashedApplicationsList: ListModel { } - property ListModel vrCommands: ListModel {} + property ListModel vrCommands: ListModel { } + property ListModel choicesVrCommands: ListModel { } function reset () { console.log("dataContainer reset enter"); diff --git a/src/components/qt_hmi/qml_model_qt5/models/MediaClockModel.qml b/src/components/qt_hmi/qml_model_qt5/models/MediaClockModel.qml index cae82c36f1..3712ca4c31 100644 --- a/src/components/qt_hmi/qml_model_qt5/models/MediaClockModel.qml +++ b/src/components/qt_hmi/qml_model_qt5/models/MediaClockModel.qml @@ -73,28 +73,22 @@ QtObject { function onTimer () { switch (updateMode) { case Internal.MediaClockUpdateMode.MCU_COUNTUP: - if (endTime !== -1) { - if (startTime < endTime) { - startTime++ - } else { - timer.stop() - runningMode = Internal.MediaClockRunningMode.MCR_STOPPED - console.debug("count Up timer stopped") - } + console.debug("count up") + if (startTime < endTime) { + startTime++ } else { - if (startTime < upperTimeLimit) { - startTime++ - } else { - startTime = 0 - } + timer.stop() + runningMode = Internal.MediaClockRunningMode.MCR_STOPPED + console.debug("count Up timer stopped") } break case Internal.MediaClockUpdateMode.MCU_COUNTDOWN: console.debug("count down") - if (--startTime === 0) { + if (startTime > endTime) { + startTime-- + } else { timer.stop() runningMode = Internal.MediaClockRunningMode.MCR_STOPPED - startTime = endTime = -1 console.debug("count Down timer stopped") } break @@ -112,13 +106,12 @@ QtObject { function onProgress () { if (startTime === -1) { progress = 0 - } else { - if (updateMode === Internal.MediaClockUpdateMode.MCU_COUNTUP) { - progress = (endTime !== -1) ? (startTime / endTime) : (startTime / upperTimeLimit) - } else { - progress = (endTime !== -1) ? ( (startTime - endTime) / (startTimeForProgress - endTime) ) - : (startTime / startTimeForProgress) - } + } + else if (endTime != -1 && endTime === startTimeForProgress) { + progress = 1 + } + else { + progress = (startTime - startTimeForProgress) / (endTime - startTimeForProgress) } } } diff --git a/src/components/qt_hmi/qml_model_qt5/popups/InteractionPopup.qml b/src/components/qt_hmi/qml_model_qt5/popups/InteractionPopup.qml index 782fd76c18..a6fc4d7107 100644 --- a/src/components/qt_hmi/qml_model_qt5/popups/InteractionPopup.qml +++ b/src/components/qt_hmi/qml_model_qt5/popups/InteractionPopup.qml @@ -46,6 +46,7 @@ ContextPopup { property int appID property int interactionLayout property var async + property var grammarID property bool performInteractionIsActiveNow Text { @@ -84,13 +85,15 @@ ContextPopup { } } - function performInteraction(initialText, choiceSet, vrHelpTitle, vrHelp, timeout, interactionLayout, appID) { + function performInteraction(initialTextArg, choiceSet, vrHelpTitle, vrHelp, timeout, interactionLayout, appID) { console.debug("enter") var app = dataContainer.getApplication(appID) var dataToUpdate = {} performInteractionIsActiveNow = true - initialText.text = initialText.fieldText + if (initialTextArg !== undefined){ + initialText.text = initialTextArg.fieldText + } this.timeout = timeout this.appID = appID @@ -123,6 +126,8 @@ ContextPopup { async = new Async.AsyncCall() if (piPopUp.choiceSet.count !== 0) { activate() + }else if (grammarID) { + vrActivate() } console.debug("exit") return async @@ -132,9 +137,21 @@ ContextPopup { console.debug("enter") timer.interval = timeout timer.start() + if (grammarID) { + vrPopUp.sortModelforPerformInteraction() + } show() console.debug("exit") } + function vrActivate () { + console.debug("enter") + timer.interval = timeout + timer.start() + vrPopUp.sortModelforPerformInteraction() + vrPopUp.show() + vrHelpPopup.show() + console.debug("exit") + } function complete (reason, data) { console.debug("enter") @@ -150,6 +167,7 @@ ContextPopup { break } timer.stop() + grammarID = "" hide() performInteractionIsActiveNow = false console.debug("exit") diff --git a/src/components/qt_hmi/qml_model_qt5/popups/TTSPopUp.qml b/src/components/qt_hmi/qml_model_qt5/popups/TTSPopUp.qml index 33f82013b2..d16015ec56 100644 --- a/src/components/qt_hmi/qml_model_qt5/popups/TTSPopUp.qml +++ b/src/components/qt_hmi/qml_model_qt5/popups/TTSPopUp.qml @@ -42,6 +42,7 @@ PopUp { width: Constants.ttsPopUpWidth padding: Constants.ttsPopUpPadding property var async + property string helpPromptstr ScrollView { anchors.fill: parent @@ -50,6 +51,7 @@ PopUp { anchors.fill: parent color: Constants.popUpBorderColor font.pixelSize: Constants.ttsFontSize + text:"" } } @@ -63,12 +65,16 @@ PopUp { Timer { id: ttsPerformInteractionTimer interval: Constants.ttsSpeakTime - onTriggered: activate(message) + onTriggered: + if(interactionPopup.performInteractionIsActiveNow) + activate(message) property var message: undefined } ] function performInteraction(helpPrompt, initialPrompt, timeoutPrompt, timeout) { + console.debug("Activate TTS popup:", "message"); + helpPromptstr = helpPrompt activate(initialPrompt); if (timeout * 2 - Constants.ttsSpeakTime > 0) { ttsPerformInteractionTimer.message = timeoutPrompt; diff --git a/src/components/qt_hmi/qml_model_qt5/popups/VRPopUp.qml b/src/components/qt_hmi/qml_model_qt5/popups/VRPopUp.qml index 2acf4f0651..ed33e5ca8d 100644 --- a/src/components/qt_hmi/qml_model_qt5/popups/VRPopUp.qml +++ b/src/components/qt_hmi/qml_model_qt5/popups/VRPopUp.qml @@ -57,22 +57,47 @@ PopUp { anchors.right: parent.right source: "../res/controlButtons/vrImage.png" } + OvalButton{ + id:helpButton + anchors.rightMargin: Constants.popupMargin + anchors.leftMargin: Constants.popupMargin + anchors.top: voice.bottom + anchors.left: parent.left + anchors.right: parent.right + text: "Help" + onClicked:{ + if (interactionPopup.performInteractionIsActiveNow) + ttsPopUp.activate(ttsPopUp.helpPromptstr) + if (dataContainer.activeVR) { + vrPopUp.complete(); + vrHelpPopup.hide() + } + } + } ScrollableListView { anchors.bottomMargin: Constants.popupMargin anchors.rightMargin: Constants.popupMargin anchors.leftMargin: Constants.popupMargin - anchors.top: voice.bottom + anchors.top: helpButton.bottom anchors.right: parent.right anchors.bottom: parent.bottom anchors.left: parent.left - model: dataContainer.vrCommands + model: if (interactionPopup.grammarID) { + dataContainer.choicesVrCommands + } + else { + dataContainer.vrCommands + } delegate: OvalButton { width: parent.width text: command + visible: visibleButtons(grammarID,type) onClicked: { + if (interactionPopup.performInteractionIsActiveNow && type === Common.VRCommandType.Choice) + interactionPopup.complete(Common.Result.SUCCESS, {"choiceID": cmdID}) sdlVR.onCommand(cmdID, appID === 0 ? undefined : appID); if (dataContainer.activeVR) { vrPopUp.complete(); @@ -93,4 +118,41 @@ PopUp { sdlVR.stopped(); hide(); } + + function sortModelforPerformInteraction() { + var n, + i, + j; + for (n = 0; n < dataContainer.choicesVrCommands.count; n++) { + for (i = n + 1; i < dataContainer.choicesVrCommands.count; i++) { + if (dataContainer.choicesVrCommands.get(n).type === Common.VRCommandType.Command && + dataContainer.choicesVrCommands.get(i).type === Common.VRCommandType.Choice) { + dataContainer.choicesVrCommands.move(i, n, 1); + n = 0; + } + } + } + for (j = interactionPopup.grammarID.length; j > 0; j--) { + for (n = 0; n < dataContainer.choicesVrCommands.count && + dataContainer.choicesVrCommands.get(n).type === Common.VRCommandType.Choice; n++) { + for (i = n + 1; i < dataContainer.choicesVrCommands.count && + dataContainer.choicesVrCommands.get(i).type === Common.VRCommandType.Choice; i++) { + if (dataContainer.choicesVrCommands.get(n).grammarID !== interactionPopup.grammarID[j-1] + && dataContainer.choicesVrCommands.get(i).grammarID === interactionPopup.grammarID[j-1]) { + dataContainer.choicesVrCommands.move(i, n, 1); + n = 0; + } + } + } + } + } + + function visibleButtons(grammarID, type) { + if (interactionPopup.grammarID) { + return interactionPopup.grammarID.indexOf(grammarID) !== -1 + } + else { + return type === Common.VRCommandType.Command + } + } } diff --git a/src/components/qt_hmi/qml_model_qt5/views/SDLPlayerOptionsListView.qml b/src/components/qt_hmi/qml_model_qt5/views/SDLPlayerOptionsListView.qml index 8f3a0a17b6..e249a5eb76 100644 --- a/src/components/qt_hmi/qml_model_qt5/views/SDLPlayerOptionsListView.qml +++ b/src/components/qt_hmi/qml_model_qt5/views/SDLPlayerOptionsListView.qml @@ -94,6 +94,7 @@ GeneralView { case Internal.MenuItemType.MI_NODE: sdlUI.onCommand(model.id, dataContainer.currentApplication.appId) contentLoader.back() + dataContainer.currentApplication.currentSubMenu = dataContainer.currentApplication.options break; case Internal.MenuItemType.MI_SUBMENU: case Internal.MenuItemType.MI_PARENT: diff --git a/src/components/qt_hmi/qml_model_qt5/views/ScrollableMessageView.qml b/src/components/qt_hmi/qml_model_qt5/views/ScrollableMessageView.qml index 895ebbf879..0dcb7a3b32 100644 --- a/src/components/qt_hmi/qml_model_qt5/views/ScrollableMessageView.qml +++ b/src/components/qt_hmi/qml_model_qt5/views/ScrollableMessageView.qml @@ -94,6 +94,10 @@ GeneralView { dataContainer.scrollableMessageModel.result = Common.Result.ABORTED contentLoader.back() } + onStealFocus: { + dataContainer.scrollableMessageModel.result = Common.Result.SUCCESS + contentLoader.back() + } } } } diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc index abfe712398..d026f4bbb5 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc @@ -1,4 +1,4 @@ -/** +/* * \file dbus_controller.cpp * \brief DbusController class. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h index 45b6a4e7fe..ecda598670 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h @@ -1,4 +1,4 @@ -/** +/* * \file dbus_controller.h * \brief DbusController class header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc index c264a42a8b..0f41a28e73 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc @@ -1,4 +1,4 @@ -/** +/* * \file dbus_plugin.cpp * \brief DbusPlugin class source file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h index 4d145d09b4..ef2a925956 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h @@ -1,4 +1,4 @@ -/** +/* * \file dbus_plugin.h * \brief DbusPlugin class header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc index bd9e6efea9..8b6cfd57d4 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc @@ -1,4 +1,4 @@ -/** +/* * \file hmiproxy.cpp * \brief HmiProxy class source file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h index 7fa0e49bf8..886d523157 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h @@ -1,4 +1,4 @@ -/** +/* * \file hmiproxy.h * \brief HmiProxy class header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h index 6f2b54fc57..5224da7f55 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2013, Ford Motor Company * All rights reserved. * diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h index 79dfdd1838..b9360c3eb4 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h @@ -1,4 +1,4 @@ -/** +/* * \file optional_argument.h * \brief OptionalArgument struct header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h index 6148da71f5..eb9b93929f 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h @@ -1,4 +1,4 @@ -/** +/* * \file qml_dbus_common.h * \brief Contain utilities for DBus plugin. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h index cbad38ed5e..4eff83bd5b 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h @@ -1,4 +1,4 @@ -/** +/* * @file qt_version.h * @brief Defines for check Qt version. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc index a1ae3402c4..b60f5226c4 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2013, Ford Motor Company * All rights reserved. * diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h index 675b6d069e..0d0e279b87 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2013, Ford Motor Company * All rights reserved. * diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.cc b/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.cc index 42e2e4f370..bcde90930f 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.cc +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.cc @@ -1,4 +1,4 @@ -/** +/* * \file attributed_mouse_event.cpp * \brief AttributedMouseEvent class source file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.h b/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.h index b058e28f28..2d2babc29f 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.h +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.h @@ -1,4 +1,4 @@ -/** +/* * \file attributed_mouse_event.h * \brief AttributedMouseEvent class header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.cc b/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.cc index 9f4f3b611c..bf63c12cb1 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.cc +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.cc @@ -1,4 +1,4 @@ -/** +/* * \file hmi_hwbuttons.cpp * \brief HmiHWButtons class source file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.h b/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.h index ee5fa53021..cf8f0b5f4b 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.h +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.h @@ -1,4 +1,4 @@ -/** +/* * \file hmi_hwbuttons.h * \brief HmiHWButtons class header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.cc b/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.cc index aee3afbbdf..0d144ff84c 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.cc +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.cc @@ -1,4 +1,4 @@ -/** +/* * \file masked_container.cpp * \brief MaskedContainer class source file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.h b/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.h index 30e145aa35..0048bdda2a 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.h +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.h @@ -1,4 +1,4 @@ -/** +/* * \file masked_container.h * \brief MaskedContainer class header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/qt_version.h b/src/components/qt_hmi/qml_plugins/hw_buttons/qt_version.h index 6a277e3867..fb2751504d 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/qt_version.h +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/qt_version.h @@ -1,4 +1,4 @@ -/** +/* * @file qt_version.h * @brief Defines for check Qt version. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.cc b/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.cc index 19eec36651..da863e2e26 100644 --- a/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.cc +++ b/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.cc @@ -1,4 +1,4 @@ -/** +/* * @file log4cxx_plugin.cpp * @brief Log4cxxPlugin class header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.h b/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.h index 00e136cf76..fc82352f0c 100644 --- a/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.h +++ b/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.h @@ -1,4 +1,4 @@ -/** +/* * @file log4cxx_plugin.h * @brief Log4cxxPlugin class header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.cc b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.cc index e231124fe8..f51db76b99 100644 --- a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.cc +++ b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.cc @@ -1,4 +1,4 @@ -/** +/* * @file named_pipe_notifier.cc * @brief NamedPipeNotifier class implementation file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.h b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.h index 14bacd9b6f..993bb3cb31 100644 --- a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.h +++ b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.h @@ -1,4 +1,4 @@ -/** +/* * \file named_pipe_notifier.h * \brief NamedPipeNotifier class header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.cc b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.cc index a423434c17..8aa2b4cf76 100644 --- a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.cc +++ b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.cc @@ -1,4 +1,4 @@ -/** +/* * \file named_pipe_notifier_plugin.cc * \brief NamedPipeNotifierPlugin class implementation file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.h b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.h index 36513aa931..6c64d531ac 100644 --- a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.h +++ b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.h @@ -1,4 +1,4 @@ -/** +/* * \file named_pipe_notifier_plugin.h * \brief NamedPipeNotifierPlugin class header file. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/qt_version.h b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/qt_version.h index 42b4bcb9d6..91533346c0 100644 --- a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/qt_version.h +++ b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/qt_version.h @@ -1,4 +1,4 @@ -/** +/* * @file qt_version.h * @brief Defines for check Qt version. * Copyright (c) 2013, Ford Motor Company diff --git a/src/components/qt_hmi/test/CMakeLists.txt b/src/components/qt_hmi/test/CMakeLists.txt new file mode 100644 index 0000000000..b0c48a4348 --- /dev/null +++ b/src/components/qt_hmi/test/CMakeLists.txt @@ -0,0 +1,70 @@ +# Copyright (c) 2014, Ford Motor Company +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with the +# distribution. +# +# Neither the name of the Ford Motor Company nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + + +if(BUILD_TESTS) + +cmake_minimum_required(VERSION 2.8.11) + +set(QT_HMI_TESTS_LIST + ${COMPONENTS_DIR}/qt_hmi/test/src/tst_AddCommand.qml + ${COMPONENTS_DIR}/qt_hmi/test/src/tst_AddSubMenu.qml + ${COMPONENTS_DIR}/qt_hmi/test/src/tst_DeleteCommand.qml + ${COMPONENTS_DIR}/qt_hmi/test/src/tst_ScrollableMessage.qml + ${COMPONENTS_DIR}/qt_hmi/test/src/tst_SetMediaClockTimer.qml + ${COMPONENTS_DIR}/qt_hmi/test/src/tst_Show.qml + ${COMPONENTS_DIR}/qt_hmi/test/src/tst_Slider.qml + ${COMPONENTS_DIR}/qt_hmi/test/readme.txt +) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) + +set(CONFIG + warn_on + qmltestcase +) + +set(SOURCES + qt_hmi_test.cc +) + +set(target qt_hmi_test) + +create_test("qt_hmi_test" "${SOURCES}" "") +qt5_use_modules(${target} Core Qml Quick QuickTest) + +foreach( file_i ${QT_HMI_TESTS_LIST}) + file(COPY ${file_i} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +endforeach( file_i ) + +endif()
\ No newline at end of file diff --git a/src/components/qt_hmi/test/qt_hmi_test.cc b/src/components/qt_hmi/test/qt_hmi_test.cc new file mode 100644 index 0000000000..0241549ca5 --- /dev/null +++ b/src/components/qt_hmi/test/qt_hmi_test.cc @@ -0,0 +1,33 @@ +/* + Copyright (c) 2014, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +#include <QtQuickTest/quicktest.h> +QUICK_TEST_MAIN(QtHMI) diff --git a/src/components/qt_hmi/test/readme.txt b/src/components/qt_hmi/test/readme.txt new file mode 100644 index 0000000000..e169a4eb87 --- /dev/null +++ b/src/components/qt_hmi/test/readme.txt @@ -0,0 +1,14 @@ +A few comments on test writting for QML Unit Testing + +- set TestCase inside Item - this allows to send Mouse and keyboard events to controls +- content of QML is reachable directly from tests. It is necessary to add getters into + source QML file to handle internal items +- test execution order is alfabetical. If you need manage this order use numbers in test function names +- all functions that starts with "test_" prefix is treated as test case +- all files that starts with "tst_" prefix will be executed as test set +- for async testing use timer +- each system's entity that changes during RPC must be tested +- test incoming arguments is not necessary as it will be verified by Qt abstraction layer +- run test with following command: + "./qt_hmi_test -import ../git push qml_model_qt5/" + diff --git a/src/components/qt_hmi/test/src/tst_AddCommand.qml b/src/components/qt_hmi/test/src/tst_AddCommand.qml new file mode 100644 index 0000000000..e71fb66b11 --- /dev/null +++ b/src/components/qt_hmi/test/src/tst_AddCommand.qml @@ -0,0 +1,320 @@ +/** + * @file tst_AddSubMenu.qml + * @brief Test Case for OptionsView. + * Copyright (c) 2014, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +import QtTest 1.0 +import QtQuick 2.0 +import QtMultimedia 5.0 +import com.ford.sdl.hmi.dbus_adapter 1.0 +import com.ford.sdl.hmi.hw_buttons 1.0 +import com.ford.sdl.hmi.log4cxx 1.0 +import "../qml_model_qt5/controls" +import "../qml_model_qt5/views" +import "../qml_model_qt5/hmi_api" as HmiApi +import "../qml_model_qt5/models" +import "../qml_model_qt5/popups" +import "../qml_model_qt5/hmi_api/Common.js" as Common +import "../qml_model_qt5/models/Constants.js" as Constants +import "../qml_model_qt5/models/Internal.js" as Internal + +Item { + width : mainWindowLoader.width + height: mainWindowLoader.height + + Loader { + id: mainWindowLoader + asynchronous : false + } + + TestCase { + name: "AddCommand" + when: windowShown + property var dataContainer + property var sdlUIProxy + property var contentLoader + property var messageModel + + function createView(appID) { + mainWindowLoader.source = "../qml_model_qt5/MainWindow.qml" + var mainWindowObject = mainWindowLoader.item + sdlUIProxy = mainWindowObject.getUIProxy() + dataContainer = mainWindowObject.getDataStorage() + dataContainer.addApplication({appName:"TestAppName", appId:appID}) + } + + function destroyView() { + mainWindowLoader.source = "" + } + + /* + * Test Cases + */ + + function test_01_addCommand_Command_Positive() { + console.debug("enter") + + var initData = { + cmdID: 1, + cmdIcon: { + value: "123.jpg", + imageType: "DYNAMIC" + }, + menuParams: { + position: 500, + menuName: "Command positive" + }, + appID: 1 + } + + createView(initData.appID) + sdlUIProxy.addCommand(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.get(0).id, initData.cmdID, "Command id") + compare(app.options.get(0).position, initData.menuParams.position, "Command position") + compare(app.options.get(0).name, initData.menuParams.menuName, "Command name") + compare(app.options.get(0).icon.value, initData.cmdIcon.value, "Image path") + + destroyView() + console.debug("exit") + } + + function test_02_addCommand_Without_Position() { + console.debug("enter") + var initData = { + appID: 1, + Commands: [] + } + initData.Commands.push({ + cmdID:1, + comIcon: { + value: "123.jpg", + imageType: "DYNAMIC" + }, + menuParams: { + menuName: "Command 1" + }, + appID: 1 + }) + initData.Commands.push({ + cmdID:2, + cmdIcon: { + value: "345.jpg", + imageType: "DYNAMIC" + }, + menuParams: { + position: 500, + menuName: "Command 1" + }, + appID: 1 + }) + createView(initData.appID) + sdlUIProxy.addCommand(initData.Commands[0]) + sdlUIProxy.addCommand(initData.Commands[1]) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.get(1).id, initData.Commands[0].cmdID, "Command id") + compare(app.options.get(1).name, initData.Commands[0].menuParams.menuName, "Command name") + compare(app.options.get(0).id, initData.Commands[1].cmdID, "Command id") + compare(app.options.get(0).name, initData.Commands[1].menuParams.menuName, "Command name") + + destroyView() + console.debug("exit") + } + + function test_03_1010_addCommands() { + console.debug("enter") + var initData = { + appID: 1, + Commands: [] + } + + for (var i = 0; i < 1010; i++) { + initData.Commands.push({ + cmdID: i, + cmdIcon: { + value: "", + imageType: "" + }, + menuParams: { + position: i, + menuName: "Command " + i + }, + appID: 1 + }) + } + + createView(initData.appID) + for (var i = 0; i < initData.Commands.length; i++) { + sdlUIProxy.addCommand(initData.Commands[i]) + } + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.count, 1000, "Command count") + + for (var i = 0; i < 1000; i++) { + compare(app.options.get(i).id, initData.Commands[i].cmdID, "Command id") + compare(app.options.get(i).position, initData.Commands[i].menuParams.position, "Command position") + compare(app.options.get(i).name, initData.Commands[i].menuParams.menuName, "Command name") + } + + destroyView() + console.debug("exit") + } + + function test_04_Command_Upper_Bound() { + console.debug("enter") + var initData = { + cmdID: 2000000000, + cmdIcon: { + value: "00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890aAaaaaaaaaaaaaaa", + imageType: "" + }, + menuParams: { + position: 100000, + menuName: "00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890aAaaaaaaaaaaaaaa" + }, + appID: 1 + } + + createView(initData.appID) + sdlUIProxy.addCommand(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.get(0).id, initData.cmdID, "Command id") + compare(app.options.get(0).position, initData.menuParams.position, "Command position") + compare(app.options.get(0).name.length, initData.menuParams.menuName.length, "Command name") + compare(app.options.get(0).icon.value.length, initData.cmdIcon.value.length, "Image path") + + destroyView() + console.debug("exit") + } + + function test_05_addCommand_Lower_Bound() { + console.debug("enter") + var initData = { + cmdID: 0, + cmdIcon: { + value: "", + imageType: "" + }, + menuParams: { + position: 0, + menuName: "0", + parentID: 0 + }, + appID: 0 + } + + createView(initData.appID) + sdlUIProxy.addCommand(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.get(0).id, initData.cmdID, "Command id") + compare(app.options.get(0).position, initData.menuParams.position, "Command position") + compare(app.options.get(0).name, initData.menuParams.menuName, "Command name") + compare(app.options.get(0).icon.value, initData.cmdIcon.value, "Image path") + + destroyView() + console.debug("exit") + } + + function test_06_addCommand_With_Fake_Parameter() { + console.debug("enter") + var initData = { + cmdID: 1, + cmdIcon: { + value: "345.jpg", + imageType: "DYNAMIC" + }, + menuParams: { + menuName: "Command fake param", + position: 1, + fakeParam: "fakeParam" + }, + appID: 1 + } + + createView(initData.appID) + sdlUIProxy.addCommand(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.get(0).id, initData.cmdID, "Command id") + compare(app.options.get(0).position, initData.menuParams.position, "Command position") + compare(app.options.get(0).name, initData.menuParams.menuName, "Command name") + compare(app.options.get(0).icon.value, initData.cmdIcon.value, "Image path") + + destroyView() + console.debug("exit") + } + + function test_07_addCommand_No_Menu_Params() { + console.debug("enter") + + var initData = { + appID: 1, + Commands:[] + } + + var n = 10; + initData.Commands.push({ + cmdID: 123, + menuParams: {}, + appID: 1 + }) + for (var i = 0; i < n; i++) { + initData.Commands.push({ + cmdID: i, + menuParams: { + position: i, + menuName: "Command " + i + }, + appID: 1 + }) + } + + createView(initData.appID) + for (var i = 0; i < initData.Commands.length; i++) { + sdlUIProxy.addCommand(initData.Commands[i]) + } + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.count, initData.Commands.length, "Command count") + compare(app.options.get(n).id, initData.Commands[0].cmdID, "Command 11 id") + compare(app.options.get(0).id, initData.Commands[1].cmdID, "Command 12 id") + + destroyView() + console.debug("exit") + } + } +} diff --git a/src/components/qt_hmi/test/src/tst_AddSubMenu.qml b/src/components/qt_hmi/test/src/tst_AddSubMenu.qml new file mode 100644 index 0000000000..7f9477cab1 --- /dev/null +++ b/src/components/qt_hmi/test/src/tst_AddSubMenu.qml @@ -0,0 +1,328 @@ +/** + * @file tst_AddSubMenu.qml + * @brief Test Case for OptionsView. + * Copyright (c) 2014, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + +import QtTest 1.0 +import QtQuick 2.0 +import QtMultimedia 5.0 +import com.ford.sdl.hmi.dbus_adapter 1.0 +import com.ford.sdl.hmi.hw_buttons 1.0 +import com.ford.sdl.hmi.log4cxx 1.0 +import "../qml_model_qt5/controls" +import "../qml_model_qt5/views" +import "../qml_model_qt5/hmi_api" as HmiApi +import "../qml_model_qt5/models" +import "../qml_model_qt5/popups" +import "../qml_model_qt5/hmi_api/Common.js" as Common +import "../qml_model_qt5/models/Constants.js" as Constants +import "../qml_model_qt5/models/Internal.js" as Internal + +Item { + width : mainWindowLoader.width + height: mainWindowLoader.height + + Loader { + id: mainWindowLoader + asynchronous : false + } + + TestCase { + name: "AddSubMenu" + when: windowShown + property var dataContainer + property var sdlUIProxy + property var contentLoader + property var messageModel + + //initialization for each test + function createMessageView(appID) { + mainWindowLoader.source = "" + mainWindowLoader.source = "../qml_model_qt5/MainWindow.qml" + var mainWindowObject = mainWindowLoader.item + if(!mainWindowObject) + qtest_fail("mainWindowObject is undefined"); + var mainScreen = mainWindowObject.getMainScreen() + mainScreen.visible = true + var warningInfo = mainWindowObject.getWarningInfo() + warningInfo.visible = false + contentLoader = mainWindowObject.getContentLoader() + contentLoader.asynchronous = false + sdlUIProxy = mainWindowObject.getUIProxy() + dataContainer = mainWindowObject.getDataStorage() + dataContainer.addApplication({appName:"TestAppName", appId:appID}) + } + + //cleanup for each test + function destroyView() { + //Clear Loader with MainWindow, which delete own models and views + mainWindowLoader.source = "" + } + + /* + * Test Cases + */ + + //Positive case and in boundary conditions + function test_01_addSubMenu() { + console.debug("enter") + var initData = { + menuID: 1000, + menuParams: { + position: 500, + menuName: "SubMenu positive" + }, + appID: 1 + } + + createMessageView(initData.appID) + sdlUIProxy.addSubMenu(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.get(0).id, initData.menuID, "SubMenu id") + compare(app.options.get(0).position, initData.menuParams.position, "SubMenu position") + compare(app.options.get(0).name, initData.menuParams.menuName, "SubMenu name") + + destroyView() + console.debug("exit") + } + + // Only mandatory - without Position + function test_02_addSubMenu_WithoutPosition() { + console.debug("enter") + var initData = { + menuID: 1001, + menuParams: { + menuName: "SubMenu mandatory only" + }, + appID: 1 + } + + createMessageView(initData.appID) + sdlUIProxy.addSubMenu(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.get(0).id, initData.menuID, "SubMenu id") + //How to verify if value was not set? + //compare(app.options.get(0).position, initData.menuParams.position, "SubMenu position") + compare(app.options.get(0).name, initData.menuParams.menuName, "SubMenu name") + + destroyView() + console.debug("exit") + } + + //Create AddSubMenu and check data + function test_03_1000_SubMenu() { + console.debug("enter") + var initData = { + appID: 1, + subMenus: [] + } + + for (var i = 0; i < 1010; i++) { + + initData.subMenus.push({ + menuID: i, + menuParams: { + position: i, + menuName: "Submenu" + i + }, + appID: 1 + }) + } + + createMessageView(initData.appID) + for (var i = 0; i < initData.subMenus.length; i++) { + sdlUIProxy.addSubMenu(initData.subMenus[i]) + } + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.count, 1000, "SubMenus count") + + for (var i = 0; i < 1000; i++) { + compare(app.options.get(i).id, initData.subMenus[i].menuID, "SubMenu id") + compare(app.options.get(i).position, initData.subMenus[i].menuParams.position, "SubMenu position") + compare(app.options.get(i).name, initData.subMenus[i].menuParams.menuName, "SubMenu name") + } + + destroyView() + console.debug("exit") + } + + //Create AddSubMenu and check data + function test_04_addSubMenu_UpperBound() { + console.debug("enter") + var initData = { + menuID: 2000000000, + menuParams: { + position: 1000, + menuName: "00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012å/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890aAaaaaaaaaaaaaaa" + }, + appID: 1 + } + + createMessageView(initData.appID) + sdlUIProxy.addSubMenu(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.get(0).id, initData.menuID, "SubMenu id") + compare(app.options.get(0).position, initData.menuParams.position, "SubMenu position") + compare(app.options.get(0).name.length, 500, "SubMenu name") + + destroyView() + console.debug("exit") + } + + //Create AddSubMenu and check data + function test_05_addSubMenu_LowerBound() { + console.debug("enter") + var initData = { + menuID: 0, + menuParams: { + position: 0, + menuName: "0" + }, + appID: 1 + } + + createMessageView(initData.appID) + sdlUIProxy.addSubMenu(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.get(0).id, initData.menuID, "SubMenu id") + compare(app.options.get(0).position, initData.menuParams.position, "SubMenu position") + compare(app.options.get(0).name.length, 1, "SubMenu name") + + destroyView() + console.debug("exit") + } + + // With fake parameter + function test_06_addSubMenu_With_Fake_Parameter() { + console.debug("enter") + var initData = { + menuID: 1001, + menuParams: { + menuName: "SubMenu fake param", + position: 1, + fakeParam: "fakeParam" + }, + appID: 1 + } + + createMessageView(initData.appID) + sdlUIProxy.addSubMenu(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.get(0).id, initData.menuID, "SubMenu id") + compare(app.options.get(0).position, initData.menuParams.position, "SubMenu position") + compare(app.options.get(0).name, initData.menuParams.menuName, "SubMenu name") + + destroyView() + console.debug("exit") + } + + // With fake parameter + function test_07_addSubMenu_menuIDOutLowerBound() { + console.debug("enter") + var initData = { + menuID: -1, + menuParams: { + menuName: "100", + position: 1, + }, + appID: 1 + } + + createMessageView(initData.appID) + sdlUIProxy.addSubMenu(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.count, 0, "SubMenus count") + + compare(app.options.get(1), !undefined, "SubMenu duplicated") + + destroyView() + console.debug("exit") + } + + // With fake parameter + function test_08_addSubMenu_menuIDOutUpperBound() { + console.debug("enter") + var initData = { + menuID: 2000000001, + menuParams: { + menuName: "100", + position: 1, + }, + appID: 1 + } + + createMessageView(initData.appID) + sdlUIProxy.addSubMenu(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.count, 0, "SubMenus count") + + compare(app.options.get(1), !undefined, "SubMenu duplicated") + + destroyView() + console.debug("exit") + } + + // With fake parameter + function test_09_addSubMenu_duplicatedSubMenus() { + console.debug("enter") + var initData = { + menuID: 2000000001, + menuParams: { + menuName: "100", + position: 1, + }, + appID: 1 + } + + createMessageView(initData.appID) + sdlUIProxy.addSubMenu(initData) + sdlUIProxy.addSubMenu(initData) + var app = dataContainer.getApplication(initData.appID) + + compare(app.options.count, 1, "SubMenus count") + + compare(app.options.get(1), undefined, "SubMenu duplicated") + + destroyView() + console.debug("exit") + } + } +} diff --git a/src/components/qt_hmi/test/src/tst_DeleteCommand.qml b/src/components/qt_hmi/test/src/tst_DeleteCommand.qml new file mode 100644 index 0000000000..bf28be0282 --- /dev/null +++ b/src/components/qt_hmi/test/src/tst_DeleteCommand.qml @@ -0,0 +1,210 @@ +/** + * @file tst_ScrollableMessage.qml + * @brief Test Case for ScrollableMessageView. + * Copyright (c) 2014, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +import QtTest 1.0 +import QtQuick 2.0 +import QtMultimedia 5.0 +import com.ford.sdl.hmi.dbus_adapter 1.0 +import com.ford.sdl.hmi.hw_buttons 1.0 +import com.ford.sdl.hmi.log4cxx 1.0 +import "../qml_model_qt5/controls" +import "../qml_model_qt5/views" +import "../qml_model_qt5/hmi_api" as HmiApi +import "../qml_model_qt5/models" +import "../qml_model_qt5/popups" +import "../qml_model_qt5/hmi_api/Common.js" as Common +import "../qml_model_qt5/models/Constants.js" as Constants +import "../qml_model_qt5/models/Internal.js" as Internal + +Item +{ + width : mainWindowLoader.width + height: mainWindowLoader.height + + Loader + { + id: mainWindowLoader + asynchronous : false + } + + TestCase + { + name: "DeleteCommand" + when: windowShown + property var dataContainer + property var sdlUIProxy + property var contentLoader + property var messageModel + + + //initialization for each test + function createMessageView(appID) + { + mainWindowLoader.source = "" + mainWindowLoader.source = "../qml_model_qt5/MainWindow.qml" + var mainWindowObject = mainWindowLoader.item + if(!mainWindowObject) + qtest_fail("mainWindowObject is undefined"); + var mainScreen = mainWindowObject.getMainScreen() + mainScreen.visible = true + var warningInfo = mainWindowObject.getWarningInfo() + warningInfo.visible = false + contentLoader = mainWindowObject.getContentLoader() + contentLoader.asynchronous = false + sdlUIProxy = mainWindowObject.getUIProxy() + dataContainer = mainWindowObject.getDataStorage() + dataContainer.addApplication({appName:"TestAppName", appId:appID}) + } + + //cleanup for each test + function destroyView() + { + //Clear Loader with MainWindow, which delete own models and views + mainWindowLoader.source = "" + } + + /* + * Test Cases + */ + + function test_01_deleteCommand() + { + console.debug("enter") + var initData = { + cmdID: 1, + menuParams: + { + menuName:"", + }, + cmdIcon:"", + appID: 1 + } + var initData2 = { + cmdID: 2, + menuParams: + { + menuName:"", + }, + cmdIcon:"", + appID: 1 + } + + createMessageView(initData.appID) + var app = dataContainer.getApplication(initData.appID) + var MenuCount = app.options.count + app.options.append( + { id: initData.cmdID, + name: initData.menuParams.menuName, + type: Internal.MenuItemType.MI_NODE, + position: Constants.positionOfElementWithoutPosition, + icon: initData.cmdIcon ? cmdIcon : {}, + subMenu: [] + } + ) + + compare(app.options.count, MenuCount+1, "Command into menu not added") + sdlUIProxy.deleteCommand(initData2) + + var a = 0 + for(var i = 0;((a === 0) && ( i < app.options.count)); i++) + { + if (app.options.get(i).id===initData2.menuID) + { + a = 1 + } + } + compare (a, 0, "Command in menu isn't removed") + + + destroyView() + console.debug("exit") + } + + function test_02_deleteCommand() { + console.debug("enter") + var initData = { + menuID: 1000, + menuParams: { + position: 1, + menuName: "SubMenu" + }, + appID: 1 + } + + var initData2 = { + cmdID: 1, + menuParams: { + menuName:"", + }, + cmdIcon:"", + appID: 1 + } + + createMessageView(initData.appID) + var app = dataContainer.getApplication(initData.appID) + var MenuCount = app.options.count + app.options.append ({ + "id": initData.menuID, + "name": initData.menuParams.menuName, + "position": initData.menuParams.position, + "type": Internal.MenuItemType.MI_SUBMENU, + "icon": undefined, + "subMenu":[{ + "id":initData2.cmdID, + "name": initData2.menuParams.menuName, + "position": Constants.positionOfElementWithoutPosition, + "type": Internal.MenuItemType.MI_PARENT, + "icon": { + "imageType": Common.ImageType.DYNAMIC, + "value": "../res/nav/turnArrow.png" + }, + + "subMenu": [] + }] + }) + + compare(app.options.count, MenuCount+1, "SubMenu into added") + var SubMenuCount = app.options.get(0).subMenu.count + compare( SubMenuCount, 1, "Command is not added into SubMenu") + + sdlUIProxy.deleteCommand(initData2) + + compare(app.options.count , MenuCount+1, "Menu is changed") + compare(app.options.get(0).subMenu.count, SubMenuCount-1, "Command into SubMenu is not removed") + + destroyView() + console.debug("exit") + } + } +} diff --git a/src/components/qt_hmi/test/src/tst_ScrollableMessage.qml b/src/components/qt_hmi/test/src/tst_ScrollableMessage.qml new file mode 100644 index 0000000000..abf3105b1a --- /dev/null +++ b/src/components/qt_hmi/test/src/tst_ScrollableMessage.qml @@ -0,0 +1,421 @@ +/** + * @file tst_ScrollableMessage.qml + * @brief Test Case for ScrollableMessageView. + * Copyright (c) 2014, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + +import QtTest 1.0 +import QtQuick 2.0 +import QtMultimedia 5.0 +import com.ford.sdl.hmi.dbus_adapter 1.0 +import com.ford.sdl.hmi.hw_buttons 1.0 +import com.ford.sdl.hmi.log4cxx 1.0 +import "../qml_model_qt5/controls" +import "../qml_model_qt5/views" +import "../qml_model_qt5/hmi_api" as HmiApi +import "../qml_model_qt5/models" +import "../qml_model_qt5/popups" +import "../qml_model_qt5/hmi_api/Common.js" as Common +import "../qml_model_qt5/models/Constants.js" as Constants +import "../qml_model_qt5/models/Internal.js" as Internal + +Item { + width : mainWindowLoader.width + height: mainWindowLoader.height + + Loader { + id: mainWindowLoader + asynchronous : false + } + + TestCase { + name: "ScrollableMessageView" + when: windowShown + property var dataContainer + property var sdlUIProxy + property var contentLoader + property var messageModel + property var messageView + property var timer + + property var softButtonsListExample : [ + {softButtonID:0, isHighlighted:true, systemAction:Common.SystemAction.DEFAULT_ACTION, + type:Common.SoftButtonType.SBT_TEXT, text:"Default Action"}, + {softButtonID:1, isHighlighted:false, systemAction:Common.SystemAction.STEAL_FOCUS, + type:Common.SoftButtonType.SBT_IMAGE, text:"Steal Focus"}, + {softButtonID:2, isHighlighted:false, systemAction:Common.SystemAction.KEEP_CONTEXT, + type:Common.SoftButtonType.SBT_BOTH, text:"Keep context"}] + + //initialization for each test + function createMessageView(appID) { + mainWindowLoader.source = "" + mainWindowLoader.source = "../qml_model_qt5/MainWindow.qml" + var mainWindowObject = mainWindowLoader.item + if(!mainWindowObject) + qtest_fail("mainWindowObject is undefined"); + var mainScreen = mainWindowObject.getMainScreen() + mainScreen.visible = true + var warningInfo = mainWindowObject.getWarningInfo() + warningInfo.visible = false + contentLoader = mainWindowObject.getContentLoader() + contentLoader.asynchronous = false + sdlUIProxy = mainWindowObject.getUIProxy() + dataContainer = mainWindowObject.getDataStorage() + dataContainer.addApplication({appName:"TestAppName", appId:appID}) + } + + //get messageModel and messageView after call @scrollableMessage + function getMessageViewModel() { + messageModel = dataContainer.scrollableMessageModel + if(!messageModel) + qtest_fail("messageModel is undefined"); + messageView = contentLoader.item + if(!messageView) + qtest_fail("messageView is undefined"); + } + + //cleanup for each test + function destroyView() { + //Clear Loader with MainWindow, which delete own models and views + mainWindowLoader.source = "" + } + + //return button from messageView by ommon.SystemAction + function findButtonByAction(systemAction){ + var listViewItems = messageView.getSoftButtonsListView() + for (var i = 0, len = listViewItems.count; i < len; i++) { + //get SoftButton by setting current item (ListView has no getter) + listViewItems.currentIndex = i + var buttonItem = listViewItems.currentItem + if (buttonItem.button.systemAction === systemAction) { + return buttonItem + } + } + } + + /* + * Test Cases + */ + + //Create ScrollableMessageView and check data + function test_01_create() { + console.debug("enter") + var initData = {appID:1, timeout:2000, + messageText:{fieldText:"Simple ScrollableMessage text"}, + softButtons:softButtonsListExample} + createMessageView(initData.appID) + + var result = sdlUIProxy.scrollableMessage(initData) + getMessageViewModel() + + verify(result.__errno === undefined, "ScrollableMessage return error state") + timer = messageView.getTimer() + if(!timer) + qtest_fail("timer is undefined"); + //check button equals to init data + compare(messageModel.softButtons.count, initData.softButtons.length, "wrong buttons count created") + for (var i = 0, len = messageModel.softButtons.count; i < len; i++) { + var act = messageModel.softButtons.get(i) + var exp = initData.softButtons[i] + compare(act.softButtonID, exp.softButtonID, "wrong softButtonID in button") + compare(act.isHighlighted, exp.isHighlighted, "wrong isHighlighted in button") + compare(act.systemAction, exp.systemAction, "wrong systemAction in button") + compare(act.text, exp.text, "wrong text in button") + } + //check model data equals to init data + compare(messageModel.running, true, "ScrollableMessage didn't start") + compare(messageModel.longMessageText, initData.messageText.fieldText, "wrong messageText") + compare(messageModel.appId, initData.appID, "wrong application ID") + compare(messageModel.timeout, initData.timeout, "wrong timeout") + verify(messageModel.async !== undefined, "async in undefined") + destroyView() + console.debug("exit") + } + + //Create ScrollableMessageView with empty data + function test_02_emptyInit() { + console.debug("enter") + var initData = {appID:1, timeout:0, messageText:{fieldText:""}, softButtons:[]} + createMessageView(initData.appID) + + var result = sdlUIProxy.scrollableMessage(initData) + getMessageViewModel() + + verify(result.__errno === undefined, "ScrollableMessage return error state") + //NOTE: don't check timer - it has been triggered immediately (timeout is 0) + //MessageView call @complete immediately + compare(messageModel.running, false, "ScrollableMessage didn't stop") + compare(messageModel.softButtons.count, initData.softButtons.length, "wrong buttons count") + compare(messageModel.longMessageText, initData.messageText.fieldText, "wrong messageText") + compare(messageModel.timeout, initData.timeout, "wrong timeout") + destroyView() + console.debug("exit") + } + + //call @scrollableMessage twice (after first view has closed) + function test_03_doubleCreate() { + console.debug("enter") + var initData = {appID:1, timeout:0, messageText:{fieldText:"Simple text"}, + softButtons:softButtonsListExample} + var initData2 = {appID:1, timeout:10000, messageText:{fieldText:"Simple text 2"}, + softButtons:[]} + createMessageView(initData.appID) + + //create view + var actualResult = sdlUIProxy.scrollableMessage(initData) + getMessageViewModel() + + //create new view + var actualResult2 = sdlUIProxy.scrollableMessage(initData2) + getMessageViewModel() + + verify(actualResult.__errno === undefined, "ScrollableMessage return error state") + verify(actualResult2.__errno === undefined, "ScrollableMessage return error state") + compare(messageModel.running, true, "ScrollableMessage didn't start") + compare(messageModel.longMessageText, initData2.messageText.fieldText, "wrong messageText") + compare(messageModel.timeout, initData2.timeout, "wrong timeout") + compare(messageModel.appId, initData2.appID, "wrong application ID") + verify(messageModel.async !== undefined, "async in undefined") + destroyView() + console.debug("exit") + } + + //call @scrollableMessage twice (before first view is closed) + function test_04_doubleCreateError() { + console.debug("enter") + var initData = {appID:1, timeout:20000, messageText:{fieldText:"Simple text"}, + softButtons:softButtonsListExample} + var initData2 = {appID:1, timeout:10000, messageText:{fieldText:"Simple text 2"}, + softButtons:[]} + createMessageView(initData.appID) + + //create view + var actualResult = sdlUIProxy.scrollableMessage(initData) + getMessageViewModel() + var firstView = messageView; + + //create new view + var actualResult2 = sdlUIProxy.scrollableMessage(initData2) + getMessageViewModel() + verify(actualResult.__errno === undefined, "ScrollableMessage return error state") + verify(actualResult2.__errno !== undefined, "ScrollableMessage don't return error state") + compare(messageModel.running, true, "ScrollableMessage didn't start") + compare(messageView, firstView, "creating new view insteed stay first") + compare(messageModel.longMessageText, initData.messageText.fieldText, "wrong messageText") + compare(messageModel.timeout, initData.timeout, "wrong timeout") + compare(messageModel.appId, initData.appID, "wrong application ID") + verify(messageModel.async !== undefined, "async in undefined") + destroyView() + console.debug("exit") + } + + //call @scrollableMessage and check close + function test_05_ClickBackButton() { + console.debug("enter") + var initData = {appID:1, timeout:20000, + messageText:{fieldText:"Simple ScrollableMessage text"}, + softButtons:softButtonsListExample} + createMessageView(initData.appID) + + var result = sdlUIProxy.scrollableMessage(initData) + getMessageViewModel() + + compare(messageModel.running, true, "ScrollableMessage didn't start") + verify(result.__errno === undefined, "ScrollableMessage return error state") + //look for back button + var backButton = messageView.getBackButton() + verify(backButton !== undefined, "Not created back button") + //wait rendering for correct click position + waitForRendering(mainWindowLoader) + //Press back button + mouseClick(backButton, backButton.width/2, backButton.height/2, + Qt.LeftButton, Qt.NoModifier, 0) + //check that MessageView (in contentLoader) is unloaded and deleted + var isLoaded = (contentLoader.source.toString().indexOf("ScrollableMessageView.qml") > 0) + verify(!isLoaded, "MessageView should be unloaded") + //wait for delete messageView by GC + wait(0); + verify(messageView === null, "MessageView should be deleted") + destroyView() + console.debug("exit") + } + //call @scrollableMessage and check close + function test_06_ClickDefaultAction() { + console.debug("enter") + var initData = {appID:1, timeout:20000, + messageText:{fieldText:"Simple ScrollableMessage text"}, + softButtons:softButtonsListExample} + createMessageView(initData.appID) + + var result = sdlUIProxy.scrollableMessage(initData) + getMessageViewModel() + + compare(messageModel.running, true, "ScrollableMessage didn't start") + verify(result.__errno === undefined, "ScrollableMessage return error state") + //look for DEFAULT_ACTION button + var defaultActionButton = findButtonByAction(Common.SystemAction.DEFAULT_ACTION) + verify(defaultActionButton !== undefined, "Not created button with DEFAULT_ACTION") + //wait rendering for correct click position + waitForRendering(mainWindowLoader) + //Press default button + mouseClick(defaultActionButton, defaultActionButton.width/2, defaultActionButton.height/2, + Qt.LeftButton, Qt.NoModifier, 0) + //check that MessageView (in contentLoader) is unloaded and deleted + var isLoaded = (contentLoader.source.toString().indexOf("ScrollableMessageView.qml") > 0) + verify(!isLoaded, "MessageView should be unloaded") + //wait for delete messageView by GC + wait(0); + verify(messageView === null, "MessageView should be deleted") + destroyView() + console.debug("exit") + } + + //call @scrollableMessage and check restart timer + function test_07_ClickStealFocus() { + console.debug("enter") + var initData = {appID:1, timeout:20000, messageText:{fieldText:"Simple ScrollableMessage text"}, + softButtons:softButtonsListExample} + createMessageView(initData.appID) + + var result = sdlUIProxy.scrollableMessage(initData) + getMessageViewModel() + + //check + compare(messageModel.running, true, "ScrollableMessage didn't start") + verify(result.__errno === undefined, "ScrollableMessage return error state") + //look for STEAL_FOCUS button + var stealFocusButton = findButtonByAction(Common.SystemAction.STEAL_FOCUS) + verify(stealFocusButton !== undefined, "Not created button with STEAL_FOCUS") + //wait rendering for correct buttons size for correct click position + waitForRendering(mainWindowLoader) + mouseClick(stealFocusButton, stealFocusButton.width/2, stealFocusButton.height/2, + Qt.LeftButton, Qt.NoModifier, 0) + //check that MediaView loaded in loade + var viewQMlFileName = dataContainer.currentApplication.isMediaApplication ? + "SDLPlayerView.qml" : "SDLNonMediaView.qml" + var isLoaded = (contentLoader.source.toString().indexOf(viewQMlFileName) > 0) + verify(isLoaded, "SDLPlayerView/SDLNonMediaView should be loaded") + destroyView() + console.debug("exit") + } + + //call @scrollableMessage and check restart timer + function test_08_ClickKeepContex() { + console.debug("enter") + var initData = {appID:1, timeout:20000, messageText:{fieldText:"Simple ScrollableMessage text"}, + softButtons:softButtonsListExample} + createMessageView(initData.appID) + + var result = sdlUIProxy.scrollableMessage(initData) + getMessageViewModel() + + //check + compare(messageModel.running, true, "ScrollableMessage didn't start") + verify(result.__errno === undefined, "ScrollableMessage return error state") + //look for KEEP_CONTEXT button + var keepContexButton = findButtonByAction(Common.SystemAction.KEEP_CONTEXT) + verify(keepContexButton !== undefined, "Not created button with KEEP_CONTEXT") + //wait rendering for correct click position + waitForRendering(mainWindowLoader) + //Press button + mouseClick(keepContexButton, keepContexButton.width/2, keepContexButton.height/2, + Qt.LeftButton, Qt.NoModifier, 0) + //check that MessageView is still unloaded loaded + var isLoaded = (contentLoader.source.toString().indexOf("ScrollableMessageView.qml") > 0) + verify(isLoaded, "MessageView should be loaded") + //verify restarted timer + timer = messageView.getTimer() + verify(timer.running === true, "Timer is not restarted by KEEP_CONTEXT button") + destroyView() + console.debug("exit") + } + + //add long text to model and check scrollBar visibility + function test_09_ScrollBarShown() { + console.debug("enter") + //generate string with (10!) lines + var longText = "It is very long text!\n" + for(var i = 1; i < 10; ++i) + longText += longText + var initData = {appID:1, timeout:20000, messageText:{fieldText:longText}, softButtons:[]} + createMessageView(initData.appID) + + var result = sdlUIProxy.scrollableMessage(initData) + getMessageViewModel() + + //check + compare(messageModel.running, true, "ScrollableMessage didn't start") + verify(result.__errno === undefined, "ScrollableMessage return error state") + + //wait rendering + waitForRendering(mainWindowLoader) + var scrollBar = messageView.getScrollbar() + verify(scrollBar.visible === true, "ScrollBar is not shown for long text") + + destroyView() + console.debug("exit") + } + + //compare text width with and without buttons at top of SrollableMessage + function test_10_MessageTextHeight() { + console.debug("enter") + var initData = {appID:1, timeout:500, messageText:{fieldText:"Simple text"}, softButtons:[]} + createMessageView(initData.appID) + + var result = sdlUIProxy.scrollableMessage(initData) + getMessageViewModel() + + //check + compare(messageModel.running, true, "ScrollableMessage didn't start") + verify(result.__errno === undefined, "ScrollableMessage return error state") + + var textAreaHeight = messageView.getTextArea().height + wait(initData.timeout) + + var initData2 = {appID:1, timeout:20000, messageText:{fieldText:"Simple text"}, + softButtons:softButtonsListExample} + createMessageView(initData.appID) + + var result2 = sdlUIProxy.scrollableMessage(initData2) + getMessageViewModel() + + //wait rendering + waitForRendering(mainWindowLoader) + var textAreaHeight2 = messageView.getTextArea().height + console.debug("messageTextH", textAreaHeight, textAreaHeight2) + verify(textAreaHeight2 <= textAreaHeight, "Height of text area shoud be less with buttons") + + destroyView() + console.debug("exit") + } + } +} diff --git a/src/components/qt_hmi/test/src/tst_SetMediaClockTimer.qml b/src/components/qt_hmi/test/src/tst_SetMediaClockTimer.qml new file mode 100644 index 0000000000..212cdfc143 --- /dev/null +++ b/src/components/qt_hmi/test/src/tst_SetMediaClockTimer.qml @@ -0,0 +1,292 @@ +/** + * @file tst_Slider.qml + * @brief Test Case for Slider. + * Copyright (c) 2013, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +import QtTest 1.0 +import QtQuick 2.0 +import QtMultimedia 5.0 +import com.ford.sdl.hmi.dbus_adapter 1.0 +import com.ford.sdl.hmi.hw_buttons 1.0 +import com.ford.sdl.hmi.log4cxx 1.0 +import "../qml_model_qt5/controls" +import "../qml_model_qt5/views" +import "../qml_model_qt5/hmi_api" as HmiApi +import "../qml_model_qt5/models" +import "../qml_model_qt5/popups" +import "../qml_model_qt5/hmi_api/Common.js" as Common +import "../qml_model_qt5/models/Constants.js" as Constants +import "../qml_model_qt5/models/Internal.js" as Internal + +Item { + id:item123 + TestCase { + name: "time" + property var mainWindowComponent : Qt.createComponent("../qml_model_qt5/MainWindow.qml") + property var mainObject + property var sdlUI + property var dataContainer + + function createTime() { + mainObject = mainWindowComponent.createObject(parent) + sdlUI = mainObject.getUIProxy() + dataContainer = mainObject.getDataStorage() + } + + function destroyTime() { + mainObject.destroy() + } + + //No end time, works like a timer + function test_01_noEndTimeInCountUp() { + console.debug("enter") + + var initData = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:undefined , updateMode: 0, appID: 1} + + var expectedResult = {endTimeResult:-1, resultCode : Common.Result.SUCCESS} + + createTime() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + + var actualResult = sdlUI.setMediaClockTimer(initData) + + try { + compare(dataContainer.getApplication(initData.appID).mediaClock.endTime, expectedResult.endTimeResult, "time position") + compare(actualResult.__retCode, expectedResult.resultCode, "result code") + } catch (e) {} + + destroyTime() + console.debug("exit") + } + + //No start time. Function process error + function test_02_noStartTime() { + console.debug("enter") + + var initData = {startTime:undefined, endTime:{hours: 4, minutes: 0, seconds: 0} , updateMode: 1, appID: 1} + var expectedResult = {resultCode : Common.Result.INVALID_DATA} + + createTime() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + + var actualResult = sdlUI.setMediaClockTimer(initData) + + try { + compare(actualResult.__retCode, expectedResult.resultCode, "result code") + } catch (e) {} + + destroyTime() + console.debug("exit") + } + + //Receive "pause", when onready paused + function test_03_pauseAfterPause() { + console.debug("enter") + + var initData = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:{hours: 12, minutes: 00, seconds: 00}, updateMode: 0, appID: 1} + var expectedResult = {resultCode : Common.Result.IGNORED} + + createTime() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + + sdlUI.setMediaClockTimer(initData) + + initData.updateMode=2 + sdlUI.setMediaClockTimer(initData) + + var actualResult = sdlUI.setMediaClockTimer(initData) + + try { + compare(actualResult.__retCode, expectedResult.resultCode, "result code") + } catch (e) {} + + destroyTime() + console.debug("exit") + } + + //Receive "RESUME" after "CLEAR" + function test_04_resumeAfterClear() { + console.debug("enter") + + var initData = {startTime:{hours: 10, minutes: 0, seconds: 0},endTime:{ }, updateMode:0, appID:1} + + var expectedResult = {resultCode : Common.Result.IGNORED} + + createTime() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + + sdlUI.setMediaClockTimer(initData) + + initData.updateMode=4 + sdlUI.setMediaClockTimer(initData) + + initData.updateMode=3 + sdlUI.setMediaClockTimer(initData) + + var actualResult = sdlUI.setMediaClockTimer(initData) + try { + compare(actualResult.__retCode, expectedResult.resultCode, "result code") + } catch (e) {} + + destroyTime() + console.debug("exit") + } + + function test_05_resumeAfterEnd() { + console.debug("enter") + + var initData = {startTime:{hours: 0, minutes: 12, seconds: 33},endTime:{hours: 0, minutes: 12, seconds: 33}, updateMode:0, appID:1} + + var expectedResult = {resultCode : Common.Result.IGNORED} + + createTime() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + + sdlUI.setMediaClockTimer(initData) + + dataContainer.setApplicationProperties(initData.appID, { + "mediaClock": { + "updateMode": 0, + "runningMode": 1, + "startTime": initData.StartTime, + "endTime": initData.EndTime, + "startTimeForProgress": 753 + } + }) + initData.updateMode=3 + var actualResult = sdlUI.setMediaClockTimer(initData) + + try { + compare(actualResult.__retCode, expectedResult.resultCode, "result code") + } catch (e) {} + + destroyTime() + console.debug("exit") + } + + //Launch "COUNTUP" twice + function test_06_twoCountUp() { + console.debug("enter") + + var initData1 = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:{hours: 12, minutes: 00, seconds: 00}, updateMode: 0, appID: 1} + var initData2 = {startTime:{hours: 5, minutes: 0, seconds: 0}, endTime:{hours: 18, minutes: 00, seconds: 00}, updateMode: 0, appID: 1} + var expectedResult = {startTime:18000, endTime: 64800, updateMode: 0, resultCode : Common.Result.SUCCESS} + + createTime() + dataContainer.addApplication({appName:"TestAppName", appId:initData1.appID}) + + sdlUI.setMediaClockTimer(initData1) + + var actualResult = sdlUI.setMediaClockTimer(initData2) + + try { + compare(dataContainer.getApplication(initData1.appID).mediaClock.startTime, expectedResult.startTime, "startTime") + compare(dataContainer.getApplication(initData1.appID).mediaClock.endTime, expectedResult.endTime, "endTime") + compare(dataContainer.getApplication(initData1.appID).mediaClock.updateMode, expectedResult.updateMode, "updateMode") + compare(actualResult.__retCode, expectedResult.resultCode, "result code") + } catch (e) {} + + destroyTime() + console.debug("exit") + } + + //Get "RESUME", when clock is paused + function test_07_resumeAfterResume() { + console.debug("enter") + + var initData = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:{hours: 12, minutes: 00, seconds: 00}, updateMode: 0, appID: 1} + var expectedResult = {resultCode : Common.Result.IGNORED} + + createTime() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + + sdlUI.setMediaClockTimer(initData) + + initData.updateMode=3 + var actualResult = sdlUI.setMediaClockTimer(initData) + + try { + compare(actualResult.__retCode, expectedResult.resultCode, "result code") + } catch (e) {} + + destroyTime() + console.debug("exit") + } + + + function test_08_countDownAfterCountUp() { + console.debug("enter") + + var initData1 = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:{hours: 12, minutes: 00, seconds: 00}, updateMode: 0, appID: 1} + var initData2 = {startTime:{hours: 18, minutes: 0, seconds: 0}, endTime:{hours: 5, minutes: 00, seconds: 00}, updateMode: 1, appID: 1} + var expectedResult = {startTime:64800, endTime: 18000, updateMode: 1, resultCode : Common.Result.SUCCESS} + + createTime() + dataContainer.addApplication({appName:"TestAppName", appId:initData1.appID}) + + sdlUI.setMediaClockTimer(initData1) + + var actualResult = sdlUI.setMediaClockTimer(initData2) + + try { + compare(dataContainer.getApplication(initData1.appID).mediaClock.startTime, expectedResult.startTime, "startTime") + compare(dataContainer.getApplication(initData1.appID).mediaClock.endTime, expectedResult.endTime, "endTime") + compare(dataContainer.getApplication(initData1.appID).mediaClock.updateMode, expectedResult.updateMode, "updateMode") + compare(actualResult.__retCode, expectedResult.resultCode, "result code") + } catch (e) {} + + destroyTime() + console.debug("exit") + } + + function test_09_noEndTimeInCountDown() { + console.debug("enter") + + var initData = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:undefined, updateMode: 0, appID: 1} + + var expectedResult = {startTimeForProgress:14400, resultCode : Common.Result.SUCCESS} + + createTime() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + + var actualResult = sdlUI.setMediaClockTimer(initData) + + try { + compare(dataContainer.getApplication(initData.appID).mediaClock.startTimeForProgress, expectedResult.startTimeForProgress, "time position") + compare(actualResult.__retCode, expectedResult.resultCode, "result code") + } catch (e) {} + + destroyTime() + console.debug("exit") + } + } +} diff --git a/src/components/qt_hmi/test/src/tst_Show.qml b/src/components/qt_hmi/test/src/tst_Show.qml new file mode 100644 index 0000000000..cce2e7de49 --- /dev/null +++ b/src/components/qt_hmi/test/src/tst_Show.qml @@ -0,0 +1,363 @@ +/** + * @file tst_Slider.qml + * @brief Test Case for Slider. + * Copyright (c) 2013, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +import QtTest 1.0 +import QtQuick 2.0 +import QtMultimedia 5.0 +import com.ford.sdl.hmi.dbus_adapter 1.0 +import com.ford.sdl.hmi.hw_buttons 1.0 +import com.ford.sdl.hmi.log4cxx 1.0 +import "../qml_model_qt5/controls" +import "../qml_model_qt5/views" +import "../qml_model_qt5/hmi_api" as HmiApi +import "../qml_model_qt5/models" +import "../qml_model_qt5/popups" +import "../qml_model_qt5/hmi_api/Common.js" as Common +import "../qml_model_qt5/models/Constants.js" as Constants +import "../qml_model_qt5/models/Internal.js" as Internal + +Item { + width : mainWindowLoader.width + height: mainWindowLoader.height + Loader { + id: mainWindowLoader + asynchronous : false + } + + TestCase { + name: "Show" + when: windowShown + property var mainWindowComponent : Qt.createComponent("../qml_model_qt5/MainWindow.qml") + property var mainObject + property var sldUI + property var dataContainer + property var contentLoader + + property var softButtonsListExample : [ + {softButtonID:0, isHighlighted:true, systemAction:Common.SystemAction.DEFAULT_ACTION, + type:Common.SoftButtonType.SBT_TEXT, text:"Default Action"}, + {softButtonID:1, isHighlighted:false, systemAction:Common.SystemAction.STEAL_FOCUS, + type:Common.SoftButtonType.SBT_IMAGE, text:"Steal Focus"}, + {softButtonID:2, isHighlighted:false, systemAction:Common.SystemAction.KEEP_CONTEXT, + type:Common.SoftButtonType.SBT_BOTH, text:"Keep context"}] + + + //initialization for each test + function createShow(appID) { + mainWindowLoader.source = "" + mainWindowLoader.source = "../../../../src/components/qt_hmi/qml_model_qt5/MainWindow.qml" + var mainWindowObject = mainWindowLoader.item + if(!mainWindowObject) + qtest_fail("mainWindowObject is undefined"); + var mainScreen = mainWindowObject.getMainScreen() + mainScreen.visible = true + var warningInfo = mainWindowObject.getWarningInfo() + warningInfo.visible = false + contentLoader = mainWindowObject.getContentLoader() + contentLoader.asynchronous = false + sldUI = mainWindowObject.getUIProxy() + dataContainer = mainWindowObject.getDataStorage() + dataContainer.addApplication({appName:"TestAppName", appId:appID}) + } + + + + //cleanup for each test + function destroyShow() { + //Clear Loader with MainWindow, which delete own models and views + mainWindowLoader.source = "" + } + + + //Fill up all fields, check save process to dataContainer + function test_01_create() { + console.debug("enter") + var initData = { + appID:1, + showStrings:[ + {fieldName:Common.TextFieldName.mainField1 ,fieldText:"showString1"}, + {fieldName:Common.TextFieldName.mainField2,fieldText:"showString2"}, + {fieldName:Common.TextFieldName.mainField3,fieldText:"showString3"}, + {fieldName:Common.TextFieldName.mainField4,fieldText:"showString4"}, + {fieldName:Common.TextFieldName.mediaTrack,fieldText:"mediaTrack"}, + {fieldName:Common.TextFieldName.statusBar,fieldText:"StatusBar"}, + {fieldName:Common.TextFieldName.mediaClock,fieldText:"12:34"} + ], + softButtons:softButtonsListExample, + alignment:2, + graphic:{value:"/home/user/applink/bin/SPTAlice9675308/action.png",imageType: "DYNAMIC"}, + secondaryGraphic:{value:"/home/user/applink/bin/SPTAlice9675308/action.png",imageType: "DYNAMIC"}, + customPresets:["GEN0","GEN1","GEN2","GEN3"] + } + + createShow(1) + var app = dataContainer.getApplication(initData.appID) + sldUI.show (initData) + + try { + + compare(app.hmiUIText.mainField1 , initData.showStrings[0].fieldText, "mainField1") + compare(app.hmiUIText.mainField2 , initData.showStrings[1].fieldText, "mainField2") + compare(app.hmiUIText.mainField3 , initData.showStrings[2].fieldText, "mainField3") + compare(app.hmiUIText.mainField4 , initData.showStrings[3].fieldText, "mainField4") + compare(app.hmiUIText.mediaTrack , initData.showStrings[4].fieldText, "mediaTrack") + compare(app.hmiUIText.statusBar , initData.showStrings[5].fieldText, "StatusBar" ) + compare(app.hmiUIText.mediaClock , initData.showStrings[6].fieldText, "mediaClock") + var a; + if(app.hmiUITextAlignment === 1) a=0; + if(app.hmiUITextAlignment === 2) a=1; + if(app.hmiUITextAlignment === 4) a=2; + compare(initData.alignment, a, "Alignment") + compare(app.hmiUIText.image, initData.graphic.value, "image") + compare(app.hmiUIText.secondaryImage, initData.secondaryGraphic.value, "secdondImage") + compare(app.softButtons.count, initData.softButtons.length, "wrong buttons count created") + for (var i = 0, len = app.softButtons.count; i < len; i++) + { + var act = app.softButtons.get(i) + var exp = initData.softButtons[i] + compare(act.softButtonID, exp.softButtonID, "wrong softButtonID in button") + compare(act.isHighlighted, exp.isHighlighted, "wrong isHighlighted in button") + compare(act.systemAction, exp.systemAction, "wrong systemAction in button") + compare(act.text, exp.text, "wrong text in button") + } + compare(app.customPresets.count, initData.customPresets.length, "wrong buttons count created") + for (var j = 0, len2 = app.customPresets.count; j < len; j++) + { + var act2 = app.customPresets.get(j) + var exp2 = initData.customPresets[j] + compare(act2.text, exp2, "wrong text in button") + } + } + catch (e) {} + destroyShow() + console.debug("exit") + } + //All fields are empty + function test_02_emptyInit() + { + console.debug("enter") + var initData = { + appID:1, + showStrings:[ + {fieldName:Common.TextFieldName.mainField1 ,fieldText:""}, + {fieldName:Common.TextFieldName.mainField2,fieldText:""}, + {fieldName:Common.TextFieldName.mainField3,fieldText:""}, + {fieldName:Common.TextFieldName.mainField4,fieldText:""}, + {fieldName:Common.TextFieldName.mediaTrack,fieldText:""}, + {fieldName:Common.TextFieldName.statusBar,fieldText:""}, + {fieldName:Common.TextFieldName.mediaClock,fieldText:""} + ], + softButtons:[], + alignment:0, + graphic:{value:"",imageType: "DYNAMIC"}, + secondaryGraphic:{value:"",imageType: "DYNAMIC"}, + customPresets:[] + } + + createShow(1) + var app = dataContainer.getApplication(initData.appID) + sldUI.show (initData) + + try { + + compare(app.hmiUIText.mainField1 , initData.showStrings[0].fieldText, "mainField1") + compare(app.hmiUIText.mainField2 , initData.showStrings[1].fieldText, "mainField2") + compare(app.hmiUIText.mainField3 , initData.showStrings[2].fieldText, "mainField3") + compare(app.hmiUIText.mainField4 , initData.showStrings[3].fieldText, "mainField4") + compare(app.hmiUIText.mediaTrack , initData.showStrings[4].fieldText, "mediaTrack") + compare(app.hmiUIText.statusBar , initData.showStrings[5].fieldText, "StatusBar" ) + compare(app.hmiUIText.mediaClock , initData.showStrings[6].fieldText, "mediaClock") + var a; + if(app.hmiUITextAlignment === 1) a=0; + if(app.hmiUITextAlignment === 2) a=1; + if(app.hmiUITextAlignment === 4) a=2; + compare(initData.alignment, a, "Alignment") + compare(app.hmiUIText.image, initData.graphic.value, "image") + compare(app.hmiUIText.secondaryImage, initData.secondaryGraphic.value, "secdondImage") + compare(app.softButtons.count, initData.softButtons.length, "wrong buttons count created") + for (var i = 0, len = app.softButtons.count; i < len; i++) + { + var act = app.softButtons.get(i) + var exp = initData.softButtons[i] + compare(act.softButtonID, exp.softButtonID, "wrong softButtonID in button") + compare(act.isHighlighted, exp.isHighlighted, "wrong isHighlighted in button") + compare(act.systemAction, exp.systemAction, "wrong systemAction in button") + compare(act.text, exp.text, "wrong text in button") + } + compare(app.customPresets.count, initData.customPresets.length, "wrong buttons count created") + for (var j = 0, len2 = app.customPresets.count; j < len; j++) + { + var act2 = app.customPresets.get(j) + var exp2 = initData.customPresets[j] + compare(act2.text, exp2, "wrong text in button") + } + } + catch (e) {} + destroyShow() + console.debug("exit") + } + + //Mandatory fields only + function test_03_create_mandatory_only() { + console.debug("enter") + var initData = { + appID:1, + showStrings:[ + {fieldName:Common.TextFieldName.mainField1 ,fieldText:"showString1"}, + {fieldName:Common.TextFieldName.mainField2,fieldText:"showString2"}, + {fieldName:Common.TextFieldName.mainField3,fieldText:"showString3"}, + {fieldName:Common.TextFieldName.mainField4,fieldText:"showString4"}, + {fieldName:Common.TextFieldName.mediaTrack,fieldText:"mediaTrack"}, + {fieldName:Common.TextFieldName.statusBar,fieldText:"StatusBar"}, + {fieldName:Common.TextFieldName.mediaClock,fieldText:"12:34"} + ] + } + + createShow(1) + var app = dataContainer.getApplication(initData.appID) + sldUI.show (initData) + + try { + + compare(app.hmiUIText.mainField1 , initData.showStrings[0].fieldText, "mainField1") + compare(app.hmiUIText.mainField2 , initData.showStrings[1].fieldText, "mainField2") + compare(app.hmiUIText.mainField3 , initData.showStrings[2].fieldText, "mainField3") + compare(app.hmiUIText.mainField4 , initData.showStrings[3].fieldText, "mainField4") + compare(app.hmiUIText.mediaTrack , initData.showStrings[4].fieldText, "mediaTrack") + compare(app.hmiUIText.statusBar , initData.showStrings[5].fieldText, "StatusBar" ) + compare(app.hmiUIText.mediaClock , initData.showStrings[6].fieldText, "mediaClock") + + } + catch (e) {} + destroyShow() + console.debug("exit") + } + //Field with extra param + function test_04_fake_param() { + console.debug("enter") + var initData = { + appID:1, + showStrings:[ + {fieldName:Common.TextFieldName.mainField1 ,fieldText:"showString1"}, + {fieldName:Common.TextFieldName.mainField2,fieldText:"showString2"}, + {fieldName:Common.TextFieldName.mainField3,fieldText:"showString3"}, + {fieldName:Common.TextFieldName.mainField4,fieldText:"showString4"}, + {fieldName:Common.TextFieldName.mediaTrack,fieldText:"mediaTrack"}, + {fieldName:Common.TextFieldName.statusBar,fieldText:"StatusBar",fakeParam:"FakeParam"}, + {fieldName:Common.TextFieldName.mediaClock,fieldText:"12:34"} + ] + } + + createShow(1) + var app = dataContainer.getApplication(initData.appID) + sldUI.show (initData) + + try { + + compare(app.hmiUIText.mainField1 , initData.showStrings[0].fieldText, "mainField1") + compare(app.hmiUIText.mainField2 , initData.showStrings[1].fieldText, "mainField2") + compare(app.hmiUIText.mainField3 , initData.showStrings[2].fieldText, "mainField3") + compare(app.hmiUIText.mainField4 , initData.showStrings[3].fieldText, "mainField4") + compare(app.hmiUIText.mediaTrack , initData.showStrings[4].fieldText, "mediaTrack") + compare(app.hmiUIText.statusBar , initData.showStrings[5].fieldText, "StatusBar" ) + compare(app.hmiUIText.mediaClock , initData.showStrings[6].fieldText, "mediaClock") + + } + catch (e) {} + destroyShow() + console.debug("exit") + } + //aligment of mainField1, mainField2 + function test_05_alignment() { + console.debug("enter") + var initData = { + appID:1, + showStrings:[], + alignment:0, + } + + createShow(1) + var app = dataContainer.getApplication(initData.appID) + sldUI.show (initData) + + try { + //Magic with digits - because enum of text.Alighnment enum and sdl alignment doesn't match + var a; + if(app.hmiUITextAlignment === 1) a=0; + if(app.hmiUITextAlignment === 2) a=1; + if(app.hmiUITextAlignment === 4) a=2; + compare(initData.alignment, a, "Alignment") + initData.alignment=1 + sldUI.show (initData) + var b; + if(app.hmiUITextAlignment === 1) b=0; + if(app.hmiUITextAlignment === 2) b=1; + if(app.hmiUITextAlignment === 4) b=2; + compare(initData.alignment, b, "Alignment") + initData.alignment=2 + sldUI.show (initData) + var c; + if(app.hmiUITextAlignment === 1) c=0; + if(app.hmiUITextAlignment === 2) c=1; + if(app.hmiUITextAlignment === 4) c=2; + compare(initData.alignment, c, "Alignment") + } + catch (e) {} + destroyShow() + console.debug("exit") + } + //pole bez parametra + function test_06_no_param() { + console.debug("enter") + var initData = { + appID:1, + showStrings:[], + graphic:{imageType: "DYNAMIC"}, + } + + createShow(1) + var app = dataContainer.getApplication(initData.appID) + sldUI.show (initData) + + try { + + compare(app.hmiUIText.image, undefined, "image") + + } + catch (e) {} + destroyShow() + console.debug("exit") + } +} +} diff --git a/src/components/qt_hmi/test/src/tst_Slider.qml b/src/components/qt_hmi/test/src/tst_Slider.qml new file mode 100644 index 0000000000..0e6acef078 --- /dev/null +++ b/src/components/qt_hmi/test/src/tst_Slider.qml @@ -0,0 +1,204 @@ +/** + * @file tst_Slider.qml + * @brief Test Case for Slider. + * Copyright (c) 2013, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +import QtTest 1.0 +import QtQuick 2.0 +import QtMultimedia 5.0 +import com.ford.sdl.hmi.dbus_adapter 1.0 +import com.ford.sdl.hmi.hw_buttons 1.0 +import com.ford.sdl.hmi.log4cxx 1.0 +import "../qml_model_qt5/controls" +import "../qml_model_qt5/views" +import "../qml_model_qt5/hmi_api" as HmiApi +import "../qml_model_qt5/models" +import "../qml_model_qt5/popups" +import "../qml_model_qt5/hmi_api/Common.js" as Common +import "../qml_model_qt5/models/Constants.js" as Constants +import "../qml_model_qt5/models/Internal.js" as Internal + +Item { + TestCase { + name: "Slider" + when: windowShown + property var mainWindowComponent : Qt.createComponent("../qml_model_qt5/MainWindow.qml") + property var mainObject + property var sldUI + property var dataContainer + property var sliderPopup + property var timer + + function createSlider() { + mainObject = mainWindowComponent.createObject(parent) + var mainScreen = mainObject.getMainScreen() + mainScreen.visible = true + sldUI = mainObject.getUIProxy() + dataContainer = mainObject.getDataStorage() + sliderPopup = mainObject.getSlider() + timer = sliderPopup.getTimer() + } + + + function destroySlider() { + mainObject.destroy() + } + + function test_01_timeoutZero() { + console.debug("enter") + var initData = {numTicks:9, position:4, sliderHeader:"header", sliderFooter:["footer"], timeout:0, appID:1} + createSlider() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + var actualResult = sldUI.slider(initData) + try { + compare(actualResult.sliderPosition, initData.position, "slider position") + } catch(e){} + destroySlider() + console.debug("exit") + } + + function test_02_changePosition() { + console.debug("enter") + var initData = {numTicks:9, position:4, sliderHeader:"header", sliderFooter:["footer"], timeout:1, appID:1} + var expectedResult = {position : 2, resultCode : Common.Result.SUCCESS} + createSlider() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + sliderPopup.onReady.connect(function simulateUserAction(){sliderPopup.position = expectedResult.position}) + + sldUI.slider(initData) + + timer.onTriggered() + try { + compare(dataContainer.uiSlider.position, expectedResult.position, "slider position") + compare(sliderPopup.resultCode, expectedResult.resultCode, "result code") + } catch (e) {} + destroySlider() + console.debug("exit") + } + + function test_03_unChangedPosition() { + console.debug("enter") + var initData = {numTicks:9, position:4, sliderHeader:"header", sliderFooter:["footer"], timeout:1, appID:1} + var expectedResult = {position : 4, resultCode : Common.Result.SUCCESS} + createSlider() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + + sldUI.slider(initData) + + timer.onTriggered() + try { + compare(dataContainer.uiSlider.position, expectedResult.position, "slider position") + compare(sliderPopup.resultCode, expectedResult.resultCode, "result code") + } catch (e) {} + destroySlider() + console.debug("exit") + } + + + function test_04_changePositionBackPressed() { + console.debug("enter") + var initData = {numTicks:9, position:4, sliderHeader:"header", sliderFooter:["footer"], timeout:1, appID:1} + var expectedResult = {position : 4, resultCode : Common.Result.ABORTED} + createSlider() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + sliderPopup.onReady.connect(function simulateUserAction(){sliderPopup.position = expectedResult.position}) + + sldUI.slider(initData) + sliderPopup.getBackButton().clicked() + + try { + compare(dataContainer.uiSlider.position, expectedResult.position, "slider position") + compare(sliderPopup.resultCode, expectedResult.resultCode, "result code") + } catch (e) {} + destroySlider() + console.debug("exit") + } + + function test_05_secondCall() { + console.debug("enter") + var initData = {numTicks:9, position:4, sliderHeader:"header", sliderFooter:["footer"], timeout:1, appID:1} + var expectedResult = {position : 5, resultCode : Common.Result.ABORTED} + createSlider() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + sliderPopup.onReady.connect(function simulateUserAction(){sliderPopup.position = expectedResult.position}) + + sldUI.slider(initData) + initData.position = 5 + var actualResult = sldUI.slider(initData) + + try { + compare(actualResult.sliderPosition, expectedResult.position, "slider position") + compare(actualResult.__retCode, expectedResult.resultCode, "result code") + } catch (e) {} + destroySlider() + console.debug("exit") + } + + function test_06_footerValueNoChange() { + console.debug("enter") + var initData = {numTicks:4, position:3, sliderHeader:"header", sliderFooter:["footer1", "footer2", "footer3", "footer4"], timeout:1, appID:1} + var expectedResult = {position: 3, footers:["footer1", "footer2", "footer3", "footer4"]} + createSlider() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + + sldUI.slider(initData) + + try { + compare(sliderPopup.getFooterText().text, expectedResult.footers[expectedResult.position - 1], "current footer") + } catch (e) {} + destroySlider() + console.debug("exit") + } + + function test_07_footerValueChange() { + console.debug("enter") + var initData = {numTicks:4, position:2, sliderHeader:"header", sliderFooter:["footer1", "footer2", "footer3", "footer4"], timeout:1, appID:1} + var expectedResult = {position: 3, footers:["footer1", "footer2", "footer3", "footer4"]} + createSlider() + dataContainer.addApplication({appName:"TestAppName", appId:initData.appID}) + sliderPopup.onReady.connect(function simulateUserAction(){ + var rect = sliderPopup.getBorderRectangle() + console.debug("visible", sliderPopup.visible) + mouseClick(rect, rect.width / initData.numTicks * expectedResult.position, 1) + }) + + sldUI.slider(initData) + + try { + compare(sliderPopup.getFooterText().text, expectedResult.footers[expectedResult.position - 1], "current footer") + } catch (e) {} + destroySlider() + console.debug("exit") + } + + } +} |