Verification method, system and equipment of graphic code generator and medium
By automatically parsing the graph model file, the graphic structure relationship tree and the target interface collection with parameter are generated, and the automatic comparison interface of the code analysis tool is combined with the problem of low verification efficiency of the graph code generator, and efficient and reliable code verification is achieved.
Patent Information
- Application Number
- CN202510410355.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-02
- Publication Date
- 2025-07-04
AI Technical Summary
In the prior art, the verification of graph code generators mainly relies on manual inspection and testing, and is inefficient, especially for large and complex graphical interfaces, the verification process is time-consuming and not efficient enough.
By analyzing the graph model file, a primitive structure relationship tree is generated, a set of target interfaces with parameters is generated, and a code parsing tool is used to automatically compare the detection interface, replacing traditional manual inspection and testing.
It significantly reduces manual workload, improves verification efficiency and accuracy, provides a more comprehensive and fine-grained verification basis, and ensures the correctness and reliability of generated codes.
Smart Images

Figure CN120255901A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of code automation, and particularly to a verification method, system, device and medium for a graphical code generator. Background Art
[0002] A graphical code generator is a tool that automatically generates target code according to a graphical model file. It can significantly improve the efficiency of graphical interface development and reduce the workload of manual coding. However, the automatically generated target code may have errors or be inconsistent with the design. To ensure the correctness and reliability of the generated target code, it is necessary to verify the graphical code generator.
[0003] Currently, the verification of graphical code generators mainly adopts the methods of manual inspection and testing. Developers manually review the generated target code and manually write test cases to verify the correctness of the target code. This method is inefficient, especially for large and complex graphical interfaces, and the verification process is very time-consuming. Summary of the Invention
[0004] To solve the above problems, the present invention provides a verification method, system, device and medium for a graphical code generator.
[0005] The first aspect of the present invention discloses a verification method for a graphical code generator. The graphical code generator is used to automatically generate target code for a graphical model file, and the graphical model file describes the graphical structure of a target graphical interface. The verification method is used to detect the correctness of the target code, and the verification method includes:
[0006] Parse the graphical model file to obtain a primitive structure relationship tree; wherein, each node of the primitive structure relationship tree represents a graphical element or its attribute in the target graphical interface, and the tree structure of the primitive structure relationship tree represents the hierarchical structure relationship between all graphical elements and all attributes in the target graphical interface;
[0007] Generate a set of target interfaces with parameters according to all nodes in the primitive structure relationship tree;
[0008] Use a code parsing tool to parse the target code to obtain a plurality of interfaces to be detected;
[0009] Judge whether the target code is correct according to the interfaces to be detected and the set of target interfaces with parameters.
[0010] Further, the graphical model file is based on the XML language;
[0011] Moreover, the step of parsing the graphical model file to obtain a primitive structure relationship tree includes:
[0012] Filter multiple graphic elements and multiple attributes from the graphic model file according to predefined keywords;
[0013] Based on the graphic model file, construct the relationship between the graphic elements and the attributes to generate a primitive structure relationship tree.
[0014] Further, the steps of constructing the relationship between the graphic elements and the attributes based on the graphic model file to generate a primitive structure relationship tree include:
[0015] Create corresponding non-leaf nodes for all graphic elements and create corresponding leaf nodes for all attributes;
[0016] Determine the node corresponding to the graphic element corresponding to the main window of the target graphic interface as the root node;
[0017] Take the root node as the starting node of the tree structure, and according to the hierarchical relationship of the XML tags corresponding to each graphic element and attribute in the graphic model file, allocate corresponding leaf nodes and sub-middle nodes to the root node, and allocate corresponding leaf nodes and corresponding parent nodes to each middle node to obtain a primitive structure relationship tree.
[0018] Further, the steps of allocating corresponding leaf nodes and sub-middle nodes to the root node, and allocating corresponding leaf nodes and corresponding parent nodes to each middle node according to the hierarchical relationship of the XML tags corresponding to each graphic element and label in the graphic model file to obtain a primitive structure relationship tree include:
[0019] Judge whether the graphic model file conforms to the predefined graphic semantic constraint rules:
[0020] If it conforms, then according to the hierarchical relationship of the XML tags corresponding to each graphic element and label in the graphic model file, allocate corresponding leaf nodes and sub-middle nodes to the root node, and allocate corresponding leaf nodes and corresponding parent nodes to each middle node to obtain a primitive structure relationship tree.
[0021] Further, the steps of generating a target interface set with parameters based on all nodes in the primitive structure relationship tree include:
[0022] For each non-leaf node in the primitive structure relationship tree:
[0023] Determine all matching interfaces from the predefined graphic interface library according to the type of the graphic element corresponding to it;
[0024] Determine the input parameters for each of the matching interfaces according to the attributes corresponding to its corresponding leaf nodes;
[0025] Combine all matching interfaces and their input parameters to obtain a set of target interfaces with parameters.
[0026] Further, the steps of determining whether the target code is correct according to the interface to be detected and the set of target interfaces with parameters include:
[0027] Determine whether all detection interfaces corresponding to non-leaf nodes match the set of target interfaces with parameters;
[0028] If so, determine that the target code is correct;
[0029] Otherwise, determine that the target code is incorrect.
[0030] Further, the steps of determining whether a detection interface corresponding to a non-leaf node matches the set of target interfaces with parameters include:
[0031] Determine the target detection interface corresponding to the non-leaf node and its corresponding parameters from multiple interfaces to be detected;
[0032] Determine whether the target detection interface is included in all matching interfaces corresponding to the non-leaf node and the input parameters are the same;
[0033] If the result is yes, determine that the detection interface corresponding to the non-leaf node matches the set of target interfaces with parameters;
[0034] Otherwise, determine that the detection interface corresponding to the non-leaf node does not match the set of target interfaces with parameters.
[0035] The second aspect of the present invention discloses a verification system for a graphical code generator, including:
[0036] A first parsing module for parsing a graphical model file to obtain a graphic element structure relationship tree; wherein, each node of the graphic element structure relationship tree represents a graphic element or its attribute in the target graphic interface, and the tree structure of the graphic element structure relationship tree represents the hierarchical structure relationship between all graphic elements and all attributes in the target graphic interface;
[0037] A generation module for generating a set of target interfaces with parameters according to all nodes in the graphic element structure relationship tree;
[0038] A second parsing module for parsing the target code using a code parsing tool to obtain multiple interfaces to be detected;
[0039] A judgment module for determining whether the target code is correct according to the interface to be detected and the set of target interfaces with parameters.
[0040] A third aspect of the present invention discloses an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. It is characterized in that when the processor executes the computer program, the steps of any one of the verification methods of the graphic code generator disclosed in the first aspect of the present invention are implemented.
[0041] A fourth aspect of the present invention discloses a storage medium storing a computer program, which is characterized in that when the computer program is executed by a processor, the steps of any one of the verification methods of the graphic code generator disclosed in the first aspect of the present invention are implemented.
[0042] The verification method of the graphic code generator proposed by the present invention automatically parses the graphic model file to generate a primitive structure relationship tree and a set of target interfaces with parameters, and uses a code parsing tool to automatically extract the interfaces to be detected for comparison, replacing the traditional manual inspection and testing methods, significantly reducing the manual workload, and at the same time making full use of the structured information of the graphic model file to provide a more comprehensive and fine-grained verification basis. Compared with manual verification, the verification method of the present invention greatly improves the verification efficiency while ensuring the accuracy and consistency of the verification results, providing a more efficient and reliable quality guarantee means for the development and application of the graphic code generator. Description of the Drawings
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other drawings without creative efforts based on these drawings.
[0044] Figure 1 It is a schematic flowchart of a verification method of a graphic code generator disclosed in an embodiment of the present invention;
[0045] Figure 2 It is a schematic principle diagram of a verification method of a graphic code generator disclosed in an embodiment of the present invention;
[0046] Figure 3 It is a schematic structural diagram of a verification system of a graphic code generator disclosed in an embodiment of the present invention;
[0047] Figure 4 It is a schematic structural diagram of the electronic device disclosed in an embodiment of the present invention. Detailed Embodiments
[0048] To enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts belong to the scope of protection of the present invention.
[0049] The terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, or product end that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, devices, or products.
[0050] Referring to the embodiments herein means that the specific features, structures, or characteristics described in connection with the embodiments can be included in at least one embodiment of the present invention. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0051] Please refer to Figure 1 as shown in Figure 1 is a schematic flowchart of a verification method for a graphic code generator disclosed in an embodiment of the present invention. The graphic code generator is used to automatically generate target code for a graphic model file, and the graphic model file describes the graphic structure of a target graphic interface. The verification method is used to detect the correctness of the target code, and the verification method includes:
[0052] S101. Parse the graphic model file to obtain a primitive structure relationship tree; wherein each node of the primitive structure relationship tree represents a graphic element or its attribute in the target graphic interface, and the tree structure of the primitive structure relationship tree represents the hierarchical structure relationship between all graphic elements and all attributes in the target graphic interface;
[0053] In this embodiment, the graphical model file refers to the Safety Graphics Markup Language (SAML), which describes the graphical model. SAML (Safety Graphics Markup Language) is a domain-specific language used to describe and model the graphical interfaces of safety-critical systems, providing a standardized way to represent and analyze the graphical user interfaces of safety-critical systems to ensure their security, reliability, and compliance. SAML is defined based on the Extensible Markup Language (XML) and has a hierarchical structure, consisting of a series of nested elements and attributes, which are used to describe various aspects of the graphical interface, such as screens, controls, layouts, events, and operations, etc. By using a declarative approach, SAML can clearly express the structure and behavior of the interface without paying attention to specific implementation details.
[0054] The primitive structure relationship tree is a tree-like data structure used to represent the hierarchical structure relationship between graphical elements and their attributes in the target graphical interface. It parses the target graphical interface into a tree-like structure to intuitively and orderly present the composition and layout of the target graphical interface.
[0055] In the primitive structure relationship tree, each node represents a graphical element or its attribute in the target graphical interface. The parent-child relationship between nodes reflects the inclusion and subordination relationships between graphical elements. The hierarchical structure of the tree reflects the nesting and organization methods of graphical elements.
[0056] For example: The main window of the target graphical interface includes a square icon and a circular button. The circular button has two attributes, namely the center and the radius. The square icon has two attributes, namely the center and the side length. Then the corresponding primitive structure relationship tree can be described as follows: The root node represents the main window of the entire target graphical interface. There are two sub-middle nodes under the root node, representing the square icon and the circular button respectively. There are two leaf nodes under the circular button node, representing the center attribute and the radius attribute respectively. There are two leaf nodes under the square icon node, representing the center attribute and the side length attribute respectively. There are three leaf nodes under the root node, representing the center attribute, the first side length attribute, and the second side length attribute respectively.
[0057] In an alternative embodiment, the graphical model file is based on the XML language;
[0058] Moreover, the steps of parsing the graphical model file to obtain the primitive structure relationship tree include:
[0059] Filtering out a plurality of graphical elements and a plurality of attributes from the graphical model file according to predefined keywords;
[0060] Based on the graphic model file, construct the relationships between the graphic elements and the attributes, and generate a primitive structure relationship tree.
[0061] In this alternative embodiment, the XML language is a commonly used structured data representation language that uses tags to describe the hierarchical structure and attributes of data. Each graphic element corresponds to a keyword. For example, the keyword corresponding to a circular button can be "circular button", "first type button", etc., and each attribute also corresponds to a keyword. For example, the keyword corresponding to the side length can be "side length", "first attribute", etc.
[0062] It can be seen that in this alternative embodiment, by predefining keywords and utilizing the structured characteristics of XML, the graphic elements and attributes can be extracted from the graphic model file more accurately and efficiently, and a complete primitive structure relationship tree can be constructed. This not only improves the accuracy of parsing the graphic model file and reduces errors and omissions caused by manual parsing, but also by utilizing the structured characteristics of XML, it is easier to identify the hierarchical relationships between graphic elements and the attribution of attributes. At the same time, by predefining keywords, the description methods of different graphic model files can be unified, improving the consistency and reusability of parsing. The finally generated primitive structure relationship tree provides a clear and structured data foundation for subsequent interface generation and code verification, improving the efficiency and accuracy of verification.
[0063] In another alternative embodiment, the steps of constructing the relationships between the graphic elements and the attributes based on the graphic model file and generating a primitive structure relationship tree include:
[0064] Create corresponding non-leaf nodes for all graphic elements and corresponding leaf nodes for all attributes;
[0065] Determine the node corresponding to the graphic element of the main window of the target graphic interface as the root node;
[0066] Take the root node as the starting node of the tree structure, and according to the hierarchical relationship of the XML tags corresponding to each graphic element and attribute in the graphic model file, allocate corresponding leaf nodes and sub-intermediate nodes to the root node, and allocate corresponding leaf nodes and corresponding parent nodes to each intermediate node to obtain a primitive structure relationship tree.
[0067] It can be seen that this alternative embodiment provides a clear and operable way to construct a primitive structure relationship tree. By utilizing the hierarchical relationship of XML tags, the parent-child relationships and sibling relationships between graphic elements and attributes can be accurately reflected. The generated primitive structure relationship tree can completely and accurately represent the structure and composition of the target graphic interface, laying a solid foundation for subsequent interface generation and code verification, and improving the reliability and effectiveness of the entire verification method.
[0068] In yet another alternative embodiment, according to the hierarchical relationship of the XML tags corresponding to each graphical element and label in the graphical model file, the steps of allocating corresponding leaf nodes and sub-intermediate nodes to the root node, and allocating corresponding leaf nodes and corresponding parent nodes to each intermediate node to obtain the graphic element structure relationship tree include:
[0069] Determine whether the graphical model file conforms to the predefined graphical semantic constraint rules:
[0070] If it conforms, according to the hierarchical relationship of the XML tags corresponding to each graphical element and label in the graphical model file, allocate corresponding leaf nodes and sub-intermediate nodes to the root node, and allocate corresponding leaf nodes and corresponding parent nodes to each intermediate node to obtain the graphic element structure relationship tree.
[0071] In this alternative embodiment, the graphical semantic constraint rules refer to a set of rules and constraints defined for the graphical model file to ensure that the structure and content of the file meet specific requirements and specifications. These rules may include, but are not limited to: correct nesting and closing of XML tags, existence of required tags and attributes, data types and value ranges of tag and attribute values, logical relationships and constraints between graphical elements, etc. For example, a graphical semantic constraint rule can be: "The <main interface> tag can only appear as the root tag and can only appear once", which ensures the uniqueness and integrity of the graphical interface.
[0072] It can be seen that this alternative embodiment provides an additional layer of verification and guarantee. By predefined graphical semantic constraint rules, it can ensure the correctness and rationality of the graphical model file, avoid problems such as construction failure or inaccurate generated graphic element structure relationship tree caused by file errors or non-compliance, improve the reliability of the entire verification method, and at the same time reduce unnecessary calculations and processing, improving efficiency.
[0073] S102. Generate a target interface set with parameters according to all nodes in the graphic element structure relationship tree;
[0074] In an alternative embodiment, the steps of generating a target interface set with parameters according to all nodes in the graphic element structure relationship tree include:
[0075] For each non-leaf node in the graphic element structure relationship tree:
[0076] Determine all matching interfaces from the predefined graphic interface library according to the type of the corresponding graphical element;
[0077] Determine the input parameters for each of the matching interfaces according to the attributes corresponding to its corresponding leaf nodes;
[0078] Combine all matching interfaces and their input parameters to obtain a set of target interfaces with parameters.
[0079] In this optional embodiment, the graphics interface library can be OpenGL, DirectX, etc., and the embodiments of the present invention do not limit it.
[0080] For example: For a square graphic element, its attributes include the center coordinates and side length. In OpenGL, there can be multiple matching interfaces to draw this square element: Interface one can directly draw a square according to the center coordinates and side length, and its input parameters are the center coordinates and side length; Interface two can draw a square according to the four vertex coordinates of the square, and its input parameters are the four vertex coordinates of the square; Interface three can draw a square according to the lower left vertex and side length, and its input parameters are the lower left vertex coordinates and side length. Interface one, two, three and their corresponding parameters are the set of target interfaces with parameters corresponding to the square graphic element.
[0081] It can be seen that in this optional embodiment, by pre-defining the graphics interface library and determining the matching interfaces and input parameters according to the types and attributes of the nodes in the primitive structure relationship tree, the interface set corresponding to the target graphic interface can be generated quickly and accurately, avoiding the cumbersome and errors of manually writing interfaces.
[0082] S103. Use a code parsing tool to parse the target code to obtain a plurality of interfaces to be detected;
[0083] In this optional embodiment, the target code can be based on C language, C++, JAVA language, and the embodiments of the present invention do not limit it. The code parsing tool refers to a software tool or library used to analyze and understand the structure, syntax, and semantics of the target code. The code parsing tool reads the source code file, identifies elements such as keywords, identifiers, expressions, statements, and code blocks therein, and constructs an abstract syntax tree or other intermediate representation of the code, so as to realize the static analysis and understanding of the code. The code parsing tool can be Clang, pycparser, ctags, etc., and the embodiments of the present invention do not limit it.
[0084] S104. Determine whether the target code is correct according to the interfaces to be detected and the set of target interfaces with parameters.
[0085] In another optional embodiment, the step of determining whether the target code is correct according to the interfaces to be detected and the set of target interfaces with parameters includes:
[0086] Judge whether all the detection interfaces corresponding to the non-leaf nodes match the set of target interfaces with parameters;
[0087] If so, it is determined that the target code is correct;
[0088] Otherwise, it is determined that the target code is incorrect.
[0089] In yet another alternative embodiment, the step of determining whether a detection interface corresponding to a non-leaf node matches the set of parameterized target interfaces includes:
[0090] Determine the target detection interface corresponding to the non-leaf node and its corresponding parameters from multiple interfaces to be detected;
[0091] Determine whether the target detection interface is included in all matching interfaces corresponding to the non-leaf node and the entry parameters are the same;
[0092] If the result is yes, it is determined that the detection interface corresponding to the non-leaf node matches the set of parameterized target interfaces;
[0093] Otherwise, it is determined that the detection interface corresponding to the non-leaf node does not match the set of parameterized target interfaces.
[0094] It can be seen that this alternative embodiment not only compares the function names of the interfaces, but also compares the entry parameters of the interfaces, which can more accurately determine whether the interfaces in the target code are consistent with the expected interfaces, improving the reliability and accuracy of code verification. At the same time, by separately performing interface matching judgments for each non-leaf node, the specific location and reason for the problems or inconsistencies in the target code can be located, facilitating developers to perform error repair and code optimization.
[0095] Figure 2 Shows the schematic diagram of the verification method of the graphical code generator. Figure 2 In the lexical analysis, according to the predefined keywords, multiple graphical elements and multiple attributes are filtered from the graphical model file; in the syntax analysis, based on the graphical model file, the relationships between the graphical elements and the attributes are constructed to generate a primitive structure relationship tree; in the semantic analysis, it is determined whether the graphical model file conforms to the predefined graphical semantic constraint rules.
[0096] Please refer to Figure 3 as shown in Figure 3 is a schematic structural diagram of a verification system for a graphical code generator disclosed in an embodiment of the present invention, including:
[0097] A first parsing module 301, configured to parse a graphical model file to obtain a primitive structure relationship tree; wherein, each node of the primitive structure relationship tree represents a graphical element or its attribute in the target graphical interface, and the tree structure of the primitive structure relationship tree represents the hierarchical structure relationship between all graphical elements and all attributes in the target graphical interface;
[0098] A generation module 302, configured to generate a set of target interfaces with parameters according to all nodes in the graphic element structure relationship tree;
[0099] A second parsing module 303, configured to use a code parsing tool to parse the target code to obtain a plurality of interfaces to be detected;
[0100] A judgment module 304, configured to judge whether the target code is correct according to the interfaces to be detected and the set of target interfaces with parameters.
[0101] For the specific limitations of the verification system of the graphic code generator, reference can be made to the limitations of the verification method of the graphic code generator in the above text, which will not be elaborated here. Each module in the above verification system of the graphic code generator can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the electronic device in a hardware format or independent of the processor, or stored in the memory in the electronic device in a software format, so as to facilitate the processor to call the corresponding operations of the above modules.
[0102] It should be noted that, in order to highlight the innovative part of the present invention, modules that are not closely related to solving the technical problems proposed by the present invention are not introduced in this embodiment, but this does not mean that there are no other modules in this embodiment.
[0103] As Figure 4 shown, the electronic device 1 provided by the present invention may include a memory 11, a processor 12, and a bus, and may further include a computer program stored in the memory 11 and executable on the processor 12, such as a verification program of the graphic code generator.
[0104] Among them, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. The memory 11 may be an internal storage unit of the electronic device 1 in some embodiments, such as the mobile hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the electronic device 1. Further, the memory 11 may include both the internal storage unit and the external storage device of the electronic device 1. The memory 11 can not only be used to store application software installed in the electronic device 1 and various types of data, such as the code for verifying the graphic code generator, etc., but also be used to temporarily store data that has been output or will be output.
[0105] In some embodiments, the processor 12 may be composed of an integrated circuit. For example, it may be composed of a single packaged integrated circuit, or may be composed of multiple packaged integrated circuits with the same or different functions, including a combination of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 12 is the control core (Control Unit) of the electronic device 1, connecting various components of the entire electronic device 1 through various interfaces and circuits. By running or executing programs or modules stored in the memory 11 (such as the verification program of the graphics code generator, etc.), and calling the data stored in the memory 11, it executes various functions of the electronic device 1 and processes data.
[0106] The processor 12 executes the operating system of the electronic device 1 and various installed application programs. The processor 12 executes the application program to implement the steps in the above-mentioned verification method of the graphics code generator.
[0107] Exemplarily, the computer program may be divided into one or more modules, and the one or more modules are stored in the memory 11 and executed by the processor 12 to complete this application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and this instruction segment is used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into a first parsing module 301, a generating module 302, a second parsing module 303, and a judging module 304.
[0108] The above-mentioned integrated unit implemented in the form of software function modules may be stored in a computer-readable storage medium, and the storage medium may be non-volatile or volatile. The above-mentioned software function modules are stored in a storage medium, including several instructions to enable a computer device (which may be a personal computer, a computer device, or a network device, etc.) or a processor to execute part of the functions of the verification method of the graphics code generator described in various embodiments of this application.
[0109] In summary, a verification method, system, device, and medium for a graphic code generator disclosed by the present invention. The verification method for the graphic code generator proposed by the present invention automatically parses a graphic model file to generate a primitive structure relationship tree and a set of target interfaces with parameters, and uses a code parsing tool to automatically extract the interfaces to be detected for comparison, replacing the traditional manual inspection and testing methods, significantly reducing the manual workload, and at the same time making full use of the structured information of the graphic model file to provide a more comprehensive and fine-grained verification basis. Compared with manual verification, the verification method of the present invention greatly improves the verification efficiency while ensuring the accuracy and consistency of the verification results, providing a more efficient and reliable quality guarantee means for the development and application of the graphic code generator. Therefore, the present invention effectively overcomes various disadvantages in the prior art and has high industrial utilization value.
[0110] The above embodiments are only used to exemplarily illustrate the principles and effects of the present invention, rather than to limit the present invention. Any person familiar with this technology can modify or change the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or changes completed by those with ordinary knowledge in the technical field without departing from the spirit and technical idea disclosed by the present invention should still be covered by the claims of the present invention.
Claims
1. A verification method for a graphic code generator, characterized in that, The graphic code generator is used to automatically generate target code for a graphic model file, which describes the graphic structure of a target graphic interface. The verification method is used to detect the correctness of the target code. The verification method includes: Parsing the graphic model file to obtain a graphic primitive structure relationship tree; wherein, each node of the graphic primitive structure relationship tree represents a graphic element or its attribute in the target graphic interface, and the tree structure of the graphic primitive structure relationship tree represents the hierarchical structure relationship among all graphic elements and all attributes in the target graphic interface; Generating a set of target interfaces with parameters according to all nodes in the graphic primitive structure relationship tree; Using a code parsing tool to parse the target code to obtain a plurality of interfaces to be detected; Judging whether the target code is correct according to the interfaces to be detected and the set of target interfaces with parameters.
2. The verification method of a graphic code generator according to claim 1, characterized in that, The graphic model file is based on the XML language; Moreover, the step of parsing the graphic model file to obtain a graphic primitive structure relationship tree includes: Filtering a plurality of graphic elements and a plurality of attributes from the graphic model file according to predefined keywords; Based on the graphic model file, constructing the relationship between the graphic elements and the attributes to generate a graphic primitive structure relationship tree.
3. The verification method of a graphic code generator according to claim 2, characterized in that, The step of constructing the relationship between the graphic elements and the attributes based on the graphic model file to generate a graphic primitive structure relationship tree includes: Creating corresponding non-leaf nodes for all graphic elements and creating corresponding leaf nodes for all attributes; Determining the node corresponding to the graphic element corresponding to the main window of the target graphic interface as the root node; Taking the root node as the starting node of the tree structure, and according to the hierarchical relationship of the XML tags corresponding to each graphic element and attribute in the graphic model file, allocating corresponding leaf nodes and sub-intermediate nodes to the root node, and allocating corresponding leaf nodes and corresponding parent nodes to each intermediate node to obtain a graphic primitive structure relationship tree.
4. The verification method of a graphic code generator according to claim 3, characterized in that, The step of allocating corresponding leaf nodes and sub-intermediate nodes to the root node, and allocating corresponding leaf nodes and corresponding parent nodes to each intermediate node according to the hierarchical relationship of the XML tags corresponding to each graphic element and label in the graphic model file to obtain a graphic primitive structure relationship tree includes: Judging whether the graphic model file conforms to predefined graphic semantic constraint rules: If it conforms, then according to the hierarchical relationship of the XML tags corresponding to each graphic element and label in the graphic model file, allocating corresponding leaf nodes and sub-intermediate nodes to the root node, and allocating corresponding leaf nodes and corresponding parent nodes to each intermediate node to obtain a graphic primitive structure relationship tree.
5. The verification method of a graphic code generator according to claim 1, characterized in that, The step of generating a set of target interfaces with parameters according to all nodes in the graphic primitive structure relationship tree includes: For each non-leaf node in the graphic primitive structure relationship tree: Determining all matching interfaces from a predefined graphic interface library according to the type of the corresponding graphic element; Determining entry parameters for each of the matching interfaces according to the attributes corresponding to its corresponding leaf nodes; combining all the matching interfaces and their entry parameters to obtain a set of target interfaces with parameters.
6. The verification method of a graphic code generator according to claim 1, characterized in that The steps of determining whether the target code is correct according to the interface to be detected and the set of parameterized target interfaces include: Determine whether all the detection interfaces corresponding to non-leaf nodes match the set of parameterized target interfaces; If so, determine that the target code is correct; Otherwise, determine that the target code is incorrect.
7. A verification method for a graphic code generator according to claim 6, characterized in that The steps of determining whether a detection interface corresponding to a non-leaf node matches the set of parameterized target interfaces include: Determine the target detection interface corresponding to the non-leaf node and its corresponding parameters from multiple interfaces to be detected; Determine whether the target detection interface is included in all the matching interfaces corresponding to the non-leaf node and the input parameters are the same; If the result is yes, determine that the detection interface corresponding to the non-leaf node matches the set of parameterized target interfaces; Otherwise, determine that the detection interface corresponding to the non-leaf node does not match the set of parameterized target interfaces.
8. A verification system for a graphic code generator, characterized in that, Including: A first parsing module for parsing a graphical model file to obtain a graphic element structure relationship tree; wherein each node of the graphic element structure relationship tree represents a graphic element or its attribute in the target graphic interface, and the tree structure of the graphic element structure relationship tree represents the hierarchical structure relationship among all the graphic elements and all the attributes in the target graphic interface; A generation module for generating a set of parameterized target interfaces according to all the nodes in the graphic element structure relationship tree; A second parsing module for parsing the target code using a code parsing tool to obtain a plurality of interfaces to be detected; A judgment module for determining whether the target code is correct according to the interfaces to be detected and the set of parameterized target interfaces.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein, When the processor executes the computer program, the steps of the verification method of the graphic code generator according to any one of claims 1 to 7 are implemented.
10. A storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the steps of the verification method of the graphic code generator according to any one of claims 1 to 7 are implemented.