-
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.
Switch yaml tests to use ClusterBase::WriteAttribute for attribute wr…
…ite. (#11460) The changes to test_cluster.zapt are the actual change we care about. The change to WriteClient.h is to fix a pre-existing bug: it calls Encode() without including all the headers that declare various signatures of Encode(). The change to ClusterTestGeneration.js fixes a bug with the signature of the success callback for writes: it had an extra arg with the type of the attribute, whereas it should have no arg at all. The change to CHIPClusters-src.zapt is to instantiate WriteAttribute for all the non-writable attributes when compiling tests, because we actually issue writes for those non-writable attributes (and test that they fail). The change to controller/data_model/BUILD.gn is because the Android compiler in CI blows up trying to compile CHIPClustersTestWrite.cpp.
- Loading branch information
1 parent
e55fbd9
commit b648482
Showing
10 changed files
with
2,696 additions
and
1,560 deletions.
There are no files selected for viewing
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
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
50 changes: 50 additions & 0 deletions
50
src/app/zap-templates/templates/app/tests/CHIPClustersWrite-src.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,50 @@ | ||
{{#if (chip_has_client_clusters)}} | ||
{{> header}} | ||
|
||
#include <zap-generated/tests/CHIPClustersTest.h> | ||
|
||
#include <app-common/zap-generated/cluster-objects.h> | ||
|
||
namespace chip { | ||
namespace Controller { | ||
|
||
{{#chip_client_clusters}} | ||
|
||
{{#chip_server_cluster_attributes}} | ||
{{#unless isWritableAttribute}} | ||
{{#*inline "attributeTypeInfo"}}chip::app::Clusters::{{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::TypeInfo{{/inline}} | ||
template CHIP_ERROR ClusterBase::WriteAttribute<{{>attributeTypeInfo}}>(const {{>attributeTypeInfo}}::Type & requestData, void *context, | ||
WriteResponseSuccessCallback successCb, WriteResponseFailureCallback failureCb); | ||
{{/unless}} | ||
{{/chip_server_cluster_attributes}} | ||
{{/chip_client_clusters}} | ||
|
||
template <typename AttributeInfo> | ||
CHIP_ERROR ClusterBase::WriteAttribute(const typename AttributeInfo::Type & requestData, void * context, | ||
WriteResponseSuccessCallback successCb, WriteResponseFailureCallback failureCb) | ||
{ | ||
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); | ||
ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); | ||
|
||
auto onSuccessCb = [context, successCb](const app::ConcreteAttributePath & commandPath) { | ||
if (successCb != nullptr) | ||
{ | ||
successCb(context); | ||
} | ||
}; | ||
|
||
auto onFailureCb = [context, failureCb](const app::ConcreteAttributePath * commandPath, app::StatusIB status, | ||
CHIP_ERROR aError) { | ||
if (failureCb != nullptr) | ||
{ | ||
failureCb(context, app::ToEmberAfStatus(status.mStatus)); | ||
} | ||
}; | ||
|
||
return chip::Controller::WriteAttribute<AttributeInfo>(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), | ||
mEndpoint, requestData, onSuccessCb, onFailureCb); | ||
} | ||
|
||
} // namespace Controller | ||
} // namespace chip | ||
{{/if}} |
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.