CN113971057A - Page component information caching method, device, equipment and storage medium - Google Patents

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

Info

Publication number
CN113971057A
CN113971057A CN202010713924.1A CN202010713924A CN113971057A CN 113971057 A CN113971057 A CN 113971057A CN 202010713924 A CN202010713924 A CN 202010713924A CN 113971057 A CN113971057 A CN 113971057A
Authority
CN
China
Prior art keywords
page
information
caching
activity information
current
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010713924.1A
Other languages
Chinese (zh)
Inventor
李括
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN202010713924.1A priority Critical patent/CN113971057A/en
Publication of CN113971057A publication Critical patent/CN113971057A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a page component information caching method, a page component information caching device and a page component information caching storage medium, wherein the page component information caching method is used in a page testing process of an Android system, and in the page testing process, a page controller can detect page changes and can obtain Activity information of a page by means of the time for calling a callback method registered by the page controller when the page changes, and then cache the Activity information to obtain cached Activity information; the cached Activity information can be quickly acquired by the tester, so that the Activity information is prevented from being acquired by frequently calling the shell command to traverse too much stack information, and the resource consumption for acquiring the page information in the page testing process is reduced.

Description

Page component information caching method, device, equipment and storage medium
Technical Field
The invention relates to the technical field of system maintenance of electronic equipment, in particular to a page component information caching method, a page component information caching device, page component information caching equipment and a page component information caching storage medium.
Background
With the continuous development of science and technology, electronic technology has also gained rapid development, and the variety of electronic products is also more and more, and people also enjoy various conveniences brought by the development of science and technology. People can enjoy comfortable life and work brought along with the development of science and technology through various types of terminals. For example, mobile terminals such as smart phones and tablet computers have become an important part of people's lives, and users can listen to music and play games by using the mobile terminals such as smart phones and tablet computers, so as to relieve pressure brought by modern fast-paced lives.
In the process of automatically testing a UI (User Interface) of an Android system, in order to manage a page testing process, it is often necessary to acquire current page component information, for example, statistics of execution case open page information and acquisition of page tags to determine a case behavior. In the prior art, too much resources are consumed when the page component information is acquired.
The above is only for the purpose of assisting understanding of the technical aspects of the present invention, and does not represent an admission that the above is prior art.
Disclosure of Invention
The invention mainly aims to provide a page component information caching method, a page component information caching device, page component information caching equipment and a page component information caching storage medium, and aims to solve the technical problems.
In order to achieve the purpose, the invention provides a page component information caching method, which is used for a page testing process of an Android system, wherein the Android system comprises a page controller; the page component information caching method comprises the following steps:
when a first page change signal is received, acquiring Activity information of a current page component based on the page controller;
and caching the current Activity information to obtain cached Activity information.
Optionally, the first page change signal comprises an open new page signal, and the Android system comprises an intention object; the step of acquiring Activity information of the current page component based on the page controller when receiving the first page change signal includes:
and when a new page opening signal is received, acquiring current Activity information through the intention object based on the page controller.
Optionally, before the step of caching the current Activity information and obtaining cached Activity information, the method further includes:
judging whether the current Activity information is in a blacklist or not;
if the current Activity information is not in the blacklist, executing a step of caching the current Activity information to obtain cached Activity information;
if the current Activity information is in the blacklist, the current Activity information is not cached and the new page is not opened.
Optionally, the step of obtaining Activity information of a current page component based on the page controller when the first page change signal is received includes switching to an existing page signal, and further includes:
and when a signal for switching to the existing page is received, asynchronously analyzing through a shell command to acquire the current Activity information.
Optionally, after the step of caching the current Activity information and obtaining cached Activity information, the method further includes:
and when a second page change signal is received, correcting the cache Activity information.
Optionally, 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;
judging whether the page information meets a preset condition or not;
and if the page information meets the preset condition, correcting the cache Activity information.
Optionally, the step of determining whether the page information meets a preset condition includes:
and judging whether the page information is not matched with the cache Activity information and/or judging whether the form of the current page event changes.
Optionally, the page information includes a first application package name corresponding to the current page event, and the cache Activity information includes a second application package name; the step of judging whether the page information is not matched with the cache Activity information comprises the following steps:
and judging whether the first application package name is inconsistent with the first application package name.
Optionally, after the step of caching the current Activity information and obtaining cached Activity information, the method further includes:
and acquiring page test data based on the cache Activity information.
Optionally, after the step of obtaining page test data based on the cache Activity information, the method further includes:
and counting the Activities displayed in the page testing process based on the page testing data.
Optionally, after the step of caching the current Activity information and obtaining cached Activity information, the method further includes:
and detecting the page test process based on the cache Activity information.
Optionally, a page operation method is registered in the page controller; before the step of obtaining the Activity information of the current page component based on the page controller when the first page change signal is received, the method further includes:
and adopting a reflection mode to register the page in the page controller.
In addition, in order to achieve the above object, the present invention further provides a page component information caching device, where the page component information caching device is used in a page test process of an Android system, and the Android system includes a page controller; the page component information caching device comprises:
the information acquisition module is used for acquiring Activity information of the current page component based on the page controller when receiving a first page change signal;
and the information caching module is used for caching the current Activity information to obtain cached Activity information.
Optionally, the first page change signal comprises an open new page signal, and the Android system comprises an intention object; the information caching module is further used for acquiring the current Activity information through the intention object when a new page opening signal is received.
Optionally, the page component information caching apparatus further includes:
the information judgment module is used for judging whether the current Activity information is in a blacklist or not before the steps of caching the current Activity information and obtaining cached Activity information;
the information caching submodule is used for caching the current Activity information to obtain caching Activity information if the current Activity information is not in the blacklist; if the current Activity information is in the blacklist, the current Activity information is not cached and the new page is not opened.
Optionally, the first page change signal includes a switch to existing page signal; the information caching module is further used for asynchronously analyzing and acquiring the current Activity information through a shell command when the signal for switching to the existing page is received.
Optionally, the page component information caching apparatus further includes:
and the information updating module is used for updating the cache Activity information when a second page change signal is received after the steps of caching the current Activity information and obtaining the cache Activity information.
Optionally, the information updating module is further configured to, when the second page change signal is received, obtain page information of a current page event corresponding to the second page change signal; judging whether the page information meets a preset condition or not; and if the page information meets the preset condition, correcting the cache Activity information.
Optionally, the information updating module further includes:
the information matching judgment module is used for judging whether the page information is not matched with the cache Activity information; and/or the presence of a gas in the gas,
and the window change judging module is used for judging whether the window of the current page event changes.
Optionally, the information matching determining module is further configured to determine whether the first application package name is inconsistent with the first application package name; the page information comprises a first application package name corresponding to the current page event, and the cache Activity information comprises a second application package name.
Optionally, the page component information caching apparatus further includes:
and the data acquisition module is used for acquiring page test data based on the cache Activity information after the step of caching the current Activity information and acquiring the cache Activity information.
The page component information caching device further comprises:
optionally, the page statistics module is configured to, after the step of obtaining page test data based on the cache Activity information, perform statistics on Activity displayed in the page test process based on the page test data.
Optionally, the page component information caching apparatus further includes:
and the data acquisition module is used for detecting the page test process based on the cache Activity information after the step of caching the current Activity information and acquiring the cache Activity information.
In addition, to achieve the above object, the present invention further provides a page component information caching device, where the device includes: the page component information caching program is configured to implement the steps of the page component information caching method as described above.
In addition, in order to achieve the above object, the present invention further provides a storage medium, where a page component information caching program is stored, and when the page component information caching program is executed by a processor, the page component information caching method as described above is implemented.
The page component information caching method is used for the page testing process of an Android system, and in the page testing process, because a page controller can detect page changes and can call the opportunity of a callback method registered by the page controller to acquire Activity information of a page by means of the page changes, caching the Activity information to acquire cached Activity information; the cached Activity information can be quickly acquired by the tester, so that the Activity information is prevented from being acquired by frequently calling the shell command to traverse too much stack information, and the resource consumption for acquiring the page information in the page testing process is reduced.
Drawings
Fig. 1 is a schematic structural diagram of a page component information caching device of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a first embodiment of a page component information caching method according to the present invention;
fig. 3 is a flowchart illustrating a specific implementation of a page component information caching method according to a second embodiment of the present invention;
FIG. 4 is a flowchart illustrating a specific implementation of correcting cache Activity information according to a third embodiment of the page component information caching method of the present invention;
fig. 5 is a block diagram of a first embodiment of a page component information caching apparatus according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a page component information caching device in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the page component information caching apparatus 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. Wherein a communication bus 1002 is used to enable connective 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, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The Memory 1005 may be a Random Access Memory (RAM) Memory, or may be a Non-Volatile Memory (NVM), such as a disk Memory. The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the architecture shown in fig. 1 does not constitute a limitation of the page assembly information caching apparatus and may include more or fewer components than shown, or some components in combination, or a different arrangement of components.
As shown in fig. 1, the memory 1005, which is a storage medium, may include therein an operating system, a data storage module, a network communication module, a user interface module, and a page component information caching program.
In the page component information caching apparatus shown in fig. 1, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 of the page component information caching device of the present invention may be disposed in the page component information caching device, and the page component information caching device calls a 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.
In the prior art, a method for acquiring the current Activity of a system through a shell command "dumpsys Activity activities" includes:
1. obtaining step
1.1 obtaining Stack information through Shell Command
The stack information of the system is obtained through a dumpsys Activity activities command, the execution command is that the system starts a shell process to read all stack information from the inside of the system and then outputs the stack information to a command console, and the current stack information of the system is received through the execution shell command in a script or a program, wherein the current stack information is the stack information of all running applications in the system, so the information amount is large, and the command execution time is long.
2. Analyzing stack information text, extracting current interactive with user according to current display page characteristics
2.1 traversing Stack information line by line
2.2 Each page Activity corresponds to a page Activity record in the stack: activity to now empty records
2.3 the value corresponding to each realActivity in the stack information Activity record is the corresponding Activity value: at this time, Activity of the cached record
2.4 the value corresponding to the state in the stack information Activity record is the page speaking state, the page of the state (state) is the page interacting with the user, and when the Activity of the state is traversed, the Activity value cached in 2.3 is directly returned.
It should be noted that Activity is one of the four most basic and most common components (Activity, Service, Content Provider, broadcastereiver broadcast receiver) in the Android components. Activity is an application component that provides a screen through which a user can interact in order to complete a task. All actions in Activity are closely related to the user, and are a component responsible for interaction with the user, and the specified control can be displayed through setContentView (View). In an android application, an Activity is usually a separate screen on which controls can be displayed and in which the user's events can be monitored and processed in response. Activity communicates with each other through Intent.
It can be known from the analysis of the prior art that, in the page testing process in the prior art, the method for acquiring the Activity of the current page is to acquire the current stack information of the system by creating a new process and through a shell command "reduce Activity activities", and then traverse the stack result, where the Activity corresponding to the stack of "state" is the Activity interacted with the user at present. Since the current stack information is the stack information of all the applications already running in the system, the amount of information is large, and traversing the stack information consumes excessive resources and results in long command execution time. In addition, if the current page Activity is acquired in one page for multiple times, a new process needs to be created each time, and the current page Activity is acquired through shell command analysis for multiple times, but the page Activity is not changed in the process, so that excessive resource consumption is further caused.
In order to solve the problem in the prior art, an embodiment of the present invention provides a page component information caching method, and referring to fig. 2, fig. 2 is a flowchart illustrating a first embodiment of the page component information caching method according to the present invention.
In this embodiment, the page component information caching method is used in a page test process of an Android system, where the Android system includes a page controller.
It should be noted that the method of the present embodiment is applied to an Android (Android) system, and may also be referred to as a system in the present embodiment. The page testing process in this embodiment may be an automatic UI (User Interface) testing process of an Android system. It is understood that a page refers to a user interface; the page controller in this embodiment refers to an ActivityController component of the android system.
The page component information caching method comprises the following steps:
in step S10, when the first page change signal is received, the Activity information of the current page component is obtained based on the page controller.
Specifically, the first page changing signal of this embodiment may be a signal generated by a system occurring a page event, that is, a signal generated when a page changing action occurs, for example, a signal generated by an action of switching between existing pages and opening a new page. In practical applications, the first page variation signal may be sensed and received by the page controller.
In addition, the page controller is referred to as an actitycontroller, and in this embodiment, actitystartup and actityresponse page operation methods are registered in the page controller. Wherein, the system calls activityStarting when opening a new page, and calls activityResumming when switching to an existing page.
In one embodiment, the first page change signal is a signal for a system to open a new page, the Android system including an intent object; in this case, when receiving the first page change signal, the step of obtaining the Activity information of the current page component based on the page controller includes:
and when a new page opening signal is received, acquiring the current Activity information through the intention object.
Specifically, the intent, that is, the intent in the Android system, is a message passing object between components, and the intent is used to request operations from other Android components, so that when a new page opening signal is received, in this embodiment, by means of callback of the opportunity of Activity starting, the intent object is used to communicate with the current Activity component, so as to obtain the current Activity information. In the process of page testing, the technical barriers of the tester cause that the tester cannot communicate with the current Activity component by using the intention object by means of the opportunity of callback Activity starting at all, so that the current Activity information is acquired.
Further, referring to fig. 3, a flowchart of a page component information caching method according to a second embodiment of the present invention is shown. In this embodiment, in order to control opening of a new page and caching of current Activity information in a test process, before the step of caching the current Activity information and obtaining cached Activity information, the method further includes:
s101, judging whether the current Activity information is in a blacklist or not;
s102, if the current Activity information is not in the blacklist, caching the current Activity information to obtain cached Activity information.
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.
Specifically, the blacklist in this embodiment includes an uncached Activity information or unopened new page list, and a blacklist page Activity list may be maintained in the script, so that Activity information in the blacklist page Activity list is uncached, and the corresponding new page is unopened; in addition, a blacklisted application list may also be maintained in the script, and all pages of applications in the blacklisted application list cannot be opened and cached.
In addition, the current Activity information may include page Activity information and a package name of the application currently to be opened
Therefore, in this embodiment, when acquiring the current Activity information, S101 is executed to determine whether the current Activity information is in the blacklist, and if so, it indicates that the UI tester does not need to cache the current Activity information and does not need to open a corresponding new page, so S103 is executed; otherwise, executing step S102 to cache the current Activity information to obtain the cached Activity information, so as to provide the cached Activity information for subsequent convenient acquisition and use.
For example, in a service scenario, the start test system does not allow the user to open a set designated page, and the start test system starts the running of the alarm clock in the executed customized script task mobile phone. Adding the appointed page into the blacklist page Activity list, and adding the alarm clock and the alarm clock into the blacklist application program list.
In another alternative embodiment, the first page change signal is a signal for the system to switch to an existing page; in this case, when receiving the first page change signal, the step of obtaining Activity information of the current page component based on the page controller further includes:
and when a signal for switching to the existing page is received, asynchronously analyzing and acquiring the current Activity information through a shell command.
Specifically, switching to an existing page refers to switching between opened old pages, for example, simulating a page opened by a user clicking a return key in a test process; at this time, the current Activity information can be obtained through callback ActivityStarting and asynchronous parsing by shell command.
Further, when a signal for switching to an existing page is received, the Activity response can only obtain the name of the corresponding application package, and at this time, the shell command "dumpsys Activity activities" needs to be used for analyzing the current Activity information.
In addition, it can be understood that, in order to implement the aforementioned method for calling back the activtystarting and activtyresetting page operations through the page controller, as an optional embodiment, before the step of obtaining the Activity information of the current page component based on the page controller when the first page change signal is received, the method further includes:
and registering a page operation method in the page controller in a reflection mode.
Specifically, as described above, the page operation methods include activitystaring and ActivityResuming. Since the system API above android7.0(24) changes, and the reflective registration is for the method of the present embodiment to adapt to the android system in multiple versions, the compatibility is better.
In a specific implementation process, in the android system, the ActivityController can be registered in a reflection manner as follows:
1. the method comprises the following steps of constructing parameters (more than Android7.0 is added with a bootean type parameter) for registering an ActivityController, wherein the Android is more than 7.0: class [ ] parameterTypes ═ new Class [ ] { iactivicycontroller.
Android7.0 and the following: class [ ] parameterTypes ═ new Class [ ] { iactivitycontroller.
2. The method comprises the following steps of constructing parameter information (adding a bootean type parameter above android 7.0) required by registering an ActivityController, and specifically comprising the following steps:
android7.0 or more: new Object [ ] { iActivitycontroller, false };
android7.0 and the following: object [ ] parameter values [ ] { iactive controller };
android7.0 and the following: class [ ] parameterTypes ═ new Class [ ] { iactivitycontroller.
3. A setactivecontroller method of acquiring ActivityManager registered ActivityController through reflection:
Methodmethod=mAm.getClass().getMethod("setActivityController",parameterTypes);
4. setting the access attribute of registered ActivityController method as true (see Java method access authority for details)
method.setAccessible(true);
5. Method for calling registered activtycontroller in reflection mode
method.invoke(mAm,parameterValues)。
It should be understood that the above is only an example, and the technical solution of the present invention is not limited in any way, and those skilled in the art can set the technical solution based on the needs in practical application, and the technical solution is not limited herein.
And step S20, caching the current Activity information to obtain cached Activity information.
Specifically, caching in this embodiment means caching the current Activity information into a memory variable of the system. In this embodiment, the cache Activity information at least includes a character string corresponding to the current Activity, for example, "com.s.android.ugc.aweme/. detail.ui.detail Activity".
It should be noted that, when a page change (for example) occurs in the system, the page operation method of the page controller is called back, a page cache event is triggered inside the page operation method, the page cache event provides a page caching opportunity, and the Activity information of the current page can be obtained when the page changes, and the current Activity information is cached to obtain the cache Activity information.
In this embodiment, the caching may be to store the Activity information that is not stored in the memory into the memory, or to perform a first update on the Activity information that is stored in the memory, that is, as long as a page change (for example) occurs in the system, a page operation method of the page controller is called back, a page caching event is triggered inside the page operation method, the page caching event provides a time for caching a page, the Activity information of the current page may be obtained when the page changes, and the current Activity information is stored or first updated to obtain the cache Activity information. That is, in this embodiment, during the page test process, only the steps S10-S20 are executed or executed in a loop, so that the Activity information of the test page, i.e. the cache Activity information, can be maintained in the memory of the system. The cache Activity information in the memory can be quickly acquired by the tester, so that the situation that the Activity information is acquired by frequently calling the shell command to traverse too much stack information is avoided, and the resource consumption for acquiring the page information in the page testing process is reduced. In addition, for the situation that the Activity of the current page is obtained in one page for multiple times, because the cache Activity information is maintained in the memory, the Activity information can be directly obtained for multiple times, and the Activity information does not need to be obtained by frequently calling a shell command to traverse excessive stack information, so that the resource consumption for obtaining the page information in the page testing process is further reduced.
It should be understood that the above is only an example, and the technical solution of the present invention is not limited in any way, and those skilled in the art can set the technical solution based on the needs in practical application, and the technical solution is not limited herein.
The page component information caching method provided by the embodiment is used in a page testing process of an Android system, and in the page testing process, a page controller can detect page changes and can call the opportunity of a callback method registered by the page controller to acquire Activity information of a page by means of the page changes, and then cache the Activity information to acquire cached Activity information; the cached Activity information can be quickly acquired by the tester, so that the Activity information is prevented from being acquired by frequently calling the shell command to traverse too much stack information, and the resource consumption for acquiring the page information in the page testing process is reduced.
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:
and when a second page change signal is received, correcting the cache Activity information.
Specifically, the second page changing signal of this embodiment may be a signal generated by a system occurring a page event, that is, a signal generated when a page changing action occurs, for example, a signal generated by an action of switching between existing pages and opening a new page.
The cache Activity information is corrected to further ensure the consistency between the current page interacted with the user and the cache page, so as to ensure that a tester can accurately master the information of the test page through the cache Activity information in the memory.
Referring to fig. 4, fig. 4 is a flowchart illustrating a page component information caching method according to a third embodiment of the present invention.
Based on the first embodiment, in this embodiment, a specific implementation manner for correcting the cache Activity information is provided. For ease of understanding, the following detailed description is made in conjunction with fig. 4:
s301, when the second page change signal is received, acquiring page information of a current page event corresponding to the second page change signal;
s302, judging whether the page information meets a preset condition or not;
s303, if the page information meets the preset condition, correcting the cache Activity information.
Specifically, in step S301, the page event refers to an accessibityevent; the page information of the current page event corresponding to the second page change signal may include a name of an application package corresponding to the current page event and a form of the current page event, and may also include a type of the current page event (for example, display content is refreshed, a control is clicked), and the like. Every time when the Android device display content changes, the system returns a corresponding page event (accessibityevent) and acquires corresponding page information.
After the page information of the current page event corresponding to the second page change signal is acquired, S302 is executed next to determine whether the page information meets a preset condition.
Specifically, the preset condition may be set as needed, as long as the purpose of correcting the cache Activity information can be achieved. For example, the preset condition may be whether the page information does not match the cache Activity information, and whether the form of the current page event changes.
In a specific implementation process, the embodiment mainly performs correctness verification on the cache Activity information by using form information (a form windows id and an application package name of a current page) carried by an access event of an Android automatic test framework.
As an embodiment, the step of determining whether the page information satisfies a preset condition includes:
and judging whether the page information is not matched with the cache Activity information and/or judging whether the form of the current page event changes.
In an embodiment, the page information includes a first application package name corresponding to the current page event, and the cache Activity information includes a second application package name; the step of judging whether the page information is not matched with the cache Activity information comprises the following steps:
and judging whether the first application package name is inconsistent with the first application package name.
Specifically, in this embodiment, whether the package name in the Activity information is consistent with the application package name of the current form event may be determined in a character string matching manner. Executing S303, if the page information meets the preset condition, correcting the cache Activity information, namely if the page information is inconsistent, determining that the cache Activity information is invalid, and re-caching the page Activity information; if the cache Activity information is consistent, the cache Activity information is proved to be valid.
In another embodiment, the cached Activity information may be corrected by determining whether the form of the current page event changes. For example, when browsing news information in a news app, although the page content changes when the information is loaded by sliding up and down, the windows id acquired by the getWindowId () method of accessiblityevent does not change; and if clicking a certain news to check news details, the windows ID changes, wherein the windows ID of a window loading event on the previous window is cached, the page event is compared with the cached windows ID when occurring, and if the page event changes, the page Activity is cached again to ensure the accuracy of cached information.
It should be understood that the above is only an example, and the technical solution of the present invention is not limited in any way, and those skilled in the art can set the technical solution based on the needs in practical application, and the technical solution is not limited herein.
As can be easily found from the above description, according to the method for correcting the cache Activity information provided in this embodiment, the correctness of the cache Activity information is verified by using the form information (the form window id and the application package name of the current page) carried by the access availability event of the Android automatic test framework, so as to ensure the accuracy of the cache Activity information maintained in the memory, and provide more accurate Activity information for the tester.
In another embodiment of the present invention, on the basis of the first embodiment, after the step of caching the current Activity information and obtaining cached Activity information, the method further includes:
and acquiring page test data based on the cache Activity information.
Specifically, the page test data refers to data in a page test process, and specifically may include: which is the current page Activity, which pages were opened during the test, the number of times the pages were opened, etc.
For the step of acquiring the page test data based on the cache Activity information, a tester directly and quickly acquires the page test data in the test script through a cache mechanism without analyzing stack information by using a dumpsys command every time, and the consumption of the script on system resources is reduced.
In another embodiment of the present invention, on the basis of the first embodiment, after the step of obtaining page test data based on the cache Activity information, the method further includes:
and counting the Activities displayed in the page testing process based on the page testing data.
Specifically, the current Activity information and the current time can be stored in a file each time the Activity starting method and the Activity resetting method are triggered, the file can be analyzed to check and count the pages opened by the whole use case after the use case is executed, and the information such as the coverage of the pages by the use case, the repeated opening times of the pages, the page staying time and the like can be obtained. The purpose of statistics is as follows: the method is used for analyzing the coverage rate of the case and facilitating the business evaluation of the test case.
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:
and detecting the page test process based on the cache Activity information.
Specifically, based on the cache Activity information, the next action can be judged through a page, and the next action is mainly used for a tester to write a script and judge the current state in the script; in addition, in the testing process, if the test case finds the bug, the Activity information can be provided for developers, and the developers can be helped to quickly locate the page with the problem.
Through the above description, it is not difficult to find that, on one hand, compared with the conventional method for acquiring Activity information by calling a shell command to traverse too much stack information, the method for caching page component information of the embodiment reduces resource consumption for acquiring page information in a page testing process; on the other hand, the method for accurately managing the pages in the test process, such as page statistics, and the like, and the method for detecting the test process are also realized.
In addition, an embodiment of the present invention further provides a storage medium, where a page component information caching program is stored on the storage medium, and the page component information caching program, when executed by a processor, implements the steps of the page component information caching method described above.
Referring to fig. 5, fig. 5 is a block diagram illustrating a first embodiment of a page component information caching apparatus according to the present invention.
The page component information caching device is used for a page testing process of an Android system, and the Android system comprises a page controller; as shown in fig. 5, the page component information caching apparatus provided in this embodiment includes:
the information acquisition module is used for acquiring Activity information of the current page component based on the page controller when receiving a first page change signal;
and the information caching module is used for caching the current Activity information to obtain cached Activity information.
The page component information caching device provided by the embodiment is used in a page testing process of an Android system, and in the page testing process, a page controller can detect page changes and can call the opportunity of a callback method registered by the page controller to acquire Activity information of a page by means of the page changes, and then cache the Activity information to acquire cached Activity information; the cached Activity information can be quickly acquired by the tester, so that the Activity information is prevented from being acquired by frequently calling the shell command to traverse too much stack information, and the resource consumption for acquiring the page information in the page testing process is reduced.
Based on the first embodiment of the above-mentioned 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.
In this embodiment, the information caching module is further configured to obtain the current Activity information through the intention object when a signal for opening a new page is received.
As an embodiment, the page component information caching apparatus further includes:
the information judgment module is used for judging whether the current Activity information is in a blacklist or not before the steps of caching the current Activity information and obtaining cached Activity information;
the information caching submodule is used for caching the current Activity information to obtain caching Activity information if the current Activity information is not in the blacklist; if the current Activity information is in the blacklist, the current Activity information is not cached and the new page is not opened.
As an embodiment, the information caching module is further configured to obtain the current Activity information through shell command asynchronous parsing when a signal for switching to an existing page is received.
As an embodiment, the page component information caching apparatus further includes:
and the information updating module is used for updating the cache Activity information when a second page change signal is received after the steps of caching the current Activity information and obtaining the cache Activity information.
As an embodiment, the information updating module is further configured to, when the second page change signal is received, obtain page information of a current page event corresponding to the second page change signal; judging whether the page information meets a preset condition or not; and if the page information meets the preset condition, correcting the cache Activity information.
As an embodiment, the information updating module further includes:
the information matching judgment module is used for judging whether the page information is not matched with the cache Activity information; and/or the presence of a gas in the gas,
and the window change judging module is used for judging whether the window of the current page event changes.
As an embodiment, the information matching determining module is further configured to determine whether the first application package name is inconsistent with the first application package name; the page information comprises a first application package name corresponding to the current page event, and the cache Activity information comprises a second application package name.
As an embodiment, the page component information caching apparatus further includes:
and the data acquisition module is used for acquiring page test data based on the cache Activity information after the step of caching the current Activity information and acquiring the cache Activity information.
The page component information caching device further comprises:
as an embodiment, the page statistics module is configured to, after the step of obtaining page test data based on the cache Activity information, perform statistics on Activity displayed in the page test process based on the page test data.
As an embodiment, the page component information caching apparatus further includes:
and the data acquisition module is used for detecting the page test process based on the cache Activity information after the step of caching the current Activity information and acquiring the cache Activity information.
Other embodiments or specific implementation manners of the page component information caching apparatus of the present invention may refer to the above method embodiments, and are not described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., a rom/ram, a magnetic disk, an optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. The page component information caching method is used for a page testing process of an Android system, and the Android system comprises a page controller; the page component information caching method comprises the following steps:
when a first page change signal is received, acquiring Activity information of a current page component based on the page controller;
and caching the current Activity information to obtain cached Activity information.
2. The method for caching page component information according to claim 1, wherein the first page change signal comprises an open new page signal, and the Android system comprises an intent object; the step of acquiring Activity information of the current page component based on the page controller when receiving the first page change signal includes:
and when a new page opening signal is received, acquiring current Activity information through the intention object based on the page controller.
3. The method for caching page component information according to claim 2, wherein before the step of caching the current Activity information and obtaining the cached Activity information, the method further comprises:
judging whether the current Activity information is in a blacklist or not;
if the current Activity information is not in the blacklist, the step of caching the current Activity information to obtain cached Activity information is executed.
4. The page component information caching method according to any one of claims 1 to 3, wherein the first page change signal includes a switch-to-existing page signal, and the step of acquiring, based on the page controller, the current page component Activity information upon receiving the first page change signal further comprises:
and when a signal for switching to the existing page is received, asynchronously analyzing through a shell command to acquire the current Activity information.
5. The page component information caching method according to any one of claims 1 to 3, wherein after said caching said current Activity information and obtaining cached Activity information, said method further comprises:
and when a second page change signal is received, correcting the cache Activity information.
6. The page component information caching method according to claim 5, wherein said step of correcting said caching Activity information upon receiving a second page change signal comprises:
when the second page change signal is received, acquiring page information of a current page event corresponding to the second page change signal;
judging whether the page information meets a preset condition or not;
and if the page information meets the preset condition, correcting the cache Activity information.
7. The method for caching page component information according to claim 6, wherein the step of determining whether the page information satisfies a preset condition comprises:
and judging whether the page information is not matched with the cache Activity information and/or judging whether the form of the current page event changes.
8. The page component information caching device is characterized in that the page component information caching device is used for a page testing process of an Android system, and the Android system comprises a page controller; the page component information caching device comprises:
the information acquisition module is used for acquiring Activity information of the current page component based on the page controller when receiving a first page change signal;
and the information caching module is used for caching the current Activity information to obtain cached Activity information.
9. A page component information caching apparatus, characterized in that the apparatus comprises: a memory, a processor and a page component information caching program stored on the memory and executable on the processor, the page component information caching program being configured to implement the steps of the page component information caching method as claimed in any one of claims 1 to 7.
10. A storage medium having stored thereon a page component information caching program, the page component information caching program, when executed by a processor, implementing the steps of the page component information caching method according to any one of claims 1 to 7.
CN202010713924.1A 2020-07-22 2020-07-22 Page component information caching method, device, equipment and storage medium Pending CN113971057A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010713924.1A CN113971057A (en) 2020-07-22 2020-07-22 Page component information caching method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010713924.1A CN113971057A (en) 2020-07-22 2020-07-22 Page component information caching method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113971057A true CN113971057A (en) 2022-01-25

Family

ID=79585048

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010713924.1A Pending CN113971057A (en) 2020-07-22 2020-07-22 Page component information caching method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113971057A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105302801A (en) * 2014-05-27 2016-02-03 腾讯科技(深圳)有限公司 Resource caching method and apparatus
CN106250165A (en) * 2016-06-12 2016-12-21 杭州无量网络科技有限公司 Application component management method and system
WO2018129774A1 (en) * 2017-01-16 2018-07-19 网宿科技股份有限公司 Method and device for page processing
CN108600382A (en) * 2018-04-28 2018-09-28 广州联欣信息科技有限公司 A kind of method and computer readable storage medium of the APP content cachings in internet off-line
CN109144633A (en) * 2018-07-20 2019-01-04 武汉斗鱼网络科技有限公司 Data sharing method, device, equipment and the storage medium of active window
CN109492176A (en) * 2018-10-30 2019-03-19 天脉聚源(北京)教育科技有限公司 A kind of page info update method and device
CN109697088A (en) * 2018-11-23 2019-04-30 努比亚技术有限公司 Application interface loading method, mobile terminal and computer readable storage medium
CN109800135A (en) * 2017-11-17 2019-05-24 腾讯科技(深圳)有限公司 A kind of information processing method and terminal

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105302801A (en) * 2014-05-27 2016-02-03 腾讯科技(深圳)有限公司 Resource caching method and apparatus
CN106250165A (en) * 2016-06-12 2016-12-21 杭州无量网络科技有限公司 Application component management method and system
WO2018129774A1 (en) * 2017-01-16 2018-07-19 网宿科技股份有限公司 Method and device for page processing
CN109800135A (en) * 2017-11-17 2019-05-24 腾讯科技(深圳)有限公司 A kind of information processing method and terminal
CN108600382A (en) * 2018-04-28 2018-09-28 广州联欣信息科技有限公司 A kind of method and computer readable storage medium of the APP content cachings in internet off-line
CN109144633A (en) * 2018-07-20 2019-01-04 武汉斗鱼网络科技有限公司 Data sharing method, device, equipment and the storage medium of active window
CN109492176A (en) * 2018-10-30 2019-03-19 天脉聚源(北京)教育科技有限公司 A kind of page info update method and device
CN109697088A (en) * 2018-11-23 2019-04-30 努比亚技术有限公司 Application interface loading method, mobile terminal and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
LATEREQUALSNEVER: ""Android关于Activity的一些使用和全局管理技巧"", pages 1 - 8, Retrieved from the Internet <URL:《https://blog.csdn.net/ghost_Programmer/article/details/50072855》> *

Similar Documents

Publication Publication Date Title
KR101790190B1 (en) Application scenario identification method, power consumption management method, apparatus, and terminal device
US7529977B2 (en) Automated extensible user interface testing
US7398469B2 (en) Automated test system for testing an application running in a windows-based environment and related methods
US8296445B1 (en) Software testing harness
CN108415804B (en) Method for acquiring information, terminal device and computer readable storage medium
CN108399124B (en) Application testing method and device, computer equipment and storage medium
CN110795311B (en) Event playback method and device
US10691390B2 (en) Method and device for video rendering
US10466894B2 (en) Method, device, storage medium and mobile terminal for recognizing an off-screen gesture
CN110704311A (en) Application program testing method and device, electronic equipment and readable storage medium
CN110838929A (en) System error checking method and system error checking device
US9684688B2 (en) System and methods for matching identifiable patterns and enabling associated actions
CN108268298B (en) Desktop icon generation method and device, storage medium and electronic equipment
CN104808913A (en) Event responding method and device
US20130185733A1 (en) Subscriber-based event subscription
CN109246077B (en) Distributed concurrent transaction verification method, device and computer storage medium
CN113971057A (en) Page component information caching method, device, equipment and storage medium
CN111124627A (en) Method, device, terminal and storage medium for determining application program caller
CN115756934A (en) Application crash analysis method and device
CN111722881B (en) Resource expansion method, system and device of container cloud platform
CN111741046B (en) Data reporting method, data acquisition method, device, equipment and medium
KR100948472B1 (en) Automatic updating of variables in a data language
CN113220296A (en) Android system interaction method and device
CN113467867A (en) Information processing method, information processing device, electronic equipment and storage medium
CN111443907A (en) Method and device for calling SDK function

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination