Skip to content

Commit

Permalink
Adding tests for Matter custom xml support (project-chip#1389)
Browse files Browse the repository at this point in the history
Added tests for Matter custom xml support for the following use cases:

- loads a file with a custom cluster and an extension of a cluster and checks it
- loads a second file with a further extension of the extended cluster and checks it
- tests generation with custom xml
- loading bad custom xml -> throw warning
- Add 2 custom files with manufacturer name/code and attribute code collisions -> throw error.
    * This should be an SQL error, it is currently broken and should be fixed in PR Adding constraints to the database       tables to avoid redundant entries project-chip#1352 is merged.
- test generation after deleting the custom xml
     * This doesn't work as expected - project-chip#1387
- Add custom xml, make changes, delete, add again -> make sure that generated content has new edits
      * Effected by project-chip#1387 and project-chip#1391
- Loading zap file with custom xml that does not exist - throw error
- Loading zap file with custom xml and generating

Once PR project-chip#1352 is merged and project-chip#1387 and project-chip#1391 are resolved - tests should be updated appropriately.
  • Loading branch information
dhchandw authored Aug 6, 2024
1 parent f8d2523 commit daf08e8
Show file tree
Hide file tree
Showing 9 changed files with 3,765 additions and 1 deletion.
582 changes: 582 additions & 0 deletions test/custom-matter-xml.test.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions test/resource/custom-cluster/matter-bad-custom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<configurator>
<domain name="CHIP"/>

<enum name="testbadEnum" type="BITMAP8"> // intentional error - using bitmap8 for enum
<cluster code="0x0300"/>
<item name="testItem1" value="0x0"/>
<item name="testItem2" value="0x01"/>
</enum>

<!-- Use the cluster extension Extend the on/off cluster -->
<clusterExtension code="0x0006">
<attribute side="server" code="0xFFF10000" define="SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_6" type="INT8U" min="0x0000" max="0xFFFF" writable="true" default="0x0000" optional="true">Sample Mfg Specific Attribute 6</attribute>
<attribute side="server" code="0xFFF20001" define="SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_8" type="INT16U" min="0x0000" max="0xFFFF" writable="true" default="0x0000" optional="true">Sample Mfg Specific Attribute 8</attribute>
<command source="client" code="0xFFF20001" name="SampleMfgSpecificOnWithTransition2" optional="true">
<description>Client command that turns the device on with a transition given
by the transition time in the Ember Sample transition time attribute.</description>
</command>
<command source="client" code="0xFFF20002" name="SampleMfgSpecificToggleWithTransition2" optional="true">
<description>Client command that toggles the device with a transition given
by the transition time in the Ember Sample transition time attribute.</description>
</command>
</clusterExtension>

</configurator>
29 changes: 29 additions & 0 deletions test/resource/custom-cluster/matter-conflict.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2023 Project CHIP Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<configurator>
<domain name="CHIP"/>
<cluster>
<domain>General</domain>
<name>Sample Conflict </name>
<code>0xFFF1FC20</code>
<define>SAMPLE_CONFLICT</define>
<description>Used for testing</description>
<!-- Attributes -->
<!-- A simple boolean attribute that flips or flops -->
<attribute side="server" code="0x0000" define="FLIP_FLOP" type="BOOLEAN" writable="true" default="false" optional="false">FlipFlop</attribute>
</cluster>
</configurator>
66 changes: 66 additions & 0 deletions test/resource/custom-cluster/matter-custom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2023 Project CHIP Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<configurator>
<domain name="CHIP"/>
<cluster>
<domain>General</domain>
<name>Sample Custom Cluster</name>
<code>0xFFF1FC20</code>
<define>SAMPLE_MEI_CLUSTER</define>
<description>The Sample MEI cluster showcases cluster manufacturer extensions</description>
<!-- Attributes -->
<!-- A simple boolean attribute that flips or flops -->
<attribute side="server" code="0x0000" define="FLIP_FLOP" type="BOOLEAN" writable="true" default="false" optional="false">FlipFlop</attribute>
<!-- Command Responses -->
<command source="server" code="0x01" name="AddArgumentsResponse" optional="false" disableDefaultResponse="true">
<description>
Response for AddArguments that returns the sum.
</description>
<arg name="returnValue" type="INT8U"/>
</command>

<!-- Commands -->
<command source="client" code="0x02" name="AddArguments" response="AddArgumentsResponse" optional="false">
<description>
Command that takes two uint8 arguments and returns their sum.
</description>
<arg name="arg1" type="INT8U"/>
<arg name="arg2" type="INT8U"/>
</command>

<command source="client" code="0x00" name="Ping" optional="false">
<description>
Simple command without any parameters and without a response.
</description>
</command>
<!-- Events -->
</cluster>

<!-- Use the cluster extension Extend the on/off cluster -->
<clusterExtension code="0x0006">
<attribute side="server" code="0xFFF10000" define="SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_2" type="INT8U" min="0x0000" max="0xFFFF" writable="true" default="0x0000" optional="true">Sample Mfg Specific Attribute 2</attribute>
<attribute side="server" code="0xFFF10001" define="SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_4" type="INT16U" min="0x0000" max="0xFFFF" writable="true" default="0x0000" optional="true">Sample Mfg Specific Attribute 4</attribute>
<command source="client" code="0xFFF100" name="SampleMfgSpecificOnWithTransition2" optional="true">
<description>Client command that turns the device on with a transition given
by the transition time in the Ember Sample transition time attribute.</description>
</command>
<command source="client" code="0xFFF101" name="SampleMfgSpecificToggleWithTransition2" optional="true">
<description>Client command that toggles the device with a transition given
by the transition time in the Ember Sample transition time attribute.</description>
</command>
</clusterExtension>
</configurator>
35 changes: 35 additions & 0 deletions test/resource/custom-cluster/matter-custom2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2023 Project CHIP Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<configurator>
<domain name="CHIP"/>

<!-- Use the cluster extension Extend the on/off cluster -->
<clusterExtension code="0x0006">
<attribute side="server" code="0xFFF20000" define="SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_6" type="INT8U" min="0x0000" max="0xFFFF" writable="true" default="0x0000" optional="true">Sample Mfg Specific Attribute 6</attribute>
<attribute side="server" code="0xFFF20001" define="SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_8" type="INT16U" min="0x0000" max="0xFFFF" writable="true" default="0x0000" optional="true">Sample Mfg Specific Attribute 8</attribute>
<command source="client" code="0xFFF200" name="SampleMfgSpecificOnWithTransition2" optional="true">
<description>Client command that turns the device on with a transition given
by the transition time in the Ember Sample transition time attribute.</description>
</command>
<command source="client" code="0xFFF201" name="SampleMfgSpecificToggleWithTransition2" optional="true">
<description>Client command that toggles the device with a transition given
by the transition time in the Ember Sample transition time attribute.</description>
</command>
</clusterExtension>

</configurator>
Loading

0 comments on commit daf08e8

Please sign in to comment.