Skip to content

Commit

Permalink
[TestCluster] Add a test for a command that takes a single optional a…
Browse files Browse the repository at this point in the history
…rgument (#12474)

* [TestCluster] Add a test for a command that takes a single optional argument

* Update generated code
  • Loading branch information
vivien-apple authored and pull[bot] committed Jan 25, 2022
1 parent a8646d2 commit 1155008
Show file tree
Hide file tree
Showing 25 changed files with 454 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15357,6 +15357,14 @@
"source": "client",
"incoming": 1,
"outgoing": 0
},
{
"name": "TestSimpleOptionalArgumentRequest",
"code": 19,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
}
],
"attributes": [
Expand Down
10 changes: 10 additions & 0 deletions src/app/clusters/test-cluster-server/test-cluster-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,16 @@ bool emberAfTestClusterClusterTimedInvokeRequestCallback(CommandHandler * comman
return true;
}

bool emberAfTestClusterClusterTestSimpleOptionalArgumentRequestCallback(
CommandHandler * commandObj, const ConcreteCommandPath & commandPath,
const Commands::TestSimpleOptionalArgumentRequest::DecodableType & commandData)
{
Protocols::InteractionModel::Status status = commandData.arg1.HasValue() ? Protocols::InteractionModel::Status::Success
: Protocols::InteractionModel::Status::InvalidValue;
commandObj->AddStatus(commandPath, status);
return true;
}

// -----------------------------------------------------------------------------
// Plugin initialization

Expand Down
15 changes: 15 additions & 0 deletions src/app/tests/suites/TestCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2360,3 +2360,18 @@ tests:
response:
# SDK returning wrong error code here so far.
errorWrongValue: UNSUPPORTED_CLUSTER

# Tests for command with optional arguments
- label:
"Send a command that takes an optional parameter but do not set it."
command: "TestSimpleOptionalArgumentRequest"
response:
error: INVALID_VALUE

- label:
"Send a command that takes an optional parameter but do not set it."
command: "TestSimpleOptionalArgumentRequest"
arguments:
values:
- name: "arg1"
value: 1
7 changes: 7 additions & 0 deletions src/app/zap-templates/zcl/data-model/chip/test-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,13 @@ limitations under the License.
</description>
</command>

<command source="client" code="0x13" name="TestSimpleOptionalArgumentRequest" optional="false">
<description>
Command that takes an optional argument which is bool. It responds with a success value if the optional is set to any value.
</description>
<arg name="arg1" type="BOOLEAN" optional="true"/>
</command>

<command source="server" code="0x00" name="TestSpecificResponse" optional="false" disableDefaultResponse="true">
<description>
Simple response for TestWithResponse with a simple return value
Expand Down
10 changes: 9 additions & 1 deletion src/controller/data_model/controller-clusters.zap
Original file line number Diff line number Diff line change
Expand Up @@ -11623,6 +11623,14 @@
"source": "client",
"incoming": 0,
"outgoing": 1
},
{
"name": "TestSimpleOptionalArgumentRequest",
"code": 19,
"mfgCode": null,
"source": "client",
"incoming": 0,
"outgoing": 1
}
],
"attributes": [
Expand Down Expand Up @@ -13264,4 +13272,4 @@
}
],
"log": []
}
}
40 changes: 40 additions & 0 deletions src/controller/java/zap-generated/CHIPClusters-JNI.cpp

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

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

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

7 changes: 7 additions & 0 deletions src/controller/python/chip/clusters/CHIPClusters.py

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

16 changes: 16 additions & 0 deletions src/controller/python/chip/clusters/Objects.py

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

3 changes: 3 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h

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

25 changes: 25 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm

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

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

11 changes: 11 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm

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

46 changes: 46 additions & 0 deletions src/darwin/Framework/CHIPTests/CHIPClustersTests.m

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

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

6 changes: 6 additions & 0 deletions zzz_generated/app-common/app-common/zap-generated/callback.h

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

Loading

0 comments on commit 1155008

Please sign in to comment.