Skip to content

Commit

Permalink
[chip-tool-darwin] Enable TestConfigVariables (#18242)
Browse files Browse the repository at this point in the history
* [chip-tool-darwin] Enable TestConfigVariables

* Update codegen
  • Loading branch information
vivien-apple authored and pull[bot] committed Feb 13, 2024
1 parent 4e4d507 commit dd39f45
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
{{~#if (chip_tests_variables_has expected)}}{{expected}}
{{~else if (isOctetString type)}}[[NSData alloc] initWithBytes:"{{octetStringEscapedForCLiteral expected}}" length:{{expected.length}}]
{{~else if (isCharString type)}}@"{{expected}}"
{{else if (chip_tests_config_has expected)}}m{{asUpperCamelCase expected}}.HasValue() ? m{{asUpperCamelCase expected}}.Value() : {{asTypedLiteral (chip_tests_config_get_default_value expected) (chip_tests_config_get_type expected)}}
{{~else}}{{asTypedExpressionFromObjectiveC expected type}}
{{~/if}}));
{{/if_is_struct}}
Expand Down
34 changes: 23 additions & 11 deletions examples/chip-tool-darwin/templates/tests/partials/test_value.zapt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{{#if (chip_tests_config_has definedValue)}}
{{! Just replace the value's name with the actual value in the rest of the processing~}}
{{>test_value target=target definedValue=(chip_tests_config_get_default_value definedValue) cluster=cluster depth=depth}}
{{else if isOptional}}
{{#if isOptional}}
{{! Just go ahead and assign to the value, stripping the optionality bit off. }}
{{>test_value target=target definedValue=definedValue cluster=cluster isOptional=false depth=(incrementDepth depth)}}
{{else if isNullable}}
Expand Down Expand Up @@ -31,13 +28,28 @@
{{/if_include_struct_item_value}}
{{/zcl_struct_items_by_struct_name}}

{{else if (chip_tests_variables_has definedValue)}}
{{target}} = [{{definedValue}} copy];
{{else if (isCharString type)}}
{{target}} = @"{{definedValue}}";
{{else if (isOctetString type)}}
{{target}} = [[NSData alloc] initWithBytes:"{{octetStringEscapedForCLiteral definedValue}}" length:{{definedValue.length}}];
{{else}}
{{target}} = [NSNumber numberWith{{asObjectiveCNumberType definedValue type false}}:{{asTypedExpressionFromObjectiveC definedValue type}}];
{{target}} =
{{#if (chip_tests_variables_has definedValue)}}
[{{definedValue}} copy];
{{else if (chip_tests_config_has definedValue)}}
m{{asUpperCamelCase definedValue}}.HasValue() ?
{{#if (isCharString type)}}
m{{asUpperCamelCase definedValue}}.Value() : @"{{chip_tests_config_get_default_value definedValue}}";
{{else if (isOctetString type)}}
{{!-- TODO Extract the length of the default value for ByteSpan--}}
{{else}}
[NSNumber numberWith{{asObjectiveCNumberType definedValue type false}}:m{{asUpperCamelCase definedValue}}.Value()] :
[NSNumber numberWith{{asObjectiveCNumberType definedValue type false}}:{{asTypedExpressionFromObjectiveC (chip_tests_config_get_default_value definedValue) type}}];
{{/if}}
{{else}}
{{#if (isCharString type)}}
@"{{definedValue}}";
{{else if (isOctetString type)}}
[[NSData alloc] initWithBytes:"{{octetStringEscapedForCLiteral definedValue}}" length:{{definedValue.length}}];
{{else}}
[NSNumber numberWith{{asObjectiveCNumberType definedValue type false}}:{{asTypedExpressionFromObjectiveC definedValue type}}];
{{/if}}
{{/if}}
{{/if_is_struct}}
{{/if}}
3 changes: 0 additions & 3 deletions examples/chip-tool-darwin/templates/tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ function getTests() {
// TODO: TestDiscovery needs FindCommissionable
tests.disable('TestDiscovery');

// TODO: TestConfigVariables not supported properly in codegen yet.
tests.disable('TestConfigVariables');

// TODO: TestGroupMessaging does not work on Darwin for now.
tests.disable('TestGroupMessaging');

Expand Down
167 changes: 166 additions & 1 deletion zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dd39f45

Please sign in to comment.