Skip to content

Commit

Permalink
Add more attributes tests to TestCluster.yaml (#7711)
Browse files Browse the repository at this point in the history
* Add additional attributes tests to TestCluster.yaml

* Update templates to support testing TestCluster attributes that has been activated

* Update gen/ folders
  • Loading branch information
vivien-apple authored and pull[bot] committed Sep 3, 2021
1 parent abbd977 commit 1646cc5
Show file tree
Hide file tree
Showing 8 changed files with 8,930 additions and 128 deletions.
6,722 changes: 6,696 additions & 26 deletions examples/chip-tool/commands/tests/Commands.h

Large diffs are not rendered by default.

25 changes: 22 additions & 3 deletions examples/chip-tool/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,25 @@ class {{filename}}: public TestCommand
CHIP_ERROR err = CHIP_NO_ERROR;

{{#if isCommand}}
err = cluster.{{asCamelCased command false}}(mOnSuccessCallback_{{index}}->Cancel(), mOnFailureCallback_{{index}}->Cancel(){{#chip_tests_item_parameters}}, {{definedValue}}{{/chip_tests_item_parameters}});
{{#chip_tests_item_parameters}}
{{#if (isString type)}}
{{chipType}} {{asCamelCased name true}}Argument = chip::ByteSpan(chip::Uint8::from_const_char("{{definedValue}}"), strlen("{{definedValue}}"));
{{else}}
{{chipType}} {{asCamelCased name true}}Argument = {{definedValue}}{{#if (isStrEqual chipType "int64_t")}}LL{{else if (isStrEqual chipType "uint64_t")}}ULL{{/if}};
{{/if}}
{{/chip_tests_item_parameters}}
err = cluster.{{asCamelCased command false}}(mOnSuccessCallback_{{index}}->Cancel(), mOnFailureCallback_{{index}}->Cancel(){{#chip_tests_item_parameters}}, {{asCamelCased name true}}Argument{{/chip_tests_item_parameters}});
{{else if isReadAttribute}}
err = cluster.ReadAttribute{{asCamelCased attribute false}}(mOnSuccessCallback_{{index}}->Cancel(), mOnFailureCallback_{{index}}->Cancel());
{{else if isWriteAttribute}}
err = cluster.WriteAttribute{{asCamelCased attribute false}}(mOnSuccessCallback_{{index}}->Cancel(), mOnFailureCallback_{{index}}->Cancel(), {{#chip_tests_item_parameters}}{{definedValue}}{{/chip_tests_item_parameters}});
{{#chip_tests_item_parameters}}
{{#if (isString type)}}
{{chipType}} {{asCamelCased name true}}Argument = chip::ByteSpan(chip::Uint8::from_const_char("{{definedValue}}"), strlen("{{definedValue}}"));
{{else}}
{{chipType}} {{asCamelCased name true}}Argument = {{definedValue}}{{#if (isStrEqual chipType "int64_t")}}LL{{else if (isStrEqual chipType "uint64_t")}}ULL{{/if}};
{{/if}}
{{/chip_tests_item_parameters}}
err = cluster.WriteAttribute{{asCamelCased attribute false}}(mOnSuccessCallback_{{index}}->Cancel(), mOnFailureCallback_{{index}}->Cancel(), {{#chip_tests_item_parameters}}{{asCamelCased name true}}Argument{{/chip_tests_item_parameters}});
{{else}}
err = CHIP_ERROR_NOT_IMPLEMENTED;
{{/if}}
Expand Down Expand Up @@ -120,7 +134,12 @@ class {{filename}}: public TestCommand

{{#chip_tests_item_response_parameters}}
{{#if hasExpectedValue}}
if ({{asCamelCased name true}} != {{expectedValue}})
{{#if (isString type)}}
{{chipType}} {{asCamelCased name true}}Argument = chip::ByteSpan(chip::Uint8::from_const_char("{{expectedValue}}"), strlen("{{expectedValue}}"));
if (!{{asCamelCased name true}}.data_equal({{asCamelCased name true}}Argument))
{{else}}
if ({{asCamelCased name true}} != {{expectedValue}}{{#if (isStrEqual chipType "int64_t")}}LL{{else if (isStrEqual chipType "uint64_t")}}ULL{{/if}})
{{/if}}
{
ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "{{expectedValue}}");
runner->SetCommandExitStatus(false);
Expand Down
Loading

0 comments on commit 1646cc5

Please sign in to comment.