Skip to content

Commit

Permalink
[YAML] Add saveAs keyword for response fields and command arguments (#…
Browse files Browse the repository at this point in the history
…11798)

* Add src/app/tests/suites/TestSaveAs.yaml

* [YAML] Add saveAs keyword for response fields and command arguments

* Add saveAs keyword support for objective C

* Reset TestCluster INT32U to default at the end of TestConstraints.yaml

* Update generated content
  • Loading branch information
vivien-apple authored and pull[bot] committed May 25, 2022
1 parent e966e4c commit e0a30eb
Show file tree
Hide file tree
Showing 17 changed files with 6,789 additions and 166 deletions.
9 changes: 8 additions & 1 deletion examples/chip-tool/commands/tests/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,14 @@ class TestCommand : public CHIPCommand
{
if (current == expected)
{
Exit(std::string(itemName) + " value == notValue: " + std::to_string(current) + " == " + std::to_string(expected));
if (std::is_same<T, const chip::Span<const uint8_t>>::value || std::is_same<T, const chip::Span<const char>>::value)
{
Exit(std::string(itemName) + " value == notValue");
}
else
{
Exit(std::string(itemName) + " value == notValue: " + std::to_string(current) + " == " + std::to_string(expected));
}
return false;
}

Expand Down
12 changes: 12 additions & 0 deletions examples/chip-tool/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class {{filename}}: public TestCommand
std::atomic_uint16_t mTestIndex;
const uint16_t mTestCount = {{totalTests}};

{{#chip_tests_items}}
{{#chip_tests_item_response_parameters}}
{{#if saveAs}}
{{chipType}} {{saveAs}};
{{/if}}
{{/chip_tests_item_response_parameters}}
{{/chip_tests_items}}

{{#*inline "failureCallback"}}mOnFailureCallback_{{index}}{{/inline}}
{{#*inline "successCallback"}}mOnSuccessCallback_{{index}}{{/inline}}
{{#*inline "failureResponse"}}OnFailureCallback_{{index}}{{/inline}}
Expand Down Expand Up @@ -231,6 +239,10 @@ class {{filename}}: public TestCommand
{{~#if expectedConstraints.maxValue}}VerifyOrReturn(CheckConstraintMaxValue<{{chipType}}>("{{>item}}", {{>item}}, {{expectedConstraints.maxValue}}));{{/if}}
{{~#if expectedConstraints.notValue}}VerifyOrReturn(CheckConstraintNotValue<{{chipType}}>("{{>item}}", {{>item}}, {{expectedConstraints.notValue}}));{{/if}}
{{/if}}

{{#if saveAs}}
{{saveAs}} = {{>item}};
{{/if}}
{{/chip_tests_item_response_parameters}}
{{#unless async}}NextTest();{{/unless}}
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{{#if_is_bitmap type}}
static_cast<{{zapTypeToEncodableClusterObjectType type ns=ns}}>({{definedValue}});
{{else}}
{{definedValue}}{{asTypeLiteralSuffix type}};
{{asTypeLiteralSuffix definedValue type}};
{{/if_is_bitmap}}
{{/if_chip_enum}}
{{/if_is_struct}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
VerifyOrReturn(CheckValue
{{~#if (isOctetString type)}}AsString("{{label}}", {{actual}}, chip::ByteSpan(chip::Uint8::from_const_char("{{octetStringEscapedForCLiteral expected}}"), {{expected.length}}))
{{else if (isCharString type)}}AsString("{{label}}", {{actual}}, chip::CharSpan("{{expected}}", {{expected.length}}))
{{else}}<{{chipType}}>("{{label}}", {{actual}}, {{expected}}{{asTypeLiteralSuffix type}})
{{else}}<{{chipType}}>("{{label}}", {{actual}}, {{asTypeLiteralSuffix expected type}})
{{/if}}
);
{{/if_is_struct}}
Expand Down
1 change: 1 addition & 0 deletions examples/chip-tool/templates/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ function getTests()
'TestConstraints',
'TestDelayCommands',
'TestLogCommands',
'TestSaveAs',
'TestDescriptorCluster',
'TestBasicInformation',
'TestIdentifyCluster',
Expand Down
6 changes: 6 additions & 0 deletions src/app/tests/suites/TestConstraints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ tests:
response:
constraints:
notValue: 6

- label: "Write attribute INT32U Value Back to Default Value"
command: "writeAttribute"
attribute: "int32u"
arguments:
value: 0
Loading

0 comments on commit e0a30eb

Please sign in to comment.