Skip to content

Commit

Permalink
Merge c75fadd into 3c8d272
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored Feb 2, 2022
2 parents 3c8d272 + c75fadd commit 1028830
Show file tree
Hide file tree
Showing 12 changed files with 2,633 additions and 76 deletions.
1 change: 1 addition & 0 deletions examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static_library("chip-tool-utils") {

public_deps = [
"${chip_root}/src/app/server",
"${chip_root}/src/app/tests/suites/commands/discovery",
"${chip_root}/src/app/tests/suites/commands/log",
"${chip_root}/src/app/tests/suites/commands/system",
"${chip_root}/src/app/tests/suites/pics",
Expand Down
1 change: 1 addition & 0 deletions examples/chip-tool/commands/tests/TestCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CHIP_ERROR TestCommand::RunCommand()

CHIP_ERROR TestCommand::WaitForCommissionee()
{
CurrentCommissioner().ReleaseOperationalDevice(mNodeId);
return CurrentCommissioner().GetConnectedDevice(mNodeId, &mOnDeviceConnectedCallback, &mOnDeviceConnectionFailureCallback);
}

Expand Down
2 changes: 2 additions & 0 deletions examples/chip-tool/commands/tests/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include "../common/CHIPCommand.h"
#include <app/tests/suites/commands/discovery/DiscoveryCommands.h>
#include <app/tests/suites/commands/log/LogCommands.h>
#include <app/tests/suites/commands/system/SystemCommands.h>
#include <app/tests/suites/include/ConstraintsChecker.h>
Expand All @@ -34,6 +35,7 @@ class TestCommand : public CHIPCommand,
public ConstraintsChecker,
public PICSChecker,
public LogCommands,
public DiscoveryCommands,
public SystemCommands
{
public:
Expand Down
59 changes: 58 additions & 1 deletion examples/chip-tool/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,57 @@ class {{filename}}: public TestCommand
{{/chip_tests_item_response_parameters}}
{{/chip_tests_items}}

void OnDiscoveryCommandsResults(const DiscoveryCommandResult & nodeData) override
{
bool isExpectedDnssdResult = false;
{{#chip_tests_items}}
{{#if (isStrEqual cluster "DiscoveryCommands")}}
if ((mTestIndex - 1) == {{index}})
{
isExpectedDnssdResult = true;
{{#chip_tests_item_response_parameters}}
{{#*inline "itemValue"}}nodeData.{{name}}{{#if isOptional}}.Value(){{/if}}{{/inline}}
{{~#if hasExpectedValue}}
{{#if isOptional}}VerifyOrReturn(CheckValuePresent("{{name}}", nodeData.{{name}}));{{/if}}
VerifyOrReturn(CheckValue("{{name}}", {{>itemValue}},
{{#if (chip_tests_config_has expectedValue)}}
m{{asUpperCamelCase expectedValue}}.HasValue() ? m{{asUpperCamelCase expectedValue}}.Value() : {{asTypedLiteral (chip_tests_config_get_default_value expectedValue) (chip_tests_config_get_type expectedValue)}}
{{else}}
{{expectedValue}}
{{/if}}
));
{{/if}}
{{#if hasExpectedConstraints}}
{{#if isOptional}}VerifyOrReturn(CheckValuePresent("{{name}}", nodeData.{{name}}));{{/if}}
{{#if (hasProperty expectedConstraints "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{name}}", {{>itemValue}}.size(), {{expectedConstraints.minLength}}));{{/if}}
{{#if (hasProperty expectedConstraints "maxLength")}}VerifyOrReturn(CheckConstraintMaxLength("{{name}}", {{>itemValue}}.size(), {{expectedConstraints.maxLength}}));{{/if}}
{{#if (hasProperty expectedConstraints "minValue")}}VerifyOrReturn(CheckConstraintMinValue<{{chipType}}>("{{name}}", {{>itemValue}}, {{asTypedLiteral expectedConstraints.minValue type}}));{{/if}}
{{#if (hasProperty expectedConstraints "maxValue")}}VerifyOrReturn(CheckConstraintMaxValue<{{chipType}}>("{{name}}", {{>itemValue}}, {{asTypedLiteral expectedConstraints.maxValue type}}));{{/if}}
{{#if (hasProperty expectedConstraints "notValue")}}VerifyOrReturn(CheckConstraintNotValue("{{name}}", {{>itemValue}}, {{asTypedLiteral expectedConstraints.notValue type}}));{{/if}}
{{/if}}

{{#if saveAs}}
{{#if (isString type)}}
if ({{saveAs}}Buffer != nullptr)
{
chip::Platform::MemoryFree({{saveAs}}Buffer);
}
{{saveAs}}Buffer = static_cast<{{#if (isOctetString type)}}uint8_t{{else}}char{{/if}} *>(chip::Platform::MemoryAlloc({{>itemValue}}.size()));
memcpy({{saveAs}}Buffer, {{>itemValue}}.data(), {{>itemValue}}.size());
{{saveAs}} = {{chipType}}({{saveAs}}Buffer, {{>itemValue}}.size());
{{else}}
{{saveAs}} = {{>itemValue}};
{{/if}}
{{/if}}
{{/chip_tests_item_response_parameters}}
}
{{/if}}
{{/chip_tests_items}}

VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received"));
NextTest();
}

{{! Helper around zapTypeToDecodableClusterObjectType that lets us set the
array/nullable/etc context appropriately.}}
{{~#*inline "subscribeResponseDataArgument"~}}
Expand Down Expand Up @@ -190,7 +241,13 @@ class {{filename}}: public TestCommand
CHIP_ERROR {{>testCommand}}()
{
SetIdentity(kIdentity{{asUpperCamelCase identity}});
return {{command}}({{#chip_tests_item_parameters}}{{#not_first}}, {{/not_first}}{{#if (isString type)}}"{{/if}}{{definedValue}}{{#if (isString type)}}"{{/if}}{{/chip_tests_item_parameters}});
return {{command}}({{#chip_tests_item_parameters}}{{#not_first}}, {{/not_first}}{{#if (isString type)}}"{{/if~}}
{{~#if (chip_tests_config_has definedValue)~}}
m{{asUpperCamelCase definedValue}}.HasValue() ? m{{asUpperCamelCase definedValue}}.Value() : {{asTypedLiteral (chip_tests_config_get_default_value definedValue) (chip_tests_config_get_type definedValue)}}
{{else}}
{{definedValue}}
{{~/if~}}
{{~#if (isString type)}}"{{/if}}{{/chip_tests_item_parameters}});
}
{{else if isWait}}
CHIP_ERROR {{>testCommand}}()
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 @@ -226,6 +226,7 @@ function getTests()
'TestClusterComplexTypes',
'TestConstraints',
'TestDelayCommands',
'TestDiscovery',
'TestLogCommands',
'TestSaveAs',
'TestConfigVariables',
Expand Down
Loading

0 comments on commit 1028830

Please sign in to comment.