Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] Add tests to TestCluster.yaml for unsupported attributes, long octet string and lists. #7741

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"featureLevel": 35,
"featureLevel": 39,
"creator": "zap",
"keyValuePairs": [
{
Expand Down Expand Up @@ -12309,6 +12309,21 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "long_octet_string",
"code": 29,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "cluster revision",
"code": 65533,
Expand Down Expand Up @@ -15539,4 +15554,4 @@
}
],
"log": []
}
}
132 changes: 122 additions & 10 deletions examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h

Large diffs are not rendered by default.

140 changes: 140 additions & 0 deletions examples/chip-tool/commands/clusters/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -15358,6 +15358,8 @@ class ReadTemperatureMeasurementClusterRevision : public ModelCommand
| * ListInt8u | 0x001A |
| * ListOctetString | 0x001B |
| * ListStructOctetString | 0x001C |
| * LongOctetString | 0x001D |
| * Unsupported | 0x00FF |
| * ClusterRevision | 0xFFFD |
\*----------------------------------------------------------------------------*/

Expand Down Expand Up @@ -16684,6 +16686,140 @@ class ReadTestClusterListStructOctetString : public ModelCommand
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
};

/*
* Attribute LongOctetString
*/
class ReadTestClusterLongOctetString : public ModelCommand
{
public:
ReadTestClusterLongOctetString() : ModelCommand("read")
{
AddArgument("attr-name", "long-octet-string");
ModelCommand::AddArguments();
}

~ReadTestClusterLongOctetString()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x050F) command (0x00) on endpoint %" PRIu16, endpointId);

chip::Controller::TestClusterCluster cluster;
cluster.Associate(device, endpointId);
return cluster.ReadAttributeLongOctetString(onSuccessCallback->Cancel(), onFailureCallback->Cancel());
}

private:
chip::Callback::Callback<StringAttributeCallback> * onSuccessCallback =
new chip::Callback::Callback<StringAttributeCallback>(OnStringAttributeResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
};

class WriteTestClusterLongOctetString : public ModelCommand
{
public:
WriteTestClusterLongOctetString() : ModelCommand("write")
{
AddArgument("attr-name", "long-octet-string");
AddArgument("attr-value", &mValue);
ModelCommand::AddArguments();
}

~WriteTestClusterLongOctetString()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x050F) command (0x01) on endpoint %" PRIu16, endpointId);

chip::Controller::TestClusterCluster cluster;
cluster.Associate(device, endpointId);
return cluster.WriteAttributeLongOctetString(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mValue);
}

private:
chip::Callback::Callback<DefaultSuccessCallback> * onSuccessCallback =
new chip::Callback::Callback<DefaultSuccessCallback>(OnDefaultSuccessResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
chip::ByteSpan mValue;
};

/*
* Attribute Unsupported
*/
class ReadTestClusterUnsupported : public ModelCommand
{
public:
ReadTestClusterUnsupported() : ModelCommand("read")
{
AddArgument("attr-name", "unsupported");
ModelCommand::AddArguments();
}

~ReadTestClusterUnsupported()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x050F) command (0x00) on endpoint %" PRIu16, endpointId);

chip::Controller::TestClusterCluster cluster;
cluster.Associate(device, endpointId);
return cluster.ReadAttributeUnsupported(onSuccessCallback->Cancel(), onFailureCallback->Cancel());
}

private:
chip::Callback::Callback<BooleanAttributeCallback> * onSuccessCallback =
new chip::Callback::Callback<BooleanAttributeCallback>(OnBooleanAttributeResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
};

class WriteTestClusterUnsupported : public ModelCommand
{
public:
WriteTestClusterUnsupported() : ModelCommand("write")
{
AddArgument("attr-name", "unsupported");
AddArgument("attr-value", 0, UINT8_MAX, &mValue);
ModelCommand::AddArguments();
}

~WriteTestClusterUnsupported()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x050F) command (0x01) on endpoint %" PRIu16, endpointId);

chip::Controller::TestClusterCluster cluster;
cluster.Associate(device, endpointId);
return cluster.WriteAttributeUnsupported(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mValue);
}

private:
chip::Callback::Callback<DefaultSuccessCallback> * onSuccessCallback =
new chip::Callback::Callback<DefaultSuccessCallback>(OnDefaultSuccessResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
uint8_t mValue;
};

/*
* Attribute ClusterRevision
*/
Expand Down Expand Up @@ -21178,6 +21314,10 @@ void registerClusterTestCluster(Commands & commands)
make_unique<ReadTestClusterListInt8u>(),
make_unique<ReadTestClusterListOctetString>(),
make_unique<ReadTestClusterListStructOctetString>(),
make_unique<ReadTestClusterLongOctetString>(),
make_unique<WriteTestClusterLongOctetString>(),
make_unique<ReadTestClusterUnsupported>(),
make_unique<WriteTestClusterUnsupported>(),
make_unique<ReadTestClusterClusterRevision>(),
};

Expand Down
Loading