Page component information caching method, device, equipment and storage medium

By in the UI automation test of the Android system, the page control page component Activity information is used to use the page controller cache page component information to solve the problem of excessive resources when obtaining the page component information, and the test efficiency is improved.

CN113971057BActive Publication Date: 2025-01-28BEIJING QIHOOD TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010713924.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-22
Publication Date
2025-01-28
Estimated Expiration
2040-07-22

AI Technical Summary

Technical Problem

During the Android system's UI automation testing process, excessive resource consumption is consumed when obtaining page component information, resulting in inefficient testing.

Method used

Use the page controller to receive the page change signal, obtain the current page component Activity information and cache to reduce the dependence on the shell command and frequently traversing the stack information.

Benefits of technology

The cache Activity information can be quickly obtained, reducing resource consumption, improving page test efficiency, and avoiding frequent calls of resource waste caused by frequent calls of the shell command.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113971057B_ABST
    Figure CN113971057B_ABST
Patent Text Reader

Abstract

The present invention discloses a page component information caching method, device, equipment and storage medium. The method is used in a page test process of an Android system. In the page test process, a page controller can detect page changes and obtain the Activity information of the page by calling a callback method registered by the page controller when the page changes, and then cache the Activity information to obtain the cached Activity information. Since the cached Activity information can be quickly obtained by testers, it is avoided to obtain the Activity information by frequently calling shell commands to traverse too much stack information, thereby reducing the resource consumption of obtaining the page information in the page test process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic equipment system maintenance, and in particular to a page component information caching method, device, equipment and storage medium. Background Art

[0002] With the continuous development of science and technology, electronic technology has also developed rapidly, and the types of electronic products have increased. People have also enjoyed the convenience brought by the development of science and technology. Now people can enjoy the comfortable life and work brought by the development of science and technology through various types of terminals. For example, mobile terminals such as smartphones and tablets have become an important part of people's lives. Users can use mobile terminals such as smartphones and tablets to listen to music and play games to relieve the pressure brought by modern fast-paced life.

[0003] In the process of automated testing of the UI (Full English Name: User Interface) of the Android system, in order to manage the page testing process, it is often necessary to obtain the current page component information, for example, to count the page opening information of the execution use case and obtain the page mark to determine the behavior of the use case. In the prior art, there is a problem of consuming too many resources when obtaining the page component information.

[0004] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of the present invention is to provide a page component information caching method, device, equipment and storage medium, aiming to solve the above-mentioned technical problems.

[0006] To achieve the above object, the present invention provides a page component information caching method, which is used in a page testing process of an Android system, wherein the Android system includes a page controller; the page component information caching method includes the following steps:

[0007] When receiving the first page change signal, obtaining the current page component Activity information based on the page controller;

[0008] Cache the current Activity information and obtain the cached Activity information.

[0009] Optionally, the first page change signal includes a new page opening signal, and the Android system includes an intent object; when the first page change signal is received, the step of obtaining the current page component Activity information based on the page controller includes:

[0010] When a signal to open a new page is received, the current Activity information is obtained through the intent object based on the page controller.

[0011] Optionally, before the step of caching the current Activity information and obtaining the cached Activity information, the method further includes:

[0012] Determine whether the current Activity information is in the blacklist;

[0013] If the current Activity information is not in the blacklist, executing the step of caching the current Activity information to obtain the cached Activity information;

[0014] If the current Activity information is in the blacklist, the current Activity information is not cached and the new page is not opened.

[0015] Optionally, the first page change signal includes a signal for switching to an existing page, and the step of acquiring the Activity information of the current page component based on the page controller when the first page change signal is received further includes:

[0016] When a signal to switch to an existing page is received, the current Activity information is obtained through asynchronous parsing of the shell command.

[0017] Optionally, after the step of caching the current Activity information and obtaining the cached Activity information, the method further includes:

[0018] When the second page change signal is received, the cached Activity information is corrected.

[0019] Optionally, the step of correcting the cached Activity information when the second page change signal is received includes:

[0020] When the second page change signal is received, acquiring page information of a current page event corresponding to the second page change signal;

[0021] Determining whether the page information meets a preset condition;

[0022] If the page information meets the preset condition, the cached Activity information is corrected.

[0023] Optionally, the step of determining whether the page information meets a preset condition includes:

[0024] Determine whether the page information does not match the cached Activity information, and / or determine whether the window of the current page event changes.

[0025] Optionally, the page information includes a first application package name corresponding to the current page event, and the cached Activity information includes a second application package name; and the step of determining whether the page information does not match the cached Activity information includes:

[0026] Determine whether the first application package name is inconsistent with the first application package name.

[0027] Optionally, after the step of caching the current Activity information and obtaining the cached Activity information, the method further includes:

[0028] Based on the cached Activity information, page test data is obtained.

[0029] Optionally, after the step of acquiring page test data based on the cached Activity information, the method further includes:

[0030] Based on the page test data, statistics are collected on the Activities displayed during the page test.

[0031] Optionally, after the step of caching the current Activity information and obtaining the cached Activity information, the method further includes:

[0032] Based on the cached Activity information, the page testing process is detected.

[0033] Optionally, a page operation method has been registered in the page controller; before the step of acquiring the current page component Activity information based on the page controller when the first page change signal is received, the method further includes:

[0034] The page operation method is registered in the page controller by reflection.

[0035] In addition, to achieve the above-mentioned purpose, the present invention also proposes a page component information caching device, which is used in a page testing process of an Android system, wherein the Android system includes a page controller; the page component information caching device includes:

[0036] An information acquisition module, configured to acquire the Activity information of the current page component based on the page controller when receiving the first page change signal;

[0037] The information cache module is used to cache the current Activity information and obtain the cached Activity information.

[0038] Optionally, the first page change signal includes a new page opening signal, and the Android system includes an intent object; the information cache module is further used to obtain current Activity information through the intent object when receiving the new page opening signal.

[0039] Optionally, the page component information caching device further includes:

[0040] An information determination module, used for determining whether the current Activity information is in a blacklist before caching the current Activity information and obtaining the cached Activity information;

[0041] The information caching submodule is used to execute the step of caching the current Activity information and obtaining the cached Activity information if the current Activity information is not in the blacklist; if the current Activity information is in the blacklist, not caching the current Activity information and not opening the new page.

[0042] Optionally, the first page change signal includes a switch to an existing page signal; the information cache module is further configured to obtain current Activity information through asynchronous parsing of a shell command when receiving the switch to an existing page signal.

[0043] Optionally, the page component information caching device further includes:

[0044] The information updating module is used to update the cached Activity information when receiving a second page change signal after the step of caching the current Activity information and obtaining the cached Activity information.

[0045] Optionally, the information update module is also used to obtain page information of the current page event corresponding to the second page change signal when the second page change signal is received; determine whether the page information meets a preset condition; if the page information meets the preset condition, correct the cached Activity information.

[0046] Optionally, the information updating module further includes:

[0047] An information matching judgment module, used to judge whether the page information does not match the cached Activity information; and / or,

[0048] The window change judgment module is used to judge whether the window of the current page event has changed.

[0049] Optionally, the information matching judgment module is also used to determine whether the first application package name is inconsistent with the first application package name; the page information includes the first application package name corresponding to the current page event, and the cached Activity information includes the second application package name.

[0050] Optionally, the page component information caching device further includes:

[0051] The data acquisition module is used to acquire page test data based on the cached Activity information after the step of caching the current Activity information to obtain the cached Activity information.

[0052] The page component information caching device further includes:

[0053] Optionally, a page statistics module is used to collect statistics on the Activities displayed during the page test based on the page test data after the step of obtaining the page test data based on the cached Activity information.

[0054] Optionally, the page component information caching device further includes:

[0055] The data acquisition module is used to detect the page test process based on the cached Activity information after the step of caching the current Activity information and obtaining the cached Activity information.

[0056] In addition, to achieve the above-mentioned purpose, the present invention also proposes a page component information caching device, which includes: a memory, a processor, and a page component information caching program stored on the memory and executable on the processor, and the page component information caching program is configured to implement the steps of the page component information caching method described above.

[0057] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, on which a page component information caching program is stored, and when the page component information caching program is executed by a processor, the steps of the page component information caching method described above are implemented.

[0058] The page component information caching method of the present invention is used in the page testing process of the Android system. During the page testing process, since the page controller can detect page changes and can obtain the Activity information of the page by calling the callback method registered by the page controller according to the page changes, the Activity information is then cached to obtain the cached Activity information. Since the cached Activity information can be quickly obtained by the tester, it is avoided to obtain the Activity information by traversing too much stack information through frequent calls of shell commands, thereby reducing the resource consumption of obtaining the page information during the page testing process. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 It is a structural diagram of a page component information cache device in a hardware operating environment involved in an embodiment of the present invention;

[0060] Figure 2 It is a flow chart of the first embodiment of the method for caching page component information of the present invention;

[0061] Figure 3 A schematic diagram of a specific implementation flow of the second embodiment of the page component information caching method of the present invention;

[0062] Figure 4 A schematic diagram of a specific implementation flow of correcting cached Activity information in the third embodiment of the page component information caching method of the present invention;

[0063] Figure 5 It is a structural block diagram of the first embodiment of the page component information caching device of the present invention.

[0064] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0065] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0066] Reference Figure 1 , Figure 1 It is a schematic diagram of the structure of a page component information cache device in a hardware operating environment involved in an embodiment of the present invention.

[0067] like Figure 1As shown, the page component information cache device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0068] Those skilled in the art will understand that Figure 1 The structure shown in does not constitute a limitation on the page component information caching device, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.

[0069] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a data storage module, a network communication module, a user interface module, and a page component information cache program.

[0070] exist Figure 1 In the page component information caching device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the page component information caching device of the present invention can be set in the page component information caching device, and the page component information caching device calls the page component information caching program stored in the memory 1005 through the processor 1001, and executes the page component information caching method provided by the embodiment of the present invention.

[0071] In the prior art, the method of obtaining the current Activity of the system through the shell command "dumpsys Activity activities" includes:

[0072] 1. Acquisition steps

[0073] 1.1 Get the stack information through shell commands.

[0074] The system stack information is obtained through the dumpsys Activity activities command. When the command is executed, the system will start a shell process to read all the stack information from the system, and then output it to the command console. The script or program receives the current system stack information by executing the shell command. The current stack information is the stack information of all running applications in the system, so the amount of information is large and the command execution time is long.

[0075] 2. Parse the stack information text and extract the Activity that is currently interacting with the user based on the characteristics of the current displayed page

[0076] 2.1 Traverse the stack information line by line;

[0077] 2.2 In the stack, each page Activity corresponds to a page ActivityRecord record: clear the recorded Activity at this time;

[0078] 2.3 In the stack information ActivityRecord, the value corresponding to each realActivity is the corresponding Activity value: at this time, the cache records the Activity;

[0079] 2.4 In the stack information ActivityRecord, the value corresponding to state is the page output state. The page in state (state=RESUMED) is the page for interacting with the user. When traversing to this state Activity, the cached Activity value in 2.3 is directly returned.

[0080] It should be noted that Activity is one of the four most basic and common components in Android (Activity, Service, Content Provider, Broadcast Receiver). Activity is an application component that provides a screen that users can use to interact in order to complete a task. All operations in Activity are closely related to the user. It is a component responsible for interacting with the user and can display specified controls through setContentView(View). In an Android application, an Activity is usually a separate screen that can display some controls and can also listen to and process user events in response. Activities communicate with each other through Intent.

[0081] From the analysis of the prior art, it can be seen that in the prior art, during the page testing process, the method of obtaining the current page Activity is to create a new process, obtain the current stack information of the system through the shell command "dumpsys Activity activities", and then traverse the stack result. The Activity corresponding to the stack with "state=RESUMED" is the Activity that currently interacts with the user. Since the current stack information is the stack information of all running applications in the system, the amount of information is large. Traversing it will consume too many resources and the command execution time will be long. In addition, if the current page Activity is obtained multiple times in a page, a new process needs to be created each time, and the current page Activity needs to be obtained through multiple parsing of the shell command. However, the page Activity does not change during this process, which further causes excessive resource consumption.

[0082] In order to solve the problems of the prior art, the embodiment of the present invention provides a method for caching page component information. Figure 2 , Figure 2 It is a flowchart of the first embodiment of the method for caching page component information of the present invention.

[0083] In this embodiment, the page component information caching method is used in a page testing process of an Android system, and the Android system includes a page controller.

[0084] It should be noted that the method of this embodiment is applied to the Android system, which may also be referred to as the system in this embodiment. The page test process in this embodiment may be an automated test process of the UI (Full English Name: User Interface) of the Android system. It can be understood that the page refers to the user interface; the page controller in this embodiment refers to the ActivityController component that comes with the Android system.

[0085] The page component information caching method comprises the following steps:

[0086] Step S10, when receiving the first page change signal, obtaining the current page component Activity information based on the page controller.

[0087] Specifically, the first page change signal of this embodiment can be a signal generated by a page event in the system, that is, a signal generated when a page change action occurs, for example, a signal generated by switching between existing pages and opening a new page. In actual applications, the first page change signal can be sensed and received by a page controller.

[0088] In addition, the page controller refers to ActivityController. In this embodiment, the page controller registers ActivityStarting and ActivityResuming page operation methods. Among them, ActivityStarting is called when the system opens a new page, and ActivityResuming is called when the system switches to an existing page.

[0089] In one embodiment, the first page change signal is a signal for the system to open a new page, and the Android system includes an intent object; in this case, upon receiving the first page change signal, the step of obtaining the current page component Activity information based on the page controller includes:

[0090] When receiving a signal to open a new page, obtain the current Activity information through the intent object.

[0091] Specifically, intent is the intent in the Android system. Intent is a message passing object between components. It can be used to request operations from other Android components. Therefore, when receiving a signal to open a new page, this embodiment can use the opportunity of callback ActivityStarting to communicate with the current Activity component using the intent object to obtain the current Activity information. However, due to the technical barriers of the testers during the page testing process, they cannot use the opportunity of callback ActivityStarting to communicate with the current Activity component using the intent object to obtain the current Activity information.

[0092] Further, see Figure 3 , is a flow chart of the second embodiment of the page component information caching method of the present invention. In this embodiment, in order to control opening a new page and caching the current Activity information during the test process, before the step of caching the current Activity information and obtaining the cached Activity information, the method further includes:

[0093] S101, determining whether the current Activity information is in the blacklist;

[0094] S102: If the current Activity information is not in the blacklist, execute the step of caching the current Activity information to obtain cached Activity information.

[0095] In addition, if the current Activity information is in the blacklist, the current Activity information is not cached and the new page is not opened.

[0096] Specifically, the blacklist in this embodiment includes a list of Activity information that is not cached or new pages that are not opened. A blacklist page Activity list can be maintained in the script, and the Activity information in the blacklist page Activity list is not cached, and its corresponding new page is not opened; in addition, a blacklist application list can also be maintained in the script, and all pages of the application in the blacklist application list cannot be opened or cached.

[0097] In addition, the current Activity information may include page Activity information and the package name of the application currently to be opened.

[0098] To this end, in this embodiment, when the current Activity information is obtained, S101 is first executed to determine whether the current Activity information is in the blacklist. If so, it means that the UI tester does not need to cache the current Activity information or open its corresponding new page, so S103 is executed; otherwise, the step of caching the current Activity information in S102 to obtain the cached Activity information is executed, so that the cached Activity information can be easily obtained and used later.

[0099] For example, in a business scenario, the real machine system does not allow users to open the specified settings page. For example, the mobile phone is not allowed to control the alarm clock in the custom script task executed during the test. In this case, the specified page can be added to the blacklist page Activity list, or the alarm clock can be added to the blacklist application list.

[0100] In another optional embodiment, the first page change signal is a signal for the system to switch to an existing page; in this case, upon receiving the first page change signal, the step of obtaining the current page component Activity information based on the page controller further includes:

[0101] When a signal to switch to an existing page is received, the current Activity information is obtained through asynchronous parsing of the shell command.

[0102] Specifically, switching to an existing page refers to switching between old pages that have been opened. For example, during the test, it simulates the user clicking the back key to return to the page that has been opened. At this time, the current Activity information can be obtained by calling back ActivityStarting and asynchronously parsing through shell commands.

[0103] Furthermore, when a signal to switch to an existing page is received, only the corresponding application package name can be obtained in ActivityResuming. At this time, it is necessary to use the shell command "dumpsys Activity activities" to parse the current Activity information. Since this command parsing method takes a long time, if it is called in the ActivityResuming method, it will cause page loading delays, affecting the execution and experience of the test script. Therefore, in this embodiment, a new thread can be opened to asynchronously parse the current Activity information.

[0104] In addition, it can be understood that in order to implement the aforementioned ActivityStarting and ActivityResuming page operation methods called back by the page controller, as an optional embodiment, before the step of obtaining the current page component Activity information based on the page controller when receiving the first page change signal, the method further includes:

[0105] The page operation method is registered in the page controller by reflection.

[0106] Specifically, as described above, the page operation method includes ActivityStarting and ActivityResuming. Since the system API has changed in Android 7.0 (24) and above, the reflection registration is to adapt the method of this embodiment to multiple versions of Android systems and have better compatibility.

[0107] In the specific implementation process, in the Android system, you can reflectively register the ActivityController in the following way:

[0108] 1. Construct the parameters for registering ActivityController (Android 7.0 and above add a boolean type parameter), as follows:

[0109] Android7.0 and above: Class[] parameterTypes = new Class[]{IActivityController.class, boolean.class};

[0110] Android7.0 and below: Class[] parameterTypes = new Class[]{IActivityController.class};

[0111] 2. Construct the parameter information required to register ActivityController (Android 7.0 and above add a boolean type parameter), as follows:

[0112] Android7.0 and above: new Object[] {iActivityController, false};

[0113] Android7.0 and below: Object[] parameterValues ​​= new Object[]{iActivityController};

[0114] Android7.0 and below: Class[] parameterTypes = new Class[]{IActivityController.class};

[0115] 3. Get the setActivityController method of ActivityManager to register ActivityController through reflection:

[0116] Methodmethod = mAm.getClass().getMethod("setActivityController",parameterTypes);

[0117] 4. Set the access attribute of the registered ActivityController method to true (see Java method access permissions for details):

[0118] method.setAccessible(true);

[0119] 5. Call the registration ActivityController method by reflection:

[0120] method.invoke(mAm, parameterValues).

[0121] It should be understood that the above is only an example and does not constitute any limitation to the technical solution of the present invention. Those skilled in the art can make settings based on needs in actual applications, and no limitation is made here.

[0122] Step S20, cache the current Activity information to obtain cached Activity information.

[0123] Specifically, the caching in this embodiment refers to caching the current Activity information into the memory variable of the system. In this embodiment, the cached Activity information at least includes a string corresponding to the current Activity, such as "com.ss.android.ugc.aweme / .detail.ui.DetailActivity".

[0124] It should be noted that when a page change occurs in the system (for example), the page operation method of the page controller will be called back, and a page cache event will be triggered inside the page operation method. The page cache event provides an opportunity to cache the page. When the page changes, the Activity information of the current page can be obtained, the current Activity information can be cached, and the cached Activity information can be obtained.

[0125] In this embodiment, caching can mean storing Activity information that is not stored in the memory in the memory, or it can mean performing a first update on Activity information that has been stored in the memory, that is, whenever a page change occurs in the system (for example), the page operation method of the page controller will be called back, and a page cache event will be triggered inside the page operation method. The page cache event provides an opportunity to cache the page, and the Activity information of the current page can be obtained when the page changes, and the current Activity information can be stored or first updated to obtain cached Activity information. That is to say, in this embodiment, during the page test process, as long as S10-S20 is executed or executed in a loop, the Activity information of the test page can be maintained in the system's memory, that is, the cached Activity information. Since the cached Activity information in the memory can be quickly obtained by the tester, it is avoided to obtain Activity information by frequently calling shell commands to traverse too much stack information, thereby reducing the resource consumption of obtaining page information during the page test process. In addition, when obtaining the current page Activity multiple times within a page, since the cached Activity information is maintained in the memory, it can be directly obtained multiple times without frequently calling shell commands to traverse too much stack information to obtain Activity information, further reducing the resource consumption of obtaining page information during page testing.

[0126] It should be understood that the above is only an example and does not constitute any limitation to the technical solution of the present invention. Those skilled in the art can make settings based on needs in actual applications, and no limitation is made here.

[0127] The page component information caching method provided in this embodiment is used in the page testing process of the Android system. During the page testing process, since the page controller can detect page changes and can obtain the Activity information of the page by calling the callback method registered by the page controller when the page changes, the Activity information is then cached to obtain the cached Activity information. Since the cached Activity information can be quickly obtained by the tester, it is avoided to obtain the Activity information by frequently calling shell commands to traverse too much stack information, thereby reducing the resource consumption of obtaining page information during the page testing process.

[0128] In another embodiment of the present invention, in order to ensure the data accuracy of the cached Activity information, after the step of caching the current Activity information and obtaining the cached Activity information, the method further includes:

[0129] When the second page change signal is received, the cached Activity information is corrected.

[0130] Specifically, the second page change signal of this embodiment may be a signal generated by a page event in the system, that is, a signal generated when a page change occurs, for example, a signal generated by switching between existing pages and opening a new page.

[0131] The purpose of correcting the cached Activity information is to further ensure the consistency between the page currently interacting with the user and the cached page, so as to ensure that the tester can accurately grasp the information of the test page through the cached Activity information in the memory.

[0132] refer to Figure 4 , Figure 4 It is a flowchart diagram of the third embodiment of the page component information caching method of the present invention.

[0133] Based on the above first embodiment, in this embodiment, a specific implementation method for correcting the cached Activity information is provided. Figure 4 To explain in detail:

[0134] S301, when receiving the second page change signal, obtaining page information of a current page event corresponding to the second page change signal;

[0135] S302, determining whether the page information meets a preset condition;

[0136] S303: If the page information meets a preset condition, correct the cached Activity information.

[0137] Specifically, in step S301, the page event refers to AccessibilityEvent; the page information of the current page event corresponding to the second page change signal may include the application package name corresponding to the current page event and the window of the current page event, and of course may also include the current page event type (such as refreshing the displayed content, the control being clicked), etc. Whenever the displayed content of the Android device changes, the system will return the corresponding page event (AccessibilityEvent) and obtain its corresponding page information.

[0138] After the page information of the current page event corresponding to the second page change signal is obtained, S302 is then executed to determine whether the page information meets a preset condition.

[0139] Specifically, the preset condition can be set as needed, as long as the purpose of correcting the cached Activity information can be achieved. For example, the preset condition can be whether the page information does not match the cached Activity information, and whether the window of the current page event changes.

[0140] In the specific implementation process, this embodiment mainly uses the window information (the window ID of the current page and the application package name packageName) carried by the accessibility event of the Android automated testing framework to verify the correctness of the cached Activity information.

[0141] As an embodiment, the step of determining whether the page information meets a preset condition includes:

[0142] Determine whether the page information does not match the cached Activity information, and / or determine whether the window of the current page event changes.

[0143] In one embodiment, the page information includes a first application package name corresponding to the current page event, and the cached Activity information includes a second application package name; and the step of determining whether the page information does not match the cached Activity information includes:

[0144] Determine whether the first application package name is inconsistent with the first application package name.

[0145] Specifically, in this embodiment, a string matching method can be used to determine whether the package name in the Activity information is consistent with the application package name of the current form event. Then, S303 is executed. If the page information meets the preset conditions, the cached Activity information is corrected. If it is inconsistent, it is considered that the cached Activity information is invalid and the page Activity information can be re-cached; if it is consistent, it is proved that the cached Activity information is valid.

[0146] In another embodiment, the cached Activity information can be corrected by determining whether the window of the current page event has changed. For example, when browsing news information in a news app, although the page content changes when sliding up and down to load information, the windowID obtained by the getWindowId() method of AccessibilityEvent will not change; if you click on a piece of news to view the news details, the windowID will change. Here, the windowID of the previous form loading event is mainly cached. When a page event occurs, it is compared with the cached windowID. If there is a change, the page Activity is re-cached to ensure the accuracy of the cached information.

[0147] It should be understood that the above is only an example and does not constitute any limitation to the technical solution of the present invention. Those skilled in the art can make settings based on needs in actual applications, and no limitation is made here.

[0148] It is not difficult to find from the above description that the method for correcting the cached Activity information provided in this embodiment verifies the correctness of the cached Activity information by utilizing the window information (the window ID of the current page and the application package name packageName) carried by the accessibility event of the Android automated testing framework to ensure the accuracy of the cached Activity information maintained in the memory, so as to provide more accurate Activity information for the tester.

[0149] In another embodiment of the present invention, based on the first embodiment, after the step of caching the current Activity information and obtaining the cached Activity information, the method further includes:

[0150] Based on the cached Activity information, page test data is obtained.

[0151] Specifically, page test data refers to the data during the page test process, which may include: which is the current page activity, which pages are opened during the test, and the number of page openings, etc.

[0152] For the step of obtaining page test data based on the cached Activity information, the tester can quickly obtain the page test data directly through the cache mechanism in the test script, without having to use the dumpsys command to parse the stack information every time, thereby reducing the script's consumption of system resources.

[0153] In another embodiment of the present invention, based on the first embodiment, after the step of acquiring page test data based on the cached Activity information, the method further includes:

[0154] Based on the page test data, statistics are collected on the Activities displayed during the page test.

[0155] Specifically, you can save the current Activity information and current time to a file each time the ActivityStarting and ActivityResuming methods are triggered. When the test case is executed, you can parse the file to view and count which pages are opened in the entire test case, the coverage of the pages by the test case, the number of times the page is opened repeatedly, the page stay time, etc. The purpose of statistics is to analyze the coverage of the test case and facilitate the business evaluation of the test case.

[0156] In another embodiment of the present invention, after the step of caching the current Activity information and obtaining the cached Activity information, the method further includes:

[0157] Based on the cached Activity information, the page testing process is detected.

[0158] Specifically, based on the cached Activity information, the next action can be determined through the page, which is mainly for testers to write scripts and judge the current status in the scripts; in addition, during the testing process, if the test case finds a bug, the Activity information can be provided to the developer to help the developer quickly locate the page where the problem occurs.

[0159] It is not difficult to find from the above description that the page component information caching method of this embodiment, on the one hand, reduces the resource consumption of obtaining page information during page testing compared to the existing method of obtaining Activity information by traversing too much stack information by calling shell commands; on the other hand, it also realizes a method for precise page management such as page statistics during the test process and a method for detecting the test process.

[0160] In addition, an embodiment of the present invention further proposes a storage medium, on which a page component information caching program is stored. When the page component information caching program is executed by a processor, the steps of the page component information caching method described above are implemented.

[0161] Reference Figure 5 , Figure 5 It is a structural block diagram of the first embodiment of the page component information caching device of the present invention.

[0162] The page component information caching device of this embodiment is used in the page testing process of the Android system, and the Android system includes a page controller; Figure 5 As shown, the page component information caching device proposed in this embodiment includes:

[0163] An information acquisition module, configured to acquire the Activity information of the current page component based on the page controller when receiving the first page change signal;

[0164] The information cache module is used to cache the current Activity information and obtain the cached Activity information.

[0165] The page component information caching device provided in this embodiment is used in the page testing process of the Android system. During the page testing process, since the page controller can detect page changes and can obtain the Activity information of the page by calling the callback method registered by the page controller when the page changes, the Activity information is then cached to obtain the cached Activity information. Since the cached Activity information can be quickly obtained by the tester, it is avoided to obtain the Activity information by frequently calling shell commands to traverse too much stack information, thereby reducing the resource consumption of obtaining page information during the page testing process.

[0166] Based on the first embodiment of the page component information caching device of the present invention, a second embodiment of the page component information caching device of the present invention is proposed.

[0167] In this embodiment, the information cache module is also used to obtain the current Activity information through the intent object when receiving a signal to open a new page.

[0168] As an embodiment, the page component information caching device further includes:

[0169] An information determination module, used for determining whether the current Activity information is in a blacklist before caching the current Activity information and obtaining the cached Activity information;

[0170] The information caching submodule is used to execute the step of caching the current Activity information and obtaining the cached Activity information if the current Activity information is not in the blacklist; if the current Activity information is in the blacklist, not caching the current Activity information and not opening the new page.

[0171] As an embodiment, the information cache module is also used to obtain the current Activity information through shell command asynchronous parsing when receiving a signal to switch to an existing page.

[0172] As an embodiment, the page component information caching device further includes:

[0173] The information updating module is used to update the cached Activity information when receiving a second page change signal after the step of caching the current Activity information and obtaining the cached Activity information.

[0174] As an embodiment, the information update module is also used to obtain page information of the current page event corresponding to the second page change signal when the second page change signal is received; determine whether the page information meets the preset conditions; if the page information meets the preset conditions, correct the cached Activity information.

[0175] As an embodiment, the information updating module further includes:

[0176] An information matching judgment module, used to judge whether the page information does not match the cached Activity information; and / or,

[0177] The window change judgment module is used to judge whether the window of the current page event has changed.

[0178] As an embodiment, the information matching judgment module is also used to determine whether the first application package name is inconsistent with the first application package name; the page information includes the first application package name corresponding to the current page event, and the cached Activity information includes the second application package name.

[0179] As an embodiment, the page component information caching device further includes:

[0180] The data acquisition module is used to acquire page test data based on the cached Activity information after the step of caching the current Activity information to obtain the cached Activity information.

[0181] The page component information caching device further includes:

[0182] As an embodiment, the page statistics module is used to collect statistics on the Activities displayed during the page testing process based on the page testing data after the step of obtaining the page testing data based on the cached Activity information.

[0183] As an embodiment, the page component information caching device further includes:

[0184] The data acquisition module is used to detect the page test process based on the cached Activity information after the step of caching the current Activity information and obtaining the cached Activity information.

[0185] Other embodiments or specific implementations of the page component information caching device of the present invention can refer to the above-mentioned method embodiments and will not be described in detail here.

[0186] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0187] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0188] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0189] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A page component information caching method, characterized in that: The page component information caching method is used in a page testing process of an Android system, wherein the Android system includes a page controller and an intent object; the page component information caching method includes the following steps: When receiving the first page change signal, obtaining the current page component Activity information based on the page controller; Cache the current Activity information and obtain the cached Activity information; The first page change signal includes a new page opening signal; the step of acquiring the current page component Activity information based on the page controller when the first page change signal is received includes: When the new page opening signal is received, the current Activity information is acquired by communicating with the current Activity component using the intent object by means of the opportunity of calling the registered page operation method in the page controller.

2. The page component information caching method according to claim 1, characterized in that: Before the step of caching the current Activity information and obtaining the cached Activity information, the method further includes: Determine whether the current Activity information is in the blacklist; If the current Activity information is not in the blacklist, the step of caching the current Activity information to obtain the cached Activity information is performed.

3. The page component information caching method according to claim 1 or 2, characterized in that: The first page change signal also includes a signal for switching to an existing page. When the first page change signal is received, the step of obtaining the Activity information of the current page component based on the page controller also includes: When the signal for switching to an existing page is received, the current Activity information is obtained by asynchronously parsing through a shell command.

4. The page component information caching method according to claim 1 or 2, characterized in that: After the step of caching the current Activity information and obtaining the cached Activity information, the method further includes: When the second page change signal is received, the cached Activity information is corrected.

5. The page component information caching method according to claim 4, characterized in that: The step of correcting the cached Activity information when the second page change signal is received includes: When the second page change signal is received, acquiring page information of a current page event corresponding to the second page change signal; Determining whether the page information meets a preset condition; If the page information meets the preset condition, the cached Activity information is corrected.

6. The page component information caching method according to claim 5, characterized in that: The step of determining whether the page information meets a preset condition comprises: Determine whether the page information does not match the cached Activity information, and / or determine whether the window of the current page event changes.

7. The page component information caching method according to claim 6, characterized in that: The page information includes a first application package name corresponding to the current page event, and the cached Activity information includes a second application package name; The step of determining whether the page information does not match the cached Activity information includes: Determine whether the first application package name is inconsistent with the second application package name.

8. The page component information caching method according to claim 1, characterized in that: After the step of caching the current Activity information and obtaining the cached Activity information, the method further includes: Based on the cached Activity information, page test data is obtained.

9. The page component information caching method according to claim 8, characterized in that: After the step of acquiring page test data based on the cached Activity information, the method further includes: Based on the page test data, statistics are collected on the Activities displayed during the page test.

10. The page component information caching method according to claim 1, characterized in that: After the step of caching the current Activity information and obtaining the cached Activity information, the method further includes: Based on the cached Activity information, the page testing process is detected.

11. The page component information caching method according to claim 1, characterized in that: The page controller has registered a page operation method; Before the step of acquiring the current page component Activity information based on the page controller when the first page change signal is received, the method further includes: The page operation method is registered in the page controller by reflection.

12. A page component information caching device, characterized in that: The page component information caching device is used in a page testing process of an Android system, wherein the Android system includes a page controller and an intent object; The page component information caching device comprises: An information acquisition module, configured to acquire the Activity information of the current page component based on the page controller when receiving the first page change signal; The information cache module is used to cache the current Activity information and obtain the cached Activity information; The first page change signal includes a new page opening signal; The information acquisition module is also used to obtain the current Activity information by communicating with the current Activity component using the intention object when receiving the new page opening signal by calling the page operation method registered in the page controller.

13. The page component information caching device according to claim 12, characterized in that: The page component information caching device further includes: The information judgment module is used to judge whether the current Activity information is in the blacklist before caching the current Activity information and obtaining the cached Activity information; The information caching submodule is used to cache the current Activity information to obtain cached Activity information if the current Activity information is not in the blacklist; if the current Activity information is in the blacklist, not cache the current Activity information and not open a new page.

14. The page component information caching device according to claim 12 or 13, characterized in that: The first page change signal also includes a switch to an existing page signal; The information cache module is also used to obtain the current Activity information through shell command asynchronous parsing when receiving the signal of switching to the existing page.

15. The page component information caching device according to claim 12 or 13, characterized in that: The page component information caching device also includes: The information updating module is used to cache the current Activity information, obtain the cached Activity information, and correct the cached Activity information when receiving the second page change signal.

16. The page component information caching device according to claim 15, characterized in that: The information updating module is further configured to obtain, upon receiving the second page change signal, page information of a current page event corresponding to the second page change signal; and determine whether the page information satisfies a preset condition; If the page information meets the preset condition, the cached Activity information is corrected.

17. The page component information caching device according to claim 16, characterized in that: The information updating module further includes: An information matching judgment module, used to judge whether the page information does not match the cached Activity information; and / or, The window change judgment module is used to judge whether the window of the current page event has changed.

18. The page component information caching device according to claim 17, characterized in that: The page information includes a first application package name corresponding to the current page event, and the cached Activity information includes a second application package name; The information matching judgment module is further used to judge whether the first application package name is inconsistent with the second application package name.

19. The page component information caching device according to claim 12, characterized in that: The page component information caching device further includes: The data acquisition module is used to cache the current Activity information, obtain the cached Activity information, and then obtain the page test data based on the cached Activity information.

20. The page component information caching device according to claim 19, characterized in that: The page component information caching device further includes: The page statistics module is used to obtain page test data based on the cached Activity information and then to collect statistics on the Activities displayed during the page test based on the page test data.

21. The page component information caching device according to claim 12, characterized in that: The page component information caching device further includes: The data acquisition module is used to cache the current Activity information, obtain the cached Activity information, and then detect the page test process based on the cached Activity information.

22. A page component information caching device, characterized in that: The device comprises: a memory, a processor, and a page component information caching program stored in the memory and executable on the processor, wherein the page component information caching program is configured to implement the steps of the page component information caching method according to any one of claims 1 to 11.

23. A storage medium, characterized in that: The storage medium stores a page component information caching program, which, when executed by a processor, implements the steps of the page component information caching method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Page information updating method and device

    CN109492176A

  • An information processing method and a terminal

    CN109800135A