-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "[im/test] Fix interaction model subscription test (#9677)"
This reverts commit b4d7eb3.
- Loading branch information
1 parent
31e2695
commit 4bff0cf
Showing
16 changed files
with
337 additions
and
1,230 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
examples/chip-tool/templates/partials/process_response_value.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{{#chip_tests_item_response_parameters}} | ||
{{#if hasExpectedValue}} | ||
{{#if isList}} | ||
if (count != {{expectedValue.length}}) | ||
{ | ||
ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "{{expectedValue}}"); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{else}} | ||
{{#if (isString type)}} | ||
{{chipType}} {{asLowerCamelCase name}}Argument = chip::ByteSpan(chip::Uint8::from_const_char("{{expectedValue}}"), strlen("{{expectedValue}}")); | ||
if (!{{asLowerCamelCase name}}.data_equal({{asLowerCamelCase name}}Argument)) | ||
{{else}} | ||
if ({{asLowerCamelCase name}} != {{expectedValue}}{{asTypeLiteralSuffix chipType}}) | ||
{{/if}} | ||
{ | ||
ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "{{expectedValue}}"); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
{{/if}} | ||
{{#if hasExpectedConstraints}} | ||
{{#if expectedConstraints.type}} | ||
ChipLogError(chipTool, "Warning: {{asLowerCamelCase name}} type checking is not implemented yet. Expected type: '%s'", "{{expectedConstraints.type}}"); | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.format}} | ||
ChipLogError(chipTool, "Warning: {{asLowerCamelCase name}} format checking is not implemented yet. Expected format: '%s'", "{{expectedConstraints.format}}"); | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.minLength}} | ||
if ({{asLowerCamelCase name}}.size() < {{expectedConstraints.minLength}}) | ||
{ | ||
ChipLogError(chipTool, "Error: {{asLowerCamelCase name}} is too short. Min size is {{expectedConstraints.minLength}} but got '%zu'", {{asLowerCamelCase name}}.size()); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.maxLength}} | ||
if ({{asLowerCamelCase name}}.size() > {{expectedConstraints.maxLength}}) | ||
{ | ||
ChipLogError(chipTool, "Error: {{asLowerCamelCase name}} is too long. Max size is {{expectedConstraints.maxLength}} but got '%zu'", {{asLowerCamelCase name}}.size()); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.minValue}} | ||
if ({{asLowerCamelCase name}} < {{expectedConstraints.minValue}}) | ||
{ | ||
ChipLogError(chipTool, "Error: {{asLowerCamelCase name}} is lower than expected. Min value is {{expectedConstraints.minValue}} but got '%d'", {{asLowerCamelCase name}}); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.maxValue}} | ||
if ({{asLowerCamelCase name}} > {{expectedConstraints.maxValue}}) | ||
{ | ||
ChipLogError(chipTool, "Error: {{asLowerCamelCase name}} is higher than expected. Max value is {{expectedConstraints.maxValue}} but got '%d'", {{asLowerCamelCase name}}); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.notValue}} | ||
if ({{asLowerCamelCase name}} == {{expectedConstraints.notValue}}) | ||
{ | ||
ChipLogError(chipTool, "Error: {{asLowerCamelCase name}} was not expected to be '{{expectedConstraints.notValue}}' due to notValue constraint"); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
{{/if}} | ||
{{/chip_tests_item_response_parameters}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
examples/chip-tool/templates/partials/testsuite/WaitForAttributeReport.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// The callback should be called atleast once | ||
{{#chip_tests_WaitForAttributeReport_attribute_info}} | ||
using OnReportCallback_{{parent.index}} = void (*)(void * context{{#chip_tests_item_response_parameters}}, {{#if isList}}uint16_t count, {{/if}}{{chipType}} {{#if isList}}* {{/if}}{{asLowerCamelCase name}}{{/chip_tests_item_response_parameters}}); | ||
chip::Callback::Callback<OnReportCallback_{{ parent.index }}> mOnReportCallback_{{parent.index}} { SubscribeAttribute_{{ parent.index }}_OnReportCallback, this }; | ||
{{/chip_tests_WaitForAttributeReport_attribute_info}} | ||
|
||
bool mReceivedReport_{{index}} = false; | ||
|
||
CHIP_ERROR TestSendCluster{{asUpperCamelCase cluster}}Command{{asUpperCamelCase command}}_{{index}}() | ||
{ | ||
ChipLogProgress(chipTool, "{{cluster}} - {{asUpperCamelCase command}} - {{label}}"); | ||
{{#chip_tests_WaitForAttributeReport_attribute_info}} | ||
chip::Controller::{{asUpperCamelCase cluster}}Cluster cluster; | ||
cluster.Associate(mDevice, {{endpoint}}); | ||
return cluster.ReportAttribute{{asUpperCamelCase attribute}}(mOnReportCallback_{{parent.index}}.Cancel()); | ||
{{/chip_tests_WaitForAttributeReport_attribute_info}} | ||
} | ||
|
||
{{#chip_tests_WaitForAttributeReport_attribute_info}} | ||
static void SubscribeAttribute_{{ parent.index }}_OnReportCallback(void * context{{#chip_tests_item_response_parameters}}, {{#if isList}}uint16_t count, {{/if}}{{chipType}} {{#if isList}}* {{/if}}{{asLowerCamelCase name}}{{/chip_tests_item_response_parameters}}) | ||
{ | ||
ChipLogProgress(chipTool, "On/Off - Subscribe {{asUpperCamelCase attribute}} Attribute: Report Data"); | ||
{{parent.parent.filename}} * runner = reinterpret_cast<{{parent.parent.filename}} *>(context); | ||
|
||
if (runner->mReceivedReport_{{parent.index}}) | ||
{ | ||
// Receiving attribute more than once is not an issue, since the following handler will override previous handlers. | ||
return; | ||
} | ||
|
||
{{> process_response_value}} | ||
|
||
runner->mReceivedReport_{{parent.index}} = true; | ||
ChipLogProgress(chipTool, "On/Off - report received."); | ||
runner->NextTest(); | ||
} | ||
|
||
{{/chip_tests_WaitForAttributeReport_attribute_info}} |
6 changes: 6 additions & 0 deletions
6
examples/chip-tool/templates/partials/testsuite/WaitForMs.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CHIP_ERROR TestSendCluster{{asUpperCamelCase cluster}}Command{{asUpperCamelCase command}}_{{index}}() | ||
{ | ||
ChipLogProgress(chipTool, "{{cluster}} - {{asUpperCamelCase command}} - {{label}}"); | ||
|
||
return {{command}}({{#chip_tests_item_parameters}}{{#not_first}}, {{/not_first}}{{definedValue}}{{/chip_tests_item_parameters}}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.