Method and device for identifying controls, electronic device, and storage medium

By assigning identifiers to Qt applications and managing them in separate tables, unnamed control identifier issues are solved, debugging and testing is simplified, and control scope is expanded without modifying application source code.

CN113742223BActive Publication Date: 2025-01-10DOUYIN VISION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110965750.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-23
Publication Date
2025-01-10
Estimated Expiration
2041-08-23

AI Technical Summary

Technical Problem

When developing Qt applications, not giving identifiers to some controls, resulting in high complexity in debugging and testing programs and the inability to manage the control's identifiers without modifying the target application.

Method used

By loading the analysis program to the target application, analyzing the control tree and assigning identifiers to some controls, generating and saving identifier table entries, describing the correspondence between the control's identifier and feature information, ensuring that each control has a unique identifier and managed in a separate identifier table.

Benefits of technology

Simplifies the writing of debugging and testing programs, expands the controllable scope of control, avoids the problem of rewriting programs due to identifier changes, and does not require modifying the source code of the target application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113742223B_ABST
    Figure CN113742223B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for identifying controls, an electronic device, and a storage medium, the method comprising: loading an analysis program into a target application, analyzing the target application using the analysis program, obtaining a control tree of the target application and feature information of at least some controls in the control tree; assigning an identifier to each control in at least some of the controls, generating at least one identifier table entry based on the identifier and feature information of each control in at least some of the controls, wherein each identifier table entry in the at least one identifier table entry is used to express the correspondence between an identifier and feature information of a control; and saving the identifier table formed by the at least one identifier table entry. In this way, a unique identifier can be assigned to a control without modifying the target application, and the control can be scheduled through the identifier.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer information processing technology, and in particular to a method and device for identifying a control, an electronic device, and a storage medium. Background Art

[0002] Qt is an application development framework that provides a cross-platform class library, integrated development tools, and a cross-platform integrated development environment (IDE). Qt can be used to develop applications. Furthermore, Qt can be used to deploy applications across different desktop and embedded operating systems. Applications developed with Qt are called Qt applications.

[0003] A typical Qt application is a Qt Quick application. When developing a Qt Quick application, it is not necessary to assign a unique identifier to each control. This results in some controls not having corresponding identifiers, which in turn makes it more complicated to write programs based on these controls (such as debuggers, test programs, etc.). Summary of the invention

[0004] In order to solve the above technical problems, the embodiments of the present application provide a method and device for identifying a control, an electronic device, and a computer-readable storage medium.

[0005] The method for identifying a control provided in an embodiment of the present application includes:

[0006] Loading the analysis program into the target application, analyzing the target application using the analysis program, and obtaining a control tree of the target application and feature information of at least some controls in the control tree;

[0007] Assigning an identifier to each control in the at least part of the controls, and generating at least one identifier table entry based on the identifier and characteristic information of each control in the at least part of the controls, wherein each identifier table entry in the at least one identifier table entry is used to express a corresponding relationship between an identifier and characteristic information of a control;

[0008] The identifier table formed by the at least one identifier table entry is saved.

[0009] The device for identifying a control provided in an embodiment of the present application includes:

[0010] A loading unit for loading the analysis program into the target application;

[0011] An analysis unit, configured to analyze the target application using the analysis program to obtain a control tree of the target application and feature information of at least some controls in the control tree;

[0012] a generating unit, configured to assign an identifier to each control of the at least some of the controls, and to generate at least one identifier table entry based on the identifier and characteristic information of each control of the at least some of the controls, wherein each identifier table entry of the at least one identifier table entry is used to express a correspondence between an identifier and characteristic information of a control;

[0013] A storage unit is used to store the identifier table formed by the at least one identifier table entry.

[0014] The electronic device provided in an embodiment of the present application includes: a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute any one of the above-mentioned methods for identifying a control.

[0015] The computer-readable storage medium provided in the embodiment of the present application is used to store a computer program, and the computer program is executed by a processor to implement any of the above-mentioned methods for identifying a control.

[0016] In the technical solution of the embodiment of the present application, the analysis program is loaded into the target application, and the target application can be automatically analyzed by the analysis program, so as to obtain the control tree corresponding to the interface of the target application and the characteristic information of at least some controls in the control tree; for each control in at least some of the controls, an identifier is assigned to the control, and an identifier table item is generated based on the identifier and characteristic information of the control, and the identifier table item is used to express the corresponding relationship between the identifier and characteristic information of the control; the identifier table formed by at least one identifier table item is saved. The technical solution of the embodiment of the present application is adopted to ensure that each control in the control tree has a corresponding identifier, so that it is convenient to write the required program (such as a debugger, a test program, etc.) based on the identifier of the control, and expand the scope of the controllable control. In addition, since the identifier of the control is stored in an identifier table independent of the target application, it is not necessary to modify the target application to achieve the management of the identifier of the control. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 This is a flowchart of a method for identifying a control provided in an embodiment of the present application. Figure 1 ;

[0018] Figure 2 is a schematic diagram of controls in a UI interface provided in an embodiment of the present application;

[0019] Figure 3It is a schematic diagram of a table of control numbers and identifiers provided in an embodiment of the present application;

[0020] Figure 4 This is a flowchart of a method for identifying a control provided in an embodiment of the present application. Figure 2 ;

[0021] Figure 5 It is a schematic diagram of the structure of a device for identifying a control provided in an embodiment of the present application;

[0022] Figure 6 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;

[0023] Figure 7 It is a schematic structural diagram of the chip of an embodiment of the present application. DETAILED DESCRIPTION

[0024] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0025] It should be noted that in the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the embodiments of the present application, the character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0026] It should be understood that the "indication" mentioned in the embodiments of the present application can be a direct indication, an indirect indication, or an indication of an association relationship. For example, A indicates B, which can mean that A directly indicates B, for example, B can be obtained through A; it can also mean that A indirectly indicates B, for example, A indicates C, and B can be obtained through C; it can also mean that there is an association relationship between A and B.

[0027] In the description of the embodiments of the present application, the term "corresponding" may indicate a direct or indirect correspondence between two items, or an association relationship between the two items, or a relationship between indication and being indicated, configuration and being configured, and the like.

[0028] To facilitate understanding of the technical solutions of the embodiments of the present application, the technical solutions of the present application are described in detail below through specific embodiments. The above related technologies can be combined arbitrarily with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application. The embodiments of the present application include at least part of the following contents.

[0029] The key technical terms in the embodiments of the present application are explained below.

[0030] Qt application: A Qt application is an application developed using Qt. Here, Qt is a cross-platform C++ graphical user interface (GUI) application development framework. Qt application can also be called Qt GUI application.

[0031] Qt Quick: Qt Quick is an advanced user interface technology provided by Qt. It can be used to create UI for mobile devices. Qt Quick provides all the necessary basic types for creating UI based on qml tools. Qml tools provide qml engine and language parsing foundation.

[0032] QObject: QObject is the base class of all Qt classes. Most Qt classes inherit from QObject.

[0033] Introspection: Introspection is the ability of object-oriented languages ​​to query information about objects during runtime.

[0034] Figure 1 This is a flowchart of a method for identifying a control provided in an embodiment of the present application. Figure 1 ,like Figure 1 As shown, the method for identifying a control comprises the following steps:

[0035] Step 101: Load the analysis program into the target application.

[0036] In the embodiment of the present application, the analysis program may also be referred to as a parsing program or an analysis conversion program or an analysis tool or a parsing tool or an analysis conversion tool. The present application does not limit the name of the analysis program.

[0037] In the embodiment of the present application, the target application is a Qt application. The Qt application uses a control tree to organize the hierarchy and position relationship of controls. As an example, the UI interface of the Qt application uses Figure 2 The widget tree is constructed as shown. Widget 1 has two child widgets, namely, Widget 2 and Widget 3; Widget 2 has one child widget, namely, Widget 4. Widget 3 has two child widgets, namely, Widget 5 and Widget 6. Here, Widget 1 is the root widget. Here, the widget can also be called a Qt widget.

[0038] In some optional implementations, the target application is a Qt Quick application. Here, the Qt Quick application refers to an application written using the Qt Quick tool.

[0039] In an embodiment of the present application, the analysis program includes a dynamic link library. The dynamic link library of the analysis program is loaded into the target application. Further, the dynamic link library of the analysis program is loaded into the running target application, so that the dynamic link library will be loaded into the process space of the Qt application. Here, the running target application will display the corresponding interface.

[0040] It should be noted that loading the analysis program into the target application can also be described as injecting the analysis program into the target application, or attaching the analysis program to the target application, which have the same meaning.

[0041] In an embodiment of the present application, there may be many ways to load the dynamic link library of the analysis program into the target application. Two methods are listed below. It should be noted that the present application is not limited to the following two methods.

[0042] Method 1: Use a debugger to load the dynamic link library of the analysis program into the target application.

[0043] For example, the debugger uses the gdb command to call the dlopen function to load the dynamic link library of the analysis program into the target application.

[0044] Method 2: Use a dynamic linker to load the dynamic link library of the analysis program into the target application.

[0045] For example, a dynamic linker is used to preload the dynamic link library of the analysis program into the target application.

[0046] Step 102: Analyze the target application using the analysis program to obtain a control tree of the target application and feature information of at least some controls in the control tree.

[0047] In some optional implementations, at least some of the controls in the control tree are all the controls in the control tree. In this case, feature information of all controls in the control tree is obtained, and corresponding identifiers are subsequently assigned to all controls.

[0048] In some optional implementations, at least some of the controls in the control tree are some controls in the control tree that are not assigned identifiers. In this case, feature information of some of the controls in the control tree that are not assigned identifiers is obtained, and corresponding identifiers are subsequently assigned to these some of the controls.

[0049] In the embodiment of the present application, the target application is analyzed by the analysis program to obtain the control tree of the target application and the characteristic information of at least some controls in the control tree, which can be achieved by the following steps:

[0050] Step 1) using the analysis program to search for at least one window displayed by the target application, each window in the at least one window corresponds to a control tree;

[0051] Step 2) Using the analysis program, determine the control tree corresponding to the at least one window, and determine feature information of at least part of the controls in the control tree.

[0052] The following describes how to generate a control tree for a target application and how to obtain control feature information, assuming that the target application is a Qt Quick application.

[0053] In the embodiment of the present application, the target application is a running Qt Quick application. Here, the QtQuick application can provide one or more of the following methods: allWindows method, topLevelWindows method, focusWindow method, contentItem method of QQuickWindow. The functions of these methods will be described in the following related schemes.

[0054] Here, the allWindows method, the topLevelWindows method, and the focusWindow method belong to the methods of the global variable qApp of type QG uiApplication.

[0055] The above step 1) can be implemented in the following ways: using the analysis program to call the allWindows method to find all windows displayed by the target application; or using the analysis program to call the topLevelWindows method to find all top-level windows displayed by the target application; or using the analysis program to call the focusWindow method to find the focus window displayed by the target application; wherein the allWindows method, the topLevelWindows method and the focusWindow method are methods provided by the Qt Quick application.

[0056] The above step 2) can be implemented in the following manner: 2-1) Using the analysis program to call the contentItem method of QQuickWindow to traverse the at least one window, and obtain the corresponding Qt Quick control tree, wherein the Qt Quick control tree includes at least one Qt Quick control; wherein the contentItem method of QQuickWindow is a method provided by the Qt Quick application. 2-2) Using the analysis program to call the introspection capability of QObject, obtain the feature information of at least some controls in the control tree.

[0057] Here, it should be noted that the contentItem method of QQuickWindow can be used to traverse and find all the controls in the control tree. The introspection ability of QObject can be used to find the characteristic information of the control. In addition, based on the characteristic information of the control, it can be determined whether the control is the root control. After determining the root control, other controls in the control tree can be found based on the root control, and finally all the controls in the control tree can be found.

[0058] Here, it should be noted that the characteristic information of the control includes at least one of the following: properties, methods, and positions. Among them, for a control, the number of its properties can be 1 or more, and the number of its methods can also be 1 or more. For a control, its position refers to its position in the control tree, and its position can be represented by two-dimensional coordinates. As an example, position: (N×M) means that the control is the Mth control at the Nth level, where the position of the root control defaults to (1×1).

[0059] Here, it should be noted that, for some controls in the control tree, the characteristic information of these controls may include properties, methods and positions, while for other controls in the control tree, the characteristic information of these controls may only include positions.

[0060] Step 103: Assign an identifier to each control of at least some of the controls, and generate at least one identifier table entry based on the identifier and characteristic information of each control of at least some of the controls, wherein each identifier table entry in the at least one identifier table entry is used to express the correspondence between the identifier and characteristic information of a control.

[0061] In the embodiment of the present application, the identifier allocated to the control is used to uniquely identify a control within the control tree.

[0062] In the embodiment of the present application, the identifier assigned to the control may be, but is not limited to, composed of letters, numbers, symbols, etc. The present application does not limit the composition of the identifier, and any content that can uniquely identify the control can be used as the identifier of the control.

[0063] As an example: The control tree corresponding to the UI interface of a running Qt application is as follows Figure 3 As shown on the left side of the figure, the root control of the control tree is Qt control 1. Qt control 1 has two child controls, namely Qt control 2 and Qt control 3; Qt control 2 has one child control, namely Qt control 4. Qt control 3 has two child controls, namely Qt control 5 and Qt control 6. In the control tree, Qt control 1, Qt control 3 and Qt control 6 are not assigned corresponding identifiers. Through the technical solution of the embodiment of the present application, corresponding identifiers are respectively assigned to Qt control 1, Qt control 3 and Qt control 6 in the control tree, among which Qt control 1 is assigned corresponding identifier A, Qt control 3 is assigned corresponding identifier B, and Qt control 6 is assigned corresponding identifier C. For Qt control 1, the correspondence between its identifier A and feature information (i.e., attribute a, attribute b, method a, position: 1×1) forms an identifier table entry; for Qt control 3, the correspondence between its identifier B and feature information (i.e., attribute c, method b, position: 2×2) forms an identifier table entry; for Qt control 6, the correspondence between its identifier C and feature information (i.e., position: 3×3) forms an identifier table entry. The identifier table formed by the above three identifier table entries is as follows: Figure 3 as shown on the right side of the diagram.

[0064] Step 104: Save the identifier table formed by the at least one identifier table entry.

[0065] Here, the identifier table may be saved in a file or a database. It should be noted that the present application does not limit the location where the identifier table is saved.

[0066] Further, in some optional embodiments, after the target application is restarted, all controls are traversed starting from the root control of the control tree, and when the target control is traversed, an identifier table entry that matches the characteristic information of the target control is searched from the identifier table based on the characteristic information of the target control, and the identifier in the matching identifier table entry is assigned to the target control; wherein the identifier of the target control is used to call the target control when writing a specific program, and the specific program includes at least one of the following: a debugging program, a testing program.

[0067] Here, the identifier of the control is associated with the characteristic information in the identifier table item, so that after the target application is restarted, the identifier table can be searched according to the characteristic information of the control to find the identifier corresponding to the control. In this way, even if the target application is restarted, the same control will always use the same identifier. In this way, the debugger or test program will also use the same identifier for the same control, avoiding the problem of needing to rewrite the debugger or test program due to identifier changes. In addition, the characteristic information of the control can also be used to detect whether the control tree has changed due to source code modification, thereby determining that the previously assigned identifier is unavailable and needs to be reallocated.

[0068] In the technical scheme of the embodiment of the present application, it is possible to assign a globally unique identifier to an unnamed control without modifying the Qt application, and manage the assigned identifier. The technical scheme of the embodiment of the present application can support both the Qt application with source code and the Qt application without source code. In addition, for the Qt application with only binary files, the technical scheme of the embodiment of the present application can also be used to assign identifiers to controls, so as to facilitate the writing of required programs (such as debuggers, test programs, etc.) based on the identifiers of the controls. On the other hand, when the required programs (such as debuggers, test programs, etc.) are written, the controls that were not originally assigned identifiers can also be called by dynamically assigned identifiers, which expands the scope of controllable controls. On the other hand, since the identifiers assigned to the controls are managed separately in an identifier table independent of the Qt application, there is no need to modify the source code of the Qt application.

[0069] The technical solution of the embodiment of the present application is illustrated below with reference to specific application examples.

[0070] Application Examples

[0071] Figure 4 This is a flowchart of a method for identifying a control provided in an embodiment of the present application. Figure 2 ,like Figure 4 As shown, the method comprises the following steps:

[0072] Step 401: Load the analysis program into the Qt Quick application.

[0073] Here, the analysis program is loaded into the process space of the Qt application to be analyzed, and the analysis program is a dynamic link library.

[0074] In some alternative implementations, the analysis program can be loaded into a Qt Quick application using a debugger.

[0075] In some alternative implementations, the analysis program can be loaded into the Qt Quick application using a dynamic linker.

[0076] Step 402: Find the window displayed in the UI interface of the Qt Quick application through the analysis program.

[0077] In some optional implementations, the allWindows method may be called to search for all windows of a Qt Quick application.

[0078] In some optional implementations, the topLevelWindows method may be called to find all top-level windows of a Qt Quick application.

[0079] In some optional implementations, the focusWindow method may be called to find the focus window of the Qt Quick application.

[0080] Here, the allWindows method, the topLevelWindows method, and the focusWindow method belong to the methods of the global variable qApp of type QG uiApplication.

[0081] Step 403: Analyze the window displayed in the UI interface through an analysis program to determine the corresponding Qt Quick control tree.

[0082] Here, each window in the UI interface corresponds to a control. Figure 2 For example, the UI interface includes 6 controls, namely control 1, control 2, control 3, control 4, control 5 and control 6. Use the contentItem method of QQuickWindow to traverse all windows and determine the following: Figure 3 The control tree shown.

[0083] Step 404: The analysis program calls the introspection function of QObject to obtain the feature information of the control.

[0084] Here, the characteristic information of the control includes at least one of the following: property, method, and position.

[0085] It should be noted that the present application does not limit the execution order of step 404 and step 403. Step 404 and step 403 may be executed simultaneously, or step 403 may be executed first and then step 404, or step 404 may be executed first and then step 403.

[0086] Step 405: Assign a unique identifier to the control.

[0087] Step 406: Create an identifier table entry based on the identifier and feature information of the control.

[0088] Here, the identifier table entry is used to express the correspondence between the identifier and the feature information of the control. This correspondence is a one-to-one correspondence, that is, one identifier corresponds to a set of feature information.

[0089] Step 407: Save the identifier table formed by the multiple identifier table entries.

[0090] Here, the identifier table can be saved to a file or a database.

[0091] The technical solution of the embodiment of the present application expands the scope of debuggable and testable controls by assigning identifiers to controls without identifiers, so that each control in the control tree can be called. On the other hand, without modifying the Qt application, an identifier table is established externally, so that Qt applications with source code do not need to be frequently compiled, and Qt applications without source code can be debugged or tested. On the other hand, the one-to-one correspondence between the characteristic information of the control and the identifier is maintained through the identifier table, so that after the Qt application is restarted, the same control can also use the same identifier without modifying the debugging or testing program.

[0092] Figure 5 Schematic diagram of the structure of the device for identifying a control provided in an embodiment of the present application, which is applied to electronic devices such as Figure 5 As shown, the device for identifying the control includes:

[0093] A loading unit 501, used to load the analysis program into the target application;

[0094] An analyzing unit 502 is used to analyze the target application using the analyzing program to obtain a control tree of the target application and feature information of at least some controls in the control tree;

[0095] A generating unit 503 is used to assign an identifier to each control of the at least part of the controls, and generate at least one identifier table entry based on the identifier and characteristic information of each control of the at least part of the controls, wherein each identifier table entry in the at least one identifier table entry is used to express a correspondence between an identifier and characteristic information of a control;

[0096] The saving unit 504 is configured to save the identifier table formed by the at least one identifier table entry.

[0097] In some optional implementations, the analysis program includes a dynamic link library; the loading unit 501 is specifically used to load the dynamic link library of the analysis program into the target application.

[0098] In some optional implementations, the loading unit 501 is specifically used to:

[0099] Use a debugger to load the dynamic link library of the analysis program into the target application; or,

[0100] The dynamic link library of the analysis program is loaded into the target application using a dynamic linker.

[0101] In some optional implementations, the analysis unit 502 is specifically configured to:

[0102] Using the analysis program to search for at least one window displayed on the interface of the target application, each window in the at least one window corresponds to a control tree;

[0103] The analysis program is used to determine a control tree corresponding to the at least one window, and to determine feature information of at least part of the controls in the control tree.

[0104] In some optional implementations, the target application is a running Qt Quick application.

[0105] In some optional implementations, the analysis unit 502 is specifically configured to:

[0106] Using the analysis program to call the allWindows method to search for all windows displayed on the interface of the target application; or,

[0107] Using the analysis program to call the topLevelWindows method to find all top-level windows displayed in the interface of the target application; or,

[0108] Using the analysis program to call the focusWindow method to find the focus window displayed on the interface of the target application;

[0109] The allWindows method, the topLevelWindows method, and the focusWindow method are methods provided by the Qt Quick application.

[0110] In some optional implementations, the analysis unit 502 is specifically configured to:

[0111] Using the analysis program to call the contentItem method of QQuickWindow to traverse the at least one window, and obtain the corresponding control tree;

[0112] The analysis program is used to call the introspection capability of QObject to obtain feature information of at least part of the controls in the control tree.

[0113] In some optional embodiments, the device further comprises:

[0114] A search unit 505 is used to search for an identifier corresponding to the characteristic information of the target control from the identifier table based on the characteristic information of the target control after the target application is restarted, and the identifier is used to write a debugging program or a testing program for the target application; wherein the target control is one of the controls in at least some of the controls in the control tree.

[0115] In some optional implementations, the characteristic information of the control includes at least one of the following: attributes, methods, and locations.

[0116] In some optional implementations, at least some of the controls in the control tree are all the controls in the control tree; or, at least some of the controls in the control tree are some of the controls in the control tree that are not assigned identifiers.

[0117] Those skilled in the art should understand that Figure 5 The implementation functions of each unit in the device for identifying a control shown can be understood by referring to the relevant description of the aforementioned method for identifying a control. Figure 5 The functions of each unit in the device for identifying a control as shown may be implemented by a program running on a processor, or may be implemented by a specific logic circuit.

[0118] Figure 6 600 is a schematic structural diagram of an electronic device 600 provided in an embodiment of the present application. The electronic device may be a mobile phone, a tablet computer, a wearable device, etc. Figure 6 The electronic device 600 shown includes a processor 610, which can call and run a computer program from a memory to implement the method in the embodiment of the present application.

[0119] Alternatively, if Figure 6 As shown, the electronic device 600 may further include a memory 620. The processor 610 may call and run a computer program from the memory 620 to implement the method in the embodiment of the present application.

[0120] Alternatively, if Figure 6 As shown, the electronic device 600 may further include a transceiver 630, and the processor 610 may control the transceiver 630 to communicate with other devices, specifically, may send information or data to other devices, or receive information or data sent by other devices.

[0121] Figure 7 It is a schematic structural diagram of the chip of an embodiment of the present application. Figure 7 The chip 700 shown includes a processor 710, which can call and run a computer program from a memory to implement the method in the embodiment of the present application.

[0122] Alternatively, if Figure 7 As shown, the chip 700 may further include a memory 720. The processor 710 may call and run a computer program from the memory 720 to implement the method in the embodiment of the present application.

[0123] The memory 720 may be a separate device independent of the processor 710 , or may be integrated into the processor 710 .

[0124] Optionally, the chip 700 may further include an input interface 730. The processor 710 may control the input interface 730 to communicate with other devices or chips, and specifically, may obtain information or data sent by other devices or chips.

[0125] Optionally, the chip 700 may further include an output interface 740. The processor 710 may control the output interface 740 to communicate with other devices or chips, and specifically, may output information or data to other devices or chips.

[0126] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0127] It should be understood that the processor of the embodiment of the present application may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by the hardware integrated logic circuit or software instructions in the processor. The above processor can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor are combined and performed. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, and other mature storage media in the art. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0128] It can be understood that the memory in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0129] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program.

[0130] Optionally, the computer-readable storage medium can be applied to the network device in the embodiments of the present application, and the computer program enables the computer to execute the corresponding processes implemented by the network device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.

[0131] Optionally, the computer-readable storage medium can be applied to the mobile terminal / terminal device in the embodiments of the present application, and the computer program enables the computer to execute the corresponding processes implemented by the mobile terminal / terminal device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.

[0132] An embodiment of the present application also provides a computer program product, including computer program instructions.

[0133] Optionally, the computer program product can be applied to the network device in the embodiments of the present application, and the computer program instructions enable the computer to execute the corresponding processes implemented by the network device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.

[0134] Optionally, the computer program product can be applied to the mobile terminal / terminal device in the embodiments of the present application, and the computer program instructions enable the computer to execute the corresponding processes implemented by the mobile terminal / terminal device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.

[0135] The embodiment of the present application also provides a computer program.

[0136] Optionally, the computer program can be applied to the network device in the embodiments of the present application. When the computer program runs on a computer, the computer executes the corresponding processes implemented by the network device in the various methods in the embodiments of the present application. For the sake of brevity, they are not described here.

[0137] Optionally, the computer program can be applied to the mobile terminal / terminal device in the embodiments of the present application. When the computer program runs on the computer, the computer executes the corresponding processes implemented by the mobile terminal / terminal device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.

[0138] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0139] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0140] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0141] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0142] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0143] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0144] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for identifying a control, characterized in that: The method comprises: Loading an analysis program into a target application, analyzing the target application using the analysis program, obtaining a control tree of the target application and feature information of at least some controls in the control tree, wherein the target application is a Qt application, and at least some controls in the control tree are controls in the control tree that do not have identifiers assigned to them; Assigning an identifier to each control in the at least part of the controls, and generating at least one identifier table entry based on the identifier and characteristic information of each control in the at least part of the controls, wherein each identifier table entry in the at least one identifier table entry is used to express a corresponding relationship between an identifier and characteristic information of a control; Saving the identifier table formed by the at least one identifier table entry; The method further comprises: After the target application is restarted, all controls are traversed starting from the root control of the control tree. When a target control is traversed, an identifier table entry matching the characteristic information of the target control is searched from the identifier table based on the characteristic information of the target control, and the identifier in the matching identifier table entry is assigned to the target control; The identifier of the target control is used to call the target control when writing a specific program.

2. The method according to claim 1, characterized in that The analysis program includes a dynamic link library; The step of loading the analysis program into the target application comprises: The dynamic link library of the analysis program is loaded into the target application.

3. The method according to claim 2, characterized in that Loading the dynamic link library of the analysis program into the target application comprises: Use a debugger to load the dynamic link library of the analysis program into the target application; or, The dynamic link library of the analysis program is loaded into the target application using a dynamic linker.

4. The method according to claim 1, characterized in that: The using the analysis program to analyze the target application to obtain a control tree of the target application and feature information of at least some controls in the control tree includes: Using the analysis program to search for at least one window displayed by the target application, each window in the at least one window corresponds to a control tree; The analysis program is used to determine a control tree corresponding to the at least one window, and to determine feature information of at least part of the controls in the control tree.

5. The method according to claim 4, characterized in that The target application is a running QtQuick application.

6. The method according to claim 5, characterized in that The step of using the analysis program to search for at least one window displayed on the interface of the target application program includes: Using the analysis program to call the allWindows method to search for all windows displayed on the interface of the target application; or, Using the analysis program to call the topLevelWindows method to find all top-level windows displayed in the interface of the target application; or, Using the analysis program to call the focusWindow method to find the focus window displayed on the interface of the target application; Among them, the allWindows method, the topLevelWindows method and the focusWindow method are methods provided by the QtQuick application.

7. The method according to claim 5, characterized in that The using the analysis program to determine the control tree corresponding to the at least one window, and determining feature information of at least part of the controls in the control tree, includes: Using the analysis program to call the contentItem method of QQuickWindow to traverse the at least one window, and obtain the corresponding control tree; The analysis program is used to call the introspection capability of QObject to obtain feature information of at least part of the controls in the control tree.

8. The method according to any one of claims 1 to 7, characterized in that The specific program includes at least one of the following: a debugging program and a testing program.

9. The method according to any one of claims 1 to 7, characterized in that At least some of the controls in the control tree are all the controls in the control tree.

10. A device for identifying a control, characterized in that: The device comprises: A loading unit, used for loading the analysis program into a target application, wherein the target application is a Qt application; An analysis unit, configured to analyze the target application using the analysis program to obtain a control tree of the target application and feature information of at least some controls in the control tree, wherein at least some controls in the control tree are some controls in the control tree that are not assigned identifiers; a generating unit, configured to assign an identifier to each control of the at least some of the controls, and to generate at least one identifier table entry based on the identifier and characteristic information of each control of the at least some of the controls, wherein each identifier table entry of the at least one identifier table entry is used to express a correspondence between an identifier and characteristic information of a control; a storage unit, configured to store the identifier table formed by the at least one identifier table entry; The system further comprises a search unit, which is used to traverse all controls starting from the root control of the control tree after the target application is restarted, and when traversing to the target control, search the identifier table entry matching the characteristic information of the target control from the identifier table based on the characteristic information of the target control, and assign the identifier in the matching identifier table entry to the target control; The identifier of the target control is used to call the target control when writing a specific program.

11. An electronic device, characterized in that: include: A processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory to execute the method as claimed in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The method according to claim 1 is used for storing a computer program, wherein the computer program is executed by a processor to implement the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Automatic testing method and device of user interface

    CN103309797A

  • Application program debugging method based on Android system, and terminal equipment

    CN105630665A