Skip to content
代码片段 群组 项目
未验证 提交 3ca4ddfc 编辑于 作者: Timotej Ecimovic's avatar Timotej Ecimovic 提交者: GitHub
浏览文件

Restore matter unit tests and fix backwards compatibility. (#948)

* Restore one matter unit test to being operational.
* Allow for sorting and omitting certain items in the struct population.
* Increase feature level.
上级 76d6233a
No related branches found
No related tags found
无相关合并请求
显示
53 个添加153 个删除
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"description": "Graphical configuration tool for application and libraries based on Zigbee Cluster Library.", "description": "Graphical configuration tool for application and libraries based on Zigbee Cluster Library.",
"path": [".", "node_modules/.bin/", "ZAP.app/Contents/MacOS"], "path": [".", "node_modules/.bin/", "ZAP.app/Contents/MacOS"],
"requiredFeatureLevel": "apack.core:9", "requiredFeatureLevel": "apack.core:9",
"featureLevel": 92, "featureLevel": 93,
"uc.triggerExtension": "zap", "uc.triggerExtension": "zap",
"executable": { "executable": {
"zap:win32.x86_64": { "zap:win32.x86_64": {
......
...@@ -261,7 +261,13 @@ function chip_endpoint_generated_event_list(options) { ...@@ -261,7 +261,13 @@ function chip_endpoint_generated_event_list(options) {
* To be used as a replacement of endpoint_cluster_list since this one * To be used as a replacement of endpoint_cluster_list since this one
* includes the GENERATED_FUNCTIONS array * includes the GENERATED_FUNCTIONS array
*/ */
function chip_endpoint_cluster_list() { function chip_endpoint_cluster_list(options) {
let order = options.hash.order;
if (order == null || order.length == 0) {
order =
'clusterId, attributes, attributeCount, clusterSize, mask, functions, acceptedCommandList, generatedCommandList';
// eventList and eventCount was added later, so default needs to stay like this for backwards compatibility.
}
const configData = getConfigData(this.global); const configData = getConfigData(this.global);
let ret = '{ \\\n'; let ret = '{ \\\n';
let totalCommands = 0; let totalCommands = 0;
...@@ -352,18 +358,51 @@ function chip_endpoint_cluster_list() { ...@@ -352,18 +358,51 @@ function chip_endpoint_cluster_list() {
eventList = `ZAP_GENERATED_EVENTS_INDEX( ${c.eventIndex} )`; eventList = `ZAP_GENERATED_EVENTS_INDEX( ${c.eventIndex} )`;
} }
let individualItems = [];
let orderTokens = order.split(',').map((x) => (x ? x.trim() : ''));
orderTokens.forEach((tok) => {
switch (tok) {
case 'clusterId':
individualItems.push(`.clusterId = ${c.clusterId}`);
break;
case 'attributes':
individualItems.push(
`.attributes = ZAP_ATTRIBUTE_INDEX(${c.attributeIndex})`
);
break;
case 'attributeCount':
individualItems.push(`.attributeCount = ${c.attributeCount}`);
break;
case 'clusterSize:':
individualItems.push(`.clusterSize = ${c.attributeSize}`);
break;
case 'mask':
individualItems.push(`.mask = ${mask}`);
break;
case 'functions':
individualItems.push(`.functions = ${functionArray}`);
break;
case 'acceptedCommandList':
individualItems.push(
`.acceptedCommandList = ${acceptedCommandsListVal}`
);
break;
case 'generatedCommandList':
individualItems.push(
`.generatedCommandList = ${generatedCommandsListVal}`
);
break;
case 'eventList':
individualItems.push(`.eventList = ${eventList}`);
break;
case 'eventCount':
individualItems.push(`.eventCount = ${eventCount}`);
break;
}
});
ret = ret.concat(` { \\ ret = ret.concat(` { \\
/* ${c.comment} */ \\ /* ${c.comment} */ \\
.clusterId = ${c.clusterId}, \\ ${individualItems.join(', \\\n')}, \\
.attributes = ZAP_ATTRIBUTE_INDEX(${c.attributeIndex}), \\
.attributeCount = ${c.attributeCount}, \\
.clusterSize = ${c.attributeSize}, \\
.mask = ${mask}, \\
.functions = ${functionArray}, \\
.acceptedCommandList = ${acceptedCommandsListVal} ,\\
.generatedCommandList = ${generatedCommandsListVal} ,\\
.eventList = ${eventList}, \\
.eventCount = ${eventCount}, \\
},\\\n`); },\\\n`);
totalCommands = totalCommands + acceptedCommands + generatedCommands; totalCommands = totalCommands + acceptedCommands + generatedCommands;
......
...@@ -82,6 +82,7 @@ test( ...@@ -82,6 +82,7 @@ test(
{}, {},
{ disableDeprecationWarnings: true } { disableDeprecationWarnings: true }
) )
expect(genResult.hasErrors).toEqual(false)
}, },
testUtil.timeout.long() testUtil.timeout.long()
) )
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
{{#chip_server_global_responses}} {{#chip_server_global_responses}}
{{! TODO: Add support for struct-typed attributes }} {{! TODO: Add support for struct-typed attributes }}
......
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
{{#chip_server_global_responses}} {{#chip_server_global_responses}}
......
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
X X
{{/if}} {{/if}}
......
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
{{#chip_client_clusters}} {{#chip_client_clusters}}
......
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
{{#chip_client_clusters}} {{#chip_client_clusters}}
......
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
{{#chip_client_clusters}} {{#chip_client_clusters}}
Map<String, InteractionInfo> write{{asUpperCamelCase name}}InteractionInfo = new LinkedHashMap<>(); Map<String, InteractionInfo> write{{asUpperCamelCase name}}InteractionInfo = new LinkedHashMap<>();
......
'''
{{> header}}
'''
{{#chip_client_clusters}} {{#chip_client_clusters}}
_{{asDelimitedMacro name}}_CLUSTER_INFO = { _{{asDelimitedMacro name}}_CLUSTER_INFO = {
"clusterName": "{{asUpperCamelCase name}}", "clusterName": "{{asUpperCamelCase name}}",
......
'''
{{> header}}
'''
{{#zcl_clusters}}
{{#zcl_attributes_server}}
{{#if entryType}}
ClusterObjectFieldDescriptor(Label="{{ asLowerCamelCase label }}", Tag={{asMEI manufacturerCode code}}, Type={{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}}),
{{else}}
ClusterObjectFieldDescriptor(Label="{{ asLowerCamelCase label }}", Tag={{asMEI manufacturerCode code}}, Type={{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}}),
{{/if}}
{{/zcl_attributes_server}}
{{#zcl_attributes_server}}
{{#if entryType}}
{{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}}' = None
{{else}}
{{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}}' = None
{{/if}}
{{/zcl_attributes_server}}
{{#zcl_enums}}
{{#first}}
class Enums:
{{/first}}
class {{asType label}}(IntEnum):
{{#zcl_enum_items}}
k{{asUpperCamelCase label}} = {{asHex value 2}}
{{/zcl_enum_items}}
{{/zcl_enums}}
{{#zcl_structs}}
{{#first}}
class Structs:
{{/first}}
{{#zcl_struct_items}}
ClusterObjectFieldDescriptor(Label="{{ asLowerCamelCase label }}", Tag={{ fieldIdentifier }}, Type={{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}),
{{/zcl_struct_items}}
{{#zcl_struct_items}}
{{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.parent.name)}}
{{/zcl_struct_items}}
{{#last}}
{{/last}}
{{/zcl_structs}}
{{#zcl_commands}}
{{#first}}
class Commands:
{{/first}}
@dataclass
class {{asUpperCamelCase name}}(ClusterCommand):
cluster_id: typing.ClassVar[int] = {{ asHex parent.code 4 }}
command_id: typing.ClassVar[int] = {{ asHex code 4 }}
{{#if (isServer source)}}
is_client: typing.ClassVar[bool] = False
{{else}}
is_client: typing.ClassVar[bool] = True
{{/if}}
Fields = [
{{#zcl_command_arguments}}
ClusterObjectFieldDescriptor(Label="{{ asLowerCamelCase label }}", Tag={{ index }}, Type={{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}),
{{/zcl_command_arguments}}
])
{{#if mustUseTimedInvoke}}
x
{{/if}}
{{#zcl_command_arguments}}
{{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.parent.name)}}
{{/zcl_command_arguments}}
{{/zcl_commands}}
{{#zcl_attributes_server}}
{{#first}}
class Attributes:
{{/first}}
{{#if mustUseTimedWrite}}
Y
{{/if}}
{{#if entryType}}
return ClusterObjectFieldDescriptor(Type={{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}})
{{else}}
return ClusterObjectFieldDescriptor(Type={{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}})
{{/if}}
{{#if entryType}}
value: '{{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}}' = {{getPythonFieldDefault entryType ns=(asUpperCamelCase parent.name)}}
{{else}}
value: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.name)}}
{{/if}}
{{/zcl_attributes_server}}
{{#zcl_events}}
{{#first}}
class Events:
{{/first}}
Fields = [
{{#zcl_event_fields}}
ClusterObjectFieldDescriptor(Label="{{ asLowerCamelCase name }}", Tag={{ fieldIdentifier }}, Type={{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}),
{{/zcl_event_fields}}
]
{{#zcl_event_fields}}
{{ asLowerCamelCase name }}: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.parent.name)}}
{{/zcl_event_fields}}
{{/zcl_events}}
{{/zcl_clusters}}
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
{{#chip_client_clusters}} {{#chip_client_clusters}}
......
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
{{#chip_client_clusters}} {{#chip_client_clusters}}
......
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
{{#chip_client_clusters}} {{#chip_client_clusters}}
......
{{> header}}
package chip.devicecontroller; package chip.devicecontroller;
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
......
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
public static String clusterIdToName(long clusterId) { public static String clusterIdToName(long clusterId) {
......
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
{{#chip_client_clusters}} {{#chip_client_clusters}}
......
{{> header}}
{{#if (chip_has_client_clusters)}} {{#if (chip_has_client_clusters)}}
{{#chip_client_clusters}} {{#chip_client_clusters}}
{{#chip_cluster_responses}} {{#chip_cluster_responses}}
......
...@@ -96,11 +96,6 @@ ...@@ -96,11 +96,6 @@
"path": "16.zapt", "path": "16.zapt",
"name": "Test 16", "name": "Test 16",
"output": "16.out" "output": "16.out"
},
{
"path": "17.zapt",
"name": "Test 17",
"output": "17.out"
} }
] ]
} }
...@@ -84,7 +84,7 @@ exports.testTemplate = { ...@@ -84,7 +84,7 @@ exports.testTemplate = {
matter2: './test/gen-template/matter2/templates.json', matter2: './test/gen-template/matter2/templates.json',
matter2Count: 1, matter2Count: 1,
matter3: './test/gen-template/matter3/t.json', matter3: './test/gen-template/matter3/t.json',
matter3Count: 17, matter3Count: 16,
dotdot: './test/gen-template/dotdot/dotdot-templates.json', dotdot: './test/gen-template/dotdot/dotdot-templates.json',
dotdotCount: 5, dotdotCount: 5,
unittest: './test/gen-template/test/gen-test.json', unittest: './test/gen-template/test/gen-test.json',
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册