From 2d7070417f5e5cca2cf984cfc517a048afbb6764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 9 Oct 2017 15:57:12 +0200 Subject: [PATCH] enable maxwarnings again --- debian/rules | 2 +- plugins/mock/devicepluginmock.json | 60 --------- tests/auto/rules/testrules.cpp | 135 +++++++++++++++++++++ tests/auto/timemanager/testtimemanager.cpp | 3 +- 4 files changed, 137 insertions(+), 63 deletions(-) diff --git a/debian/rules b/debian/rules index 6d471ff6..7bc240e6 100755 --- a/debian/rules +++ b/debian/rules @@ -43,7 +43,7 @@ override_dh_install: $(PREPROCESS_FILES:.in=) cp -a $(CURDIR)/doc/html $(CURDIR)/debian/guh-doc/usr/share/doc/guh/ || true override_dh_auto_test: - dh_auto_test -- -k TESTARGS="-maxwarnings 0 -o -,txt -o test-results.xml,xunitxml" + dh_auto_test -- -k TESTARGS="-o -,txt -o test-results.xml,xunitxml" override_dh_strip: dh_strip --dbg-package=guh-dbg diff --git a/plugins/mock/devicepluginmock.json b/plugins/mock/devicepluginmock.json index 31368f01..24485525 100644 --- a/plugins/mock/devicepluginmock.json +++ b/plugins/mock/devicepluginmock.json @@ -8,7 +8,6 @@ "idName": "configParamInt", "name": "configParamInt", "type": "int", - "index": 0, "defaultValue": 42, "minValue": 1, "maxValue": 50 @@ -18,7 +17,6 @@ "idName": "configParamBool", "name": "configParamBool", "type": "bool", - "index": 1, "defaultValue": true } ], @@ -48,7 +46,6 @@ "idName": "resultCount", "name": "resultCount", "type": "int", - "index": 0, "defaultValue": 2, "allowedValues": [1, 2] } @@ -58,7 +55,6 @@ "id": "d4f06047-125e-4479-9810-b54c189917f5", "idName": "httpport", "name": "http port", - "index": 0, "type": "int" }, { @@ -66,7 +62,6 @@ "idName": "async", "name": "async", "type": "bool", - "index": 1, "defaultValue": false, "readOnly": true }, @@ -74,7 +69,6 @@ "id": "ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4", "idName": "broken", "name": "broken", - "index": 2, "type": "bool", "defaultValue": false } @@ -85,7 +79,6 @@ "idName": "int", "name": "Dummy int state", "eventTypeName": "Dummy int state changed", - "index": 0, "defaultValue": 10, "graphRelevant": true, "type": "int" @@ -95,7 +88,6 @@ "idName": "boolValue", "name": "Dummy bool state", "eventTypeName": "Dummy bool state changed", - "index": 1, "defaultValue": false, "type": "bool", "cached": false @@ -104,21 +96,18 @@ "eventTypes": [ { "id": "45bf3752-0fc6-46b9-89fd-ffd878b5b22b", - "index": 0, "name": "Mock Event 1", "graphRelevant": true }, { "id": "863d5920-b1cf-4eb9-88bd-8f7b8583b1cf", "name": "Mock Event 2", - "index": 1, "paramTypes": [ { "id": "0550e16d-60b9-4ba5-83f4-4d3cee656121", "idName": "mockParamInt", "name": "mockParamInt", "type": "int", - "index": 0, "defaultValue": 10 } ] @@ -129,20 +118,17 @@ "id": "dea0f4e1-65e3-4981-8eaa-2701c53a9185", "name": "Mock Action 1 (with params)", "idName": "withParams", - "index": 0, "paramTypes": [ { "id": "a2d3a256-a551-4712-a65b-ecd5a436a1cb", "idName": "mockActionParam1", "name": "mockActionParam1", - "index": 0, "type": "int" }, { "id": "304a4899-18be-4e3b-94f4-d03be52f3233", "idName": "mockActionParam2", "name": "mockActionParam2", - "index": 1, "type": "bool" } ] @@ -150,25 +136,21 @@ { "id": "defd3ed6-1a0d-400b-8879-a0202cf39935", "idName": "withoutParams", - "index": 1, "name": "Mock Action 2 (without params)" }, { "id": "fbae06d3-7666-483e-a39e-ec50fe89054e", "idName": "mockAsync", - "index": 2, "name": "Mock Action 3 (async)" }, { "id": "df3cf33d-26d5-4577-9132-9823bd33fad0", "idName": "mockFailing", - "index": 3, "name": "Mock Action 4 (broken)" }, { "id": "bfe89a1d-3497-4121-8318-e77c37537219", "idName": "mockAsyncFailing", - "index": 4, "name": "Mock Action 5 (async, broken)" } ] @@ -192,7 +174,6 @@ "id": "d4f06047-125e-4479-9810-b54c189917f5", "idName": "httpport", "name": "http port", - "index": 0, "type": "int" }, { @@ -200,7 +181,6 @@ "idName": "async", "name": "async", "type": "bool", - "index": 1, "defaultValue": false, "readOnly": true }, @@ -208,7 +188,6 @@ "id": "ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4", "idName": "broken", "name": "broken", - "index": 2, "type": "bool", "defaultValue": false } @@ -219,7 +198,6 @@ "idName": "int", "name": "Dummy int state", "eventTypeName": "Dummy int state changed", - "index": 0, "defaultValue": 10, "graphRelevant": true, "type": "int" @@ -229,7 +207,6 @@ "idName": "boolValue", "name": "Dummy bool state", "eventTypeName": "Dummy bool state changed", - "index": 1, "defaultValue": false, "type": "bool", "cached": false @@ -239,21 +216,18 @@ { "id": "45bf3752-0fc6-46b9-89fd-ffd878b5b22b", "idName": "event1", - "index": 0, "name": "Mock Event 1" }, { "id": "863d5920-b1cf-4eb9-88bd-8f7b8583b1cf", "idName": "event2", "name": "Mock Event 2", - "index": 1, "paramTypes": [ { "id": "0550e16d-60b9-4ba5-83f4-4d3cee656121", "idName": "mockParamInt", "name": "mockParamInt", "type": "int", - "index": 0, "defaultValue": 10 } ] @@ -264,42 +238,35 @@ "id": "dea0f4e1-65e3-4981-8eaa-2701c53a9185", "name": "Mock Action 1 (with params)", "idName": "withParams", - "index": 0, "paramTypes": [ { "id": "a2d3a256-a551-4712-a65b-ecd5a436a1cb", "idName": "mockActionParam1", "name": "mockActionParam1", - "index": 0, "type": "int" }, { "id": "304a4899-18be-4e3b-94f4-d03be52f3233", "idName": "mockActionParam2", "name": "mockActionParam2", - "index": 1, "type": "bool" } ] }, { "id": "defd3ed6-1a0d-400b-8879-a0202cf39935", - "index": 1, "name": "Mock Action 2 (without params)" }, { "id": "fbae06d3-7666-483e-a39e-ec50fe89054e", - "index": 2, "name": "Mock Action 3 (async)" }, { "id": "df3cf33d-26d5-4577-9132-9823bd33fad0", - "index": 3, "name": "Mock Action 4 (broken)" }, { "id": "bfe89a1d-3497-4121-8318-e77c37537219", - "index": 4, "name": "Mock Action 5 (async, broken)" } ] @@ -325,7 +292,6 @@ "idName": "resultCount", "name": "resultCount", "type": "int", - "index": 0, "defaultValue": 2, "allowedValues": [1, 2] } @@ -337,7 +303,6 @@ "name": "color", "eventTypeName": "color changed", "actionTypeName": "Set color", - "index": 0, "type": "QColor", "defaultValue": "#000000", "ruleRelevant": false, @@ -351,7 +316,6 @@ "eventTypeName": "percentage changed", "actionTypeName": "Set percentage", "type": "int", - "index": 1, "unit": "Percentage", "defaultValue": 0, "ruleRelevant": false, @@ -366,7 +330,6 @@ "eventTypeName": "allowed values changed", "actionTypeName": "Set allowed values", "type": "QString", - "index": 2, "defaultValue": "String value 1", "possibleValues": [ "String value 1", @@ -383,7 +346,6 @@ "eventTypeName": "double value changed", "actionTypeName": "Set double value", "type": "double", - "index": 3, "defaultValue": 0.0, "minValue": -100.0, "maxValue": 100.0, @@ -395,7 +357,6 @@ "name": "bool value", "eventTypeName": "bool value changed", "actionTypeName": "Set bool value", - "index": 4, "type": "bool", "defaultValue": false, "writable": true @@ -405,7 +366,6 @@ { "id": "54646e7c-bc54-4895-81a2-590d72d120f9", "idName": "timeout", - "index": 0, "name": "Timeout action" } ] @@ -430,7 +390,6 @@ "idName": "resultCount", "name": "resultCount", "type": "int", - "index": 0, "defaultValue": 2, "allowedValues": [1, 2] } @@ -441,7 +400,6 @@ "idName": "pin", "name": "pin", "type": "QString", - "index": 0, "inputType": "TextLine", "defaultValue": "243681", "readOnly": true @@ -454,7 +412,6 @@ "name": "color", "eventTypeName": "color changed", "actionTypeName": "Set color", - "index": 0, "type": "QColor", "defaultValue": "#000000", "ruleRelevant": false, @@ -468,7 +425,6 @@ "eventTypeName": "percentage changed", "actionTypeName": "Set percentage", "type": "int", - "index": 1, "unit": "Percentage", "defaultValue": 0, "ruleRelevant": false, @@ -483,7 +439,6 @@ "eventTypeName": "allowed values changed", "actionTypeName": "Set allowed values", "type": "QString", - "index": 2, "defaultValue": "String value 1", "possibleValues": [ "String value 1", @@ -500,7 +455,6 @@ "eventTypeName": "double value changed", "actionTypeName": "Set double value", "type": "double", - "index": 3, "defaultValue": 0.0, "minValue": -100.0, "maxValue": 100.0, @@ -512,7 +466,6 @@ "name": "bool value", "eventTypeName": "bool value changed", "actionTypeName": "Set bool value", - "index": 4, "type": "bool", "defaultValue": false, "writable": true @@ -522,7 +475,6 @@ { "id": "54646e7c-bc54-4895-81a2-590d72d120f9", "idName": "timeout", - "index": 0, "name": "Timeout action" } ] @@ -547,7 +499,6 @@ "name": "bool value", "eventTypeName": "bool value changed", "actionTypeName": "Set bool value", - "index": 0, "type": "bool", "defaultValue": false, "writable": true @@ -569,7 +520,6 @@ "idName": "parentUuid", "name": "parent uuid", "type": "QUuid", - "index": 0, "readOnly": true } ], @@ -580,7 +530,6 @@ "name": "bool value", "eventTypeName": "bool value changed", "actionTypeName": "Set bool value", - "index": 0, "type": "bool", "defaultValue": false, "writable": true @@ -602,7 +551,6 @@ "idName": "textLine", "name": "Text line", "type": "QString", - "index": 0, "inputType": "TextLine", "defaultValue": "This is a text line" }, @@ -611,7 +559,6 @@ "idName": "textArea", "name": "Text area", "type": "QString", - "index": 1, "inputType": "TextArea", "defaultValue": "This is a text area" }, @@ -620,7 +567,6 @@ "idName": "password", "name": "Password text", "type": "QString", - "index": 2, "inputType": "Password", "defaultValue": "secret" }, @@ -629,7 +575,6 @@ "idName": "search", "name": "Search text", "type": "QString", - "index": 3, "inputType": "Search", "defaultValue": "Search text..." }, @@ -638,7 +583,6 @@ "idName": "mail", "name": "Mail address", "type": "QString", - "index": 4, "inputType": "Mail", "defaultValue": "name@example.com" }, @@ -647,7 +591,6 @@ "idName": "ip4", "name": "IPv4 address", "type": "QString", - "index": 5, "inputType": "IPv4Address", "defaultValue": "127.0.0.1" }, @@ -656,7 +599,6 @@ "idName": "ip6", "name": "IPv6 address", "type": "QString", - "index": 6, "inputType": "IPv6Address", "defaultValue": "::1" }, @@ -665,7 +607,6 @@ "idName": "url", "name": "URL", "type": "QString", - "index": 7, "inputType": "Url", "defaultValue": "http://guh.guru" }, @@ -674,7 +615,6 @@ "idName": "mac", "name": "Mac address", "type": "QString", - "index": 8, "inputType": "MacAddress", "defaultValue": "11:22:33:aa:bb:cc" } diff --git a/tests/auto/rules/testrules.cpp b/tests/auto/rules/testrules.cpp index bc864131..4e3d94ac 100644 --- a/tests/auto/rules/testrules.cpp +++ b/tests/auto/rules/testrules.cpp @@ -42,6 +42,8 @@ private: void cleanupMockHistory(); void cleanupRules(); + DeviceId addPushButtonDevice(); + QVariantMap createEventDescriptor(const DeviceId &deviceId, const EventTypeId &eventTypeId); QVariantMap createActionWithParams(const DeviceId &deviceId); @@ -79,6 +81,9 @@ private slots: void testStateEvaluator2_data(); void testStateEvaluator2(); + void testChildEvaluator_data(); + void testChildEvaluator(); + void testStateChange(); void enableDisableRule(); @@ -114,6 +119,49 @@ void TestRules::cleanupRules() { } } +DeviceId TestRules::addPushButtonDevice() +{ + // Discover device + QVariantList discoveryParams; + QVariantMap resultCountParam; + resultCountParam.insert("paramTypeId", resultCountParamTypeId); + resultCountParam.insert("value", 1); + discoveryParams.append(resultCountParam); + + QVariantMap params; + params.insert("deviceClassId", mockPushButtonDeviceClassId); + params.insert("discoveryParams", discoveryParams); + QVariant response = injectAndWait("Devices.GetDiscoveredDevices", params); + verifyDeviceError(response); + + // Pair device + DeviceDescriptorId descriptorId = DeviceDescriptorId(response.toMap().value("params").toMap().value("deviceDescriptors").toList().first().toMap().value("id").toString()); + params.clear(); + params.insert("deviceClassId", mockPushButtonDeviceClassId); + params.insert("name", "Pushbutton device"); + params.insert("deviceDescriptorId", descriptorId.toString()); + response = injectAndWait("Devices.PairDevice", params); + + verifyDeviceError(response); + + PairingTransactionId pairingTransactionId(response.toMap().value("params").toMap().value("pairingTransactionId").toString()); + QString displayMessage = response.toMap().value("params").toMap().value("displayMessage").toString(); + + qDebug() << "displayMessage" << displayMessage; + + // Wait for button pressed automatically + QTest::qWait(3500); + + // Confirm pairing + params.clear(); + params.insert("pairingTransactionId", pairingTransactionId.toString()); + response = injectAndWait("Devices.ConfirmPairing", params); + + verifyDeviceError(response); + + return DeviceId(response.toMap().value("params").toMap().value("deviceId").toString()); +} + QVariantMap TestRules::createEventDescriptor(const DeviceId &deviceId, const EventTypeId &eventTypeId) { QVariantMap eventDescriptor; @@ -1468,6 +1516,93 @@ void TestRules::testStateEvaluator2() QVERIFY2(mainEvaluator.evaluate() == shouldMatch, shouldMatch ? "State should match" : "State shouldn't match"); } +void TestRules::testChildEvaluator_data() +{ + cleanupRules(); + + DeviceId pushButtonDeviceId = addPushButtonDevice(); + + // Create child evaluators + // Action + QVariantMap action; + action.insert("actionTypeId", mockActionIdNoParams); + action.insert("deviceId", m_mockDeviceId); + action.insert("ruleActionParams", QVariantList()); + + // Exit action (with params) + QVariantMap exitAction; + QVariantList actionParams; + QVariantMap param1; + param1.insert("paramTypeId", mockActionParam1ParamTypeId); + param1.insert("value", 12); + actionParams.append(param1); + QVariantMap param2; + param2.insert("paramTypeId", mockActionParam2ParamTypeId); + param2.insert("value", true); + actionParams.append(param2); + exitAction.insert("actionTypeId", mockActionIdWithParams); + exitAction.insert("deviceId", m_mockDeviceId); + exitAction.insert("ruleActionParams", actionParams); + + // Stateevaluators + QVariantMap stateEvaluator; + + QVariantMap stateDescriptorPercentage; + stateDescriptorPercentage.insert("deviceId", pushButtonDeviceId); + stateDescriptorPercentage.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorGreaterOrEqual)); + stateDescriptorPercentage.insert("stateTypeId", percentageStateParamTypeId); + stateDescriptorPercentage.insert("value", 50); + + QVariantMap stateDescriptorDouble; + stateDescriptorDouble.insert("deviceId", pushButtonDeviceId); + stateDescriptorDouble.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals)); + stateDescriptorDouble.insert("stateTypeId", doubleStateParamTypeId); + stateDescriptorDouble.insert("value", true); + + QVariantMap stateDescriptorAllowedValues; + stateDescriptorAllowedValues.insert("deviceId", pushButtonDeviceId); + stateDescriptorAllowedValues.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals)); + stateDescriptorAllowedValues.insert("stateTypeId", allowedValuesStateParamTypeId); + stateDescriptorAllowedValues.insert("value", "String value 2"); + + QVariantMap stateDescriptorColor; + stateDescriptorColor.insert("deviceId", pushButtonDeviceId); + stateDescriptorColor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals)); + stateDescriptorColor.insert("stateTypeId", colorStateParamTypeId); + stateDescriptorColor.insert("value", "FFFF00"); + + + +// QVariantMap stateEvaluatorInt; +// stateEvaluatorInt.insert("stateDescriptor", stateDescriptorInt); +// stateEvaluatorInt.insert("operator", JsonTypes::stateOperatorToString(Types::StateOperatorAnd)); +// QVariantMap stateEvaluatorBool; +// stateEvaluatorBool.insert("stateDescriptor", stateDescriptorBool); +// stateEvaluatorBool.insert("operator", JsonTypes::stateOperatorToString(Types::StateOperatorAnd)); +// QVariantList childEvaluators; +// childEvaluators.append(stateEvaluatorInt); +// childEvaluators.append(stateEvaluatorBool); +// stateEvaluator.insert("childEvaluators", childEvaluators); +// stateEvaluator.insert("operator", JsonTypes::stateOperatorToString(Types::StateOperatorAnd)); + + + // The rule + QVariantMap ruleMap; + ruleMap.insert("name", "Child evaluator rule"); + ruleMap.insert("stateEvaluator", stateEvaluator); + ruleMap.insert("actions", QVariantList() << action); + ruleMap.insert("exitActions", QVariantList() << exitAction); + + + QVariant response = injectAndWait("Rules.AddRule", ruleMap); + verifyRuleError(response); +} + +void TestRules::testChildEvaluator() +{ + +} + void TestRules::enableDisableRule() { // Add a rule diff --git a/tests/auto/timemanager/testtimemanager.cpp b/tests/auto/timemanager/testtimemanager.cpp index 8ba08841..a5f5b810 100644 --- a/tests/auto/timemanager/testtimemanager.cpp +++ b/tests/auto/timemanager/testtimemanager.cpp @@ -1776,8 +1776,7 @@ void TestTimeManager::testEventItemStates_data() QTest::newRow("TimeEvent 08:01 | state false | not trigger") << QDateTime(QDate::currentDate(), QTime(8,1)) << true << false; QTest::newRow("TimeEvent 08:30 | state true | not trigger") << QDateTime(QDate::currentDate(), QTime(8,30)) << true << false; QTest::newRow("TimeEvent 09:00 | state true | trigger") << QDateTime(QDate::currentDate(), QTime(9,0)) << true << true; - - + QTest::newRow("TimeEvent 09:01 | state true | not trigger") << QDateTime(QDate::currentDate(), QTime(9,1)) << true << false; } void TestTimeManager::testEventItemStates()