Test method, device and equipment of electronic device and readable storage medium
By simulating the user interface on a host computer to obtain reference images and comparing them pixel by pixel with actual images, the problem of inaccurate reference images in electronic device testing is solved, thus improving the accuracy and efficiency of test results.
Patent Information
- Application Number
- CN202111345186.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-12
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2041-11-12
AI Technical Summary
In the testing of electronic devices, inaccurate test results are caused by inaccurate reference images, and the reliability of visual observation is not high, which can easily lead to visual fatigue and visual errors.
The host computer simulates the user interface, obtains the first simulated interface image as a reference image, and compares it pixel by pixel with the second interface image actually displayed by the electronic device to determine whether there is any abnormality in the electronic device.
This improves the accuracy of test results, avoids the effects of visual fatigue and visual errors, and ensures accuracy and efficiency.
Smart Images

Figure CN116126671B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of communications, and specifically relates to a testing method, apparatus, device, and readable storage medium for electronic devices. Background Technology
[0002] The user interface (UI) is the medium through which a system and a user interact and exchange information. It enables the conversion between the internal form of information and a form that is acceptable to humans.
[0003] In the testing of electronic devices, the process typically begins by acquiring images of the device's UI during display. Then, reference images are selected from an image library, and these are manually compared to the UI images to determine if any abnormalities exist. However, directly obtaining reference images from the image library during image comparison can lead to inaccurate results. Furthermore, visual observation is unreliable, susceptible to factors such as eye strain and visual errors, which can delay troubleshooting. Summary of the Invention
[0004] The purpose of this embodiment is to provide a testing method, apparatus, device, and readable storage medium for electronic devices, which can solve the problem of inaccurate test results caused by inaccurate reference images during the testing process of electronic devices.
[0005] In a first aspect, embodiments of this application provide a testing method for an electronic device, applied to a host computer, the method comprising:
[0006] Upon receiving a test command, simulate the display of the user interface;
[0007] Obtain a first interface image of the simulated user interface, and use the first interface image as a reference image;
[0008] The target image is acquired from the electronic device; the target image includes a second interface image actually displayed and acquired by the electronic device when executing the test command;
[0009] The pixels in the target image and the pixels in the reference image are compared to obtain a comparison result, and the electronic device is used to determine whether there is an abnormality based on the comparison result.
[0010] Secondly, embodiments of this application provide another testing method for electronic devices, applied to electronic devices, the method comprising:
[0011] Receive test commands sent by the host computer that correspond to the user interface;
[0012] In response to the test command, the user interface is displayed, and a second interface image of the user interface is acquired;
[0013] The second interface image is sent to the host computer as the target image, so that the host computer compares the pixels in the target image with the pixels in the reference image, obtains the comparison result, and determines whether the user interface is abnormal based on the comparison result; the reference image includes the first interface image obtained by the host computer when simulating the display of the user interface after receiving the test instruction.
[0014] Thirdly, embodiments of this application provide a testing device for an electronic device, configured on a host computer, the device comprising:
[0015] The receiving module is used to simulate the display of the user interface upon receiving a test command;
[0016] The first acquisition module is used to acquire a first interface image of the simulated user interface and use the first interface image as a reference image.
[0017] The second acquisition module is used to acquire a target image from the electronic device; the target image includes a second interface image actually displayed and acquired by the electronic device when executing the test command;
[0018] The comparison module is used to compare the pixels in the target image with the pixels in the reference image to obtain a comparison result, so as to determine whether the electronic device has any abnormalities based on the comparison result.
[0019] Fourthly, embodiments of this application provide another testing apparatus for an electronic device, disposed on the electronic device, the apparatus comprising:
[0020] The receiving module is used to receive test commands sent by the host computer that correspond to the user interface;
[0021] The acquisition module is configured to, in response to the test command, display the user interface and acquire a second interface image of the user interface;
[0022] The sending module is used to send the second interface image as a target image to the host computer, so that the host computer compares the pixels in the target image with the pixels in the reference image, obtains the comparison result, and determines whether the user interface is abnormal based on the comparison result; the reference image includes a first interface image obtained by the host computer when simulating the display of the user interface after receiving the test instruction.
[0023] Fifthly, embodiments of this application provide an electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.
[0024] In a sixth aspect, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.
[0025] In a seventh aspect, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.
[0026] In this embodiment, upon receiving a test command, the host computer simulates a user interface, acquires a first interface image of the simulated user interface, and uses this first interface image as a reference image to acquire a target image from the electronic device. Then, the pixels in the target image are compared with the pixels in the reference image to obtain a comparison result. Based on the comparison result, it is determined whether the electronic device has any abnormalities. During the testing of the electronic device, simulating the user interface and acquiring a reference image through the host computer ensures the acquisition of an accurate reference image, resolving the problem of inaccurate reference images and thus improving the accuracy of the test results. Attached Figure Description
[0027] Figure 1 A flowchart illustrating the steps of a testing method for an electronic device provided in this application embodiment;
[0028] Figure 2 A flowchart illustrating a testing method for an electronic device provided in an embodiment of this application;
[0029] Figure 3 A schematic diagram of the structure of a testing device for an electronic device provided in an embodiment of this application;
[0030] Figure 4 A schematic diagram of the structure of a testing device for another electronic device provided in an embodiment of this application;
[0031] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0032] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0033] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.
[0034] The testing method for the electronic device provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0035] Reference Figure 1 , Figure 1 A flowchart illustrating the steps of a testing method for an electronic device provided in this application embodiment, the method may include:
[0036] Step 101: Upon receiving the test instruction, simulate the display of the user interface.
[0037] Step 102: Obtain the first interface image of the simulated user interface and use the first interface image as a reference image.
[0038] The electronic device can be a terminal device with display capabilities, such as an in-vehicle terminal. The user interface is the interface displayed by the electronic device during actual operation; it can be the user interface within the electronic device's system program. Test commands correspond to the user interface and are used to control the electronic device to display the user interface. When the electronic device receives a test command, it can respond by displaying the user interface.
[0039] In this embodiment, the testing method can be implemented by a host computer, such as a computer, which is used to simulate the user interface of an electronic device. For example, the host computer may have a development tool installed, which can simulate the operation of the system program in the electronic device and display the user interface. Users can operate the host computer using input devices such as a keyboard and mouse, sending test commands to the host computer, or sending test commands to the host computer via wireless communication using a mobile phone or other computer. After receiving the test command, the host computer can respond by launching the development tool, simulating the operation of the system program, and displaying the corresponding user interface on the host computer. In practical applications, the specific form of the test command, the specific method of the host computer receiving the test command, and the specific process of simulating the display of the user interface can be set according to requirements; this embodiment does not impose any restrictions on these aspects.
[0040] In one embodiment, after responding to a test command and simulating the display of a user interface, the host computer can perform a screenshot operation on the simulated user interface to capture a screenshot of the user interface and obtain a first interface image. After obtaining the first interface image, it can be saved as a reference image. Specific methods for obtaining the first interface image include, but are not limited to, the examples described above, and this embodiment does not limit them.
[0041] Step 103: Acquire the target image from the electronic device.
[0042] The target image includes the second interface image actually displayed by the electronic device when executing test instructions.
[0043] In this embodiment, the host computer can acquire the interface image of the electronic device when it actually displays the user interface, and use the acquired interface image as the target image. For example, the user can establish a communication connection between the host computer and the electronic device using a Universal Serial Bus (USB) interface, a Serial Peripheral Interface (SPI), a Universal Asynchronous Receiver / Transmitter (UART) interface, a Controller Area Network (CAN) interface, or Wireless Fidelity (WiFi). After receiving a test command, the host computer can forward the test command to the electronic device. Upon receiving the test command, the electronic device can respond to the test command, display the user interface, and perform a screenshot operation on the actually displayed user interface to obtain a screenshot of the actually displayed user interface, thus obtaining a second interface image. After obtaining the second interface image, the electronic device can send the second interface image to the host computer, which can receive the second interface image and save it as the target image.
[0044] It should be noted that the test command sent to the electronic device is the same as the test command sent to the host computer, thus enabling both the host computer and the electronic device to display the same user interface and acquire the same interface image, resulting in a first interface image and a second interface image, respectively. In practical applications, users can also directly operate the electronic device and send test commands to it. The method by which the host computer acquires the target image from the electronic device may include, but is not limited to, the examples described above; this embodiment does not impose any restrictions on this.
[0045] Optionally, the method may further include:
[0046] The host computer sends format parameters to the electronic device so that the electronic device can acquire the second interface image according to the image format specified by the format parameters.
[0047] When the electronic device receives the format parameters sent by the host computer, it acquires the second interface image according to the image format specified by the format parameters.
[0048] In one embodiment, the host computer can acquire a first interface image in a preset image format to obtain a reference image. For example, the preset image format can be a bitmap (BMP) format or a portable network graphics format (PNG). After taking a screenshot of the simulated user interface, the host computer can save the screenshot in BMP format to obtain a first interface image in BMP format. During the process of sending test commands to the electronic device, the host computer can simultaneously send format parameters corresponding to the BMP format to the electronic device. Correspondingly, after receiving the test commands and format parameters, the electronic device can display the user interface. After taking a screenshot of the user interface, it can save the screenshot in BMP format according to the format parameters to obtain a second interface image in BMP format, and then send the second interface image in BMP format to the host computer. The format parameters can also be sent to the electronic device before or after sending the test commands.
[0049] In this embodiment of the invention, the host computer can acquire a reference image in a preset image format, and at the same time send format parameters to the electronic device so that the electronic device can acquire a target image in the corresponding format. This allows the reference image and the target image to have the same image format. When the reference image and the target image have the same image format, the convenience and accuracy of the comparison can be further improved during the image comparison process.
[0050] Step 104: Compare the pixels in the target image with the pixels in the reference image to obtain the comparison results, and determine whether there is any abnormality in the electronic device based on the comparison results.
[0051] In this embodiment, after acquiring the reference image and the target image, the host computer can compare two pixels at the same position between the target image and the reference image to determine the inconsistent target pixels. For example, in a BMP format image, the pixel value of each pixel consists of the channel values of three channels: Red (R), Green (G), and Blue (B), or four channels: R, G, B, and alpha (α). During the comparison process, based on the coordinates of each pixel, the pixel values of two pixels at the same coordinate position in the two images are compared sequentially. If the difference between the pixel values of two pixels is greater than or equal to a preset threshold, the two pixels are determined to be different; otherwise, they are determined to be the same. For example, the preset difference can be 10. If, in the reference image and the target image, two pixels at the same coordinate position have different values for the same pixel: the R channel value in the reference image is 240, the G channel value is 50, and the B channel value is 45; and the R channel value in the target image is between 230 and 250, the G channel value is between 40 and 60, and the B channel value is between 35 and 55, then the two pixels are considered to have the same pixel value. Otherwise, they are considered to have different pixel values. This process is repeated to compare two pixels at the same coordinate position in both the target and reference images to identify all different target pixels. As another example, in a PMG format image, the pixel value of each pixel is determined by its color number in the color table. During the comparison, the color values of two pixels at the same coordinate position in both images are compared sequentially based on the coordinates of each pixel. If the difference between the color values of two pixels is greater than or equal to a preset threshold, the two pixels are considered to be different; otherwise, they are considered to be the same. The target image and the reference image are compared sequentially for each pair of pixels at the same coordinates to identify all distinct target pixels. The specific value of the preset threshold can be set according to the image format; this embodiment does not impose any restrictions on it.
[0052] After identifying all the distinct target pixels, the presence of an electronic device malfunction can be determined based on the coordinates of the target pixels in the target and reference images. For example, if a target area in the user interface is used to display a parameter of the electronic device, and this parameter displays correctly in the simulated user interface on the host computer, then during the comparison process, if the target pixel is located within the target area in the comparison results of the target and reference images, it indicates that the electronic device is malfunctioning and cannot display the parameter correctly. Alternatively, if the number of target pixels included in the target area is greater than a preset number, it can be determined that the electronic device is malfunctioning and cannot display the parameter. Conversely, if the number of target pixels included in the target area is less than the preset number, the electronic device is considered normal. For example, the preset number can be 50. If the target area contains 1000 pixels, and the number of target pixels included in the target area is less than or equal to 50, the electronic device is considered normal. The specific value of the preset number can be set according to requirements, and this embodiment does not limit this. Specific methods for determining whether an electronic device is malfunctioning based on the comparison results may include, but are not limited to, the examples above, and this embodiment does not impose any limitations on these methods.
[0053] In practical applications, the target image and reference image can also be in other image formats. This embodiment uses BMP and PNG formats to save the target image and reference image. Since BMP and PNG formats use lossless compression, they can retain more image details, thereby improving the accuracy of the comparison.
[0054] Optionally, the method may further include:
[0055] Output the comparison results; the comparison results include the coordinates of the target pixel, which includes pixels in the target image and the reference image with a similarity of less than a preset threshold.
[0056] The similarity can be determined based on the difference between the pixel values of two pixels, or it can be determined based on the difference between the color values of two pixels. The larger the difference between the pixel values or color values of two pixels, the smaller the similarity. The specific method for determining the similarity based on the difference can be set according to the requirements, and this embodiment does not impose any restrictions on it.
[0057] In one embodiment, the host computer can output the comparison results between the target image and the reference image. For example, after comparing and determining all different target pixels, the host computer can output the coordinates of all target pixels to obtain a coordinate file, which is the comparison result. Alternatively, the host computer can select one of the target image and the reference image as the reference image, overlay a semi-transparent layer on the reference image, and mark the target pixels and other pixels with different colors in the semi-transparent layer. The specific output format of the comparison result can be set according to requirements, and this embodiment does not limit it.
[0058] In this embodiment of the invention, after obtaining the comparison results of the target image and the reference image, the comparison results can be output, which makes it convenient for users to judge whether the electronic device is abnormal based on the comparison results.
[0059] Optionally, before performing step 104, the method may further include:
[0060] Ensure that the target image and the reference image have the same resolution.
[0061] In one embodiment, before comparing the target image and the reference image, the host computer can first compare the resolutions of the reference image and the target image. After determining that the resolutions of the reference image and the target image are consistent, step 104 is executed to compare the pixels in the reference image and the target image. Figure 2 As shown, Figure 2 This is a flowchart illustrating a testing method for an electronic device provided in this application embodiment. After receiving a test command, the host computer first sends the test command to the electronic device. Then, the host computer can respond to the test command, simulate displaying a user interface, and acquire a reference image. Simultaneously, the electronic device can respond to the test command, actually display the user interface, acquire a target image, and send the target image to the host computer. After acquiring the target image and the reference image, the host computer first determines whether the resolutions of the target image and the reference image are consistent. Specifically, for BMP format target and reference images, after acquiring the reference and target images, the host computer can first compare the sizes of the reference and target images to determine whether their sizes are consistent. If the sizes of the reference and target images are consistent, the resolutions of the reference and target images are determined to be consistent. Then, step 207 is executed to compare the pixels in the reference and target images, and finally, the comparison result is output. For PNG format target and reference images, the resolutions of the target and reference images can be directly compared. If the comparison determines that the resolutions are consistent, step 207 is executed to compare the pixels in the reference and target images. Different methods can be used to determine whether the resolutions of target images and reference images of different formats are consistent, and this embodiment does not impose any restrictions on this.
[0062] Conversely, when the resolutions of the reference image and the target image are inconsistent, the host computer can output a prompt message to the user, indicating that the resolutions of the reference image and the target image are inconsistent. The host computer can also resend a test command to the electronic device when the resolutions of the target image and the reference image are inconsistent. Simultaneously, the host computer sends format parameters to the electronic device, which correspond to the format of the reference image acquired by the host computer. This allows the electronic device to acquire a target image with the same format as the reference image, thus ensuring that the target image and the reference image have the same resolution. In practical applications, when the resolutions of two images are inconsistent, the file sizes of the two images are also inconsistent. When image resolutions are inconsistent, accurate comparison results cannot be obtained during image comparison.
[0063] In this embodiment of the invention, before comparing the pixel of the target image and the reference image, the resolution of the target image and the reference image is compared in advance. Comparing the target image and the reference image at the same resolution can avoid comparing the target image and the reference image when the resolutions are inconsistent, thereby improving the reliability of the comparison results.
[0064] In summary, in this embodiment of the invention, upon receiving a test command, the host computer simulates and displays a user interface to acquire a first interface image of the simulated user interface. Using this first interface image as a reference image, a target image is acquired from the electronic device. Then, the pixels in the target image are compared with the pixels in the reference image to obtain a comparison result. Based on the comparison result, it is determined whether the electronic device exhibits any abnormalities. During the testing of the electronic device, simulating and displaying the user interface through the host computer to acquire a reference image ensures accurate reference images, resolving the problem of inaccurate reference images and thus improving the accuracy of the test results. Furthermore, the comparison between the first and second interface images can be automatically performed by the host computer, resulting in high accuracy and avoiding delays in troubleshooting due to factors such as visual fatigue and visual errors.
[0065] Optionally, step 104 may include:
[0066] Obtain a first region image defined by preset region coordinate parameters from the target image, and obtain a second region image defined by region coordinate parameters from the reference image;
[0067] Compare the pixels in the first region image with the pixels in the second region image.
[0068] In some cases, when determining whether an electronic device is malfunctioning through the user interface, it is only necessary to check whether the displayed content of a specific area in the user interface is normal, such as the target area in the example above.
[0069] In this embodiment, during pixel comparison, the host computer can compare pixels within specific regions of the target image and the reference image to determine if the electronic device is abnormal. Referring to the above example, for the target region in the user interface, the user can pre-set the region coordinate parameters of the target region, which correspond to the coordinates of the target region in the target image and the reference image. The region coordinate parameters may include, for example, a first coordinate parameter and a second coordinate parameter, where the first coordinate parameter is the coordinate of the upper left corner of the target region, and the second coordinate parameter is the coordinate of the lower right corner of the target region. After acquiring the target image, the host computer can first determine the upper left corner coordinate corresponding to the first coordinate parameter and the lower right corner coordinate corresponding to the second coordinate parameter from the target image based on the region coordinate parameters. Further, it can determine the rectangular region image defined by the upper left and lower right corner coordinates as the first region image. Similarly, the second region image can be determined from the reference image. During pixel comparison, the host computer can only compare pixels at the same coordinate positions in the first and second region images to determine target pixels with a similarity less than a preset threshold.
[0070] In this embodiment of the invention, during the comparison of the target image and the reference image, based on the region coordinate parameters, only the pixels in a specific region of the target image and the reference image are compared. Compared with comparing the entire target image and the reference image, the amount of data to be compared can be reduced, thereby improving the comparison efficiency.
[0071] Optionally, step 102 may include: obtaining a second region image defined by the region coordinate parameters in the simulated user interface, and using the second region image as a reference image.
[0072] The method may also include:
[0073] The host computer sends the region coordinate parameters to the electronic device.
[0074] When the electronic device receives the region coordinate parameters sent by the host computer, it acquires the first region image defined by the region coordinate parameters in the displayed user interface.
[0075] In one embodiment, during the acquisition of the reference image, the host computer can directly use the region image defined by the region coordinate parameters in the first interface image as the reference image. Referring to the above example, after acquiring the first interface image, the host computer can, based on the region coordinate parameters, crop a second region image from the first interface image (i.e., the reference image) and save the second region image as the reference image. Correspondingly, the host computer can send the region coordinate parameters to the electronic device, enabling the electronic device to acquire the first region image defined by the region coordinate parameters in the actually displayed user interface and return the first region image as the target image. Specifically, the host computer can send the region coordinate parameters to the electronic device simultaneously with sending the test command. After receiving the test command, the electronic device responds by displaying the user interface and performing a screenshot operation to obtain the second interface image. After obtaining the second interface image, it can crop the target region image from the second interface image based on the region coordinate parameters to obtain the first region image, and then send the first region image as the target image to the host computer. Furthermore, the host computer can compare the target image and the reference image, that is, compare the first region image and the second region image to obtain the comparison result.
[0076] In this embodiment of the invention, the host computer can send region coordinate parameters to the electronic device, enabling the electronic device to crop the target region in the interface image according to the region coordinate parameters and feed the region image back to the host computer. This improves image comparison efficiency while reducing the amount of data transmission between the host computer and the electronic device, thereby improving data transmission efficiency.
[0077] Reference Figure 3 , Figure 3 This is a schematic diagram of a testing device for an electronic device provided in an embodiment of this application. The device 300 is mounted on a host computer and includes:
[0078] The receiving module 301 is used to simulate displaying a user interface when a test command is received.
[0079] The first acquisition module 302 is used to acquire a first interface image of the simulated user interface and use the first interface image as a reference image.
[0080] The second acquisition module 303 is used to acquire a target image from an electronic device; the target image includes a second interface image actually displayed by the electronic device when executing a test command.
[0081] The comparison module 304 is used to compare the pixels in the target image with the pixels in the reference image to obtain the comparison result, so as to determine whether there is any abnormality in the electronic device based on the comparison result.
[0082] Optionally, the device 300 further includes:
[0083] The determination module is used to determine whether the target image and the reference image have the same resolution.
[0084] Optionally, the comparison module 304 is specifically used to obtain a first region image defined by preset region coordinate parameters from the target image, and a second region image defined by region coordinate parameters from the reference image; and to compare the pixels in the first region image and the pixels in the second region image.
[0085] Optionally, the first acquisition module 302 is specifically used to send region coordinate parameters to the electronic device; the region coordinate parameters are used to enable the electronic device to acquire a first region image defined by the region coordinate parameters in the actually displayed user interface, and return the first region image as the target image; acquire a second region image defined by the region coordinate parameters in the simulated user interface, and use the second region image as the reference image.
[0086] Optionally, the device 300 further includes:
[0087] The sending module is used to send format parameters to the electronic device so that the electronic device can obtain the second interface image according to the image format specified by the format parameters.
[0088] Optionally, the device 300 further includes an output module for outputting comparison results; the comparison results include the coordinates of the target pixel, and the target pixel includes pixels in the target image and the reference image with a similarity of less than a preset threshold.
[0089] Reference Figure 4 , Figure 4 This is a schematic diagram of the structure of another testing device for an electronic device provided in an embodiment of this application. The device 400 is disposed on the electronic device and includes:
[0090] The receiving module 401 is used to receive test commands sent by the host computer that correspond to the user interface.
[0091] The acquisition module 402 is used to display the user interface and acquire a second interface image of the user interface in response to the test command.
[0092] The sending module 403 is used to send the second interface image as the target image to the host computer, so that the host computer can compare the pixels in the target image with the pixels in the reference image, obtain the comparison result, and determine whether there is an anomaly in the user interface based on the comparison result; the reference image includes the first interface image obtained by the host computer when simulating the display of the user interface after receiving the test command.
[0093] Optionally, the acquisition module 402 is specifically used to acquire a first region image defined by the region coordinate parameters in the displayed user interface when receiving region coordinate parameters sent by the host computer; wherein, the reference image includes a second region image defined by the region coordinate parameters in the simulated user interface when the host computer receives a test command.
[0094] Optionally, the acquisition module 402 is specifically used to acquire the second interface image according to the image format specified by the format parameters when the format parameters sent by the host computer are received.
[0095] In this embodiment of the invention, upon receiving a test command, the host computer simulates the display of the user interface, acquires a first interface image of the simulated user interface, and uses this first interface image as a reference image to acquire a target image from the electronic device. Then, the pixels in the target image are compared with the pixels in the reference image to obtain a comparison result. Based on the comparison result, it is determined whether the electronic device has any abnormalities. During the testing of the electronic device, simulating the display of the user interface and acquiring the reference image through the host computer ensures the acquisition of an accurate reference image, solving the problem of inaccurate reference images and thus improving the accuracy of the test results.
[0096] The testing device for an electronic device in this application embodiment can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network-attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not impose specific limitations.
[0097] The testing device for an electronic device in this application embodiment can be a device with an operating system. The operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system.
[0098] The testing apparatus for electronic devices provided in this application embodiment can achieve... Figure 1 and Figure 2The various processes implemented in the method implementation examples will not be described again here to avoid repetition.
[0099] like Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 500 includes a processor 501, a memory 502, and a program or instructions stored in the memory 502 and executable on the processor 501. When the program or instructions are executed by the processor 501, they implement the various processes of the above-described test method embodiment of the electronic device and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0100] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0101] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described test method embodiments of the electronic device and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0102] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0103] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described test method embodiment for electronic devices and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0104] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0105] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0106] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0107] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A testing method for electronic equipment, characterized in that, Applications in host computers include: Upon receiving a test command, simulate the display of the user interface; Obtain a first interface image of the simulated user interface, and use the first interface image as a reference image; The target image is acquired from the electronic device; the target image includes a second interface image actually displayed and acquired by the electronic device when executing the test command; The pixels in the target image and the pixels in the reference image are compared to obtain a comparison result, and the electronic device is determined to have any abnormality based on the comparison result; Output the comparison result; the comparison result includes the coordinates of the target pixel, and the target pixel includes pixels in the target image and the reference image whose similarity is less than a preset threshold; The test command sent to the electronic device is the same as the test command sent to the host computer, so that the host computer and the electronic device expect to display the same user interface and obtain the interface image of the same user interface, respectively obtaining the first interface image and the second interface image. The host computer acquires the reference image in a preset image format and simultaneously sends format parameters to the electronic device, enabling the electronic device to acquire the target image in the corresponding format, so that the reference image and the target image have the same image format and the same resolution.
2. The method according to claim 1, characterized in that, The comparison of pixels in the target image and pixels in the reference image includes: Obtain a first region image defined by preset region coordinate parameters from the target image, and obtain a second region image defined by the region coordinate parameters from the reference image; The pixels in the first region image and the pixels in the second region image are compared.
3. The method according to claim 1, characterized in that, Prior to acquiring the target image from the electronic device, the method further includes: Send region coordinate parameters to the electronic device; the region coordinate parameters are used to enable the electronic device to acquire a first region image defined by the region coordinate parameters in the user interface actually displayed, and return the first region image as the target image; The step of acquiring a first interface image of the simulated user interface and using the first interface image as a reference image includes: acquiring a second region image defined by the region coordinate parameters in the simulated user interface and using the second region image as the reference image.
4. A testing method for electronic equipment, characterized in that, Applied to the electronic device, including: Receive test commands sent by the host computer that correspond to the user interface; In response to the test command, the user interface is displayed, and a second interface image of the user interface is acquired; The second interface image is sent to the host computer as the target image, so that the host computer compares the pixels in the target image with the pixels in the reference image, obtains the comparison result, and determines whether the user interface is abnormal based on the comparison result; the reference image includes a first interface image obtained by the host computer when simulating the display of the user interface upon receiving the test command; the comparison result includes the coordinates of the target pixel, and the target pixel includes pixels in the target image and the reference image with a similarity of less than a preset threshold; The test command sent to the electronic device is the same as the test command sent to the host computer, so that the host computer and the electronic device expect to display the same user interface and obtain the interface image of the same user interface, respectively obtaining the first interface image and the second interface image. The host computer acquires the reference image in a preset image format and simultaneously sends format parameters to the electronic device, enabling the electronic device to acquire the target image in the corresponding format, so that the reference image and the target image have the same image format and the same resolution.
5. The method according to claim 4, characterized in that, The step of acquiring the second interface image of the user interface includes: Upon receiving the region coordinate parameters sent by the host computer, the first region image defined by the region coordinate parameters in the displayed user interface is obtained; The reference image includes a second region image defined by the region coordinate parameters in the simulated user interface, which is obtained by the host computer upon receiving the test command.
6. A testing apparatus for electronic equipment, characterized in that, Settings are configured on the host computer, including: The receiving module is used to simulate the display of the user interface upon receiving a test command; The first acquisition module is used to acquire a first interface image of the simulated user interface and use the first interface image as a reference image. The second acquisition module is used to acquire a target image from the electronic device; the target image includes a second interface image actually displayed and acquired by the electronic device when executing the test command; The comparison module is used to compare the pixels in the target image with the pixels in the reference image to obtain a comparison result, so as to determine whether the electronic device has any abnormality based on the comparison result; An output module is used to output the comparison result; the comparison result includes the coordinates of the target pixel, and the target pixel includes pixels in the target image and the reference image whose similarity is less than a preset threshold; The test command sent to the electronic device is the same as the test command sent to the host computer, so that the host computer and the electronic device expect to display the same user interface and obtain the interface image of the same user interface, respectively obtaining the first interface image and the second interface image. The host computer acquires the reference image in a preset image format and simultaneously sends format parameters to the electronic device, enabling the electronic device to acquire the target image in the corresponding format, so that the reference image and the target image have the same image format and the same resolution.
7. The apparatus according to claim 6, characterized in that, The comparison module is specifically used to obtain a first region image defined by preset region coordinate parameters from the target image, and to obtain a second region image defined by the region coordinate parameters from the reference image; The pixels in the first region image and the pixels in the second region image are compared.
8. The apparatus according to claim 6, characterized in that, The first acquisition module is specifically used to send region coordinate parameters to the electronic device; the region coordinate parameters are used to enable the electronic device to acquire a first region image defined by the region coordinate parameters in the user interface actually displayed, and return the first region image as the target image; Obtain the second region image defined by the region coordinate parameters in the simulated user interface, and use the second region image as the reference image.
9. A testing device for electronic equipment, characterized in that, The electronic device includes: The receiving module is used to receive test commands sent by the host computer that correspond to the user interface; The acquisition module is configured to, in response to the test command, display the user interface and acquire a second interface image of the user interface; The sending module is used to send the second interface image as a target image to the host computer, so that the host computer compares the pixels in the target image with the pixels in the reference image, obtains a comparison result, and determines whether the user interface has an anomaly based on the comparison result; the reference image includes a first interface image obtained by the host computer when simulating the display of the user interface upon receiving the test command; the comparison result includes the coordinates of the target pixels, and the target pixels include pixels in the target image and the reference image with a similarity of less than a preset threshold; The test command sent to the electronic device is the same as the test command sent to the host computer, so that the host computer and the electronic device expect to display the same user interface and obtain the interface image of the same user interface, respectively obtaining the first interface image and the second interface image. The host computer acquires the reference image in a preset image format and simultaneously sends format parameters to the electronic device, enabling the electronic device to acquire the target image in the corresponding format, so that the reference image and the target image have the same image format and the same resolution.
10. The apparatus according to claim 9, characterized in that, The acquisition module is specifically used to acquire a first region image defined by the region coordinate parameters in the displayed user interface when receiving region coordinate parameters sent by the host computer; wherein, the reference image includes a second region image defined by the region coordinate parameters in the simulated user interface when the host computer receives the test command.
11. An electronic device, characterized in that, The electronic device includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the test method of the electronic device as described in any one of claims 1-5.
12. A readable storage medium storing a program or instructions that, when executed by a processor, implement the test method of the electronic device as claimed in any one of claims 1-5.
Citation Information
Patent Citations
Method for detecting interface difference, electronic device and computer readable medium
CN108984399A
Interface diagnosis method and device, terminal and computer readable storage medium
CN112100074A