[go: up one dir, main page]

CN103353858A - Automatic testing method and device based on action touch simulation - Google Patents

Automatic testing method and device based on action touch simulation Download PDF

Info

Publication number
CN103353858A
CN103353858A CN2013102225132A CN201310222513A CN103353858A CN 103353858 A CN103353858 A CN 103353858A CN 2013102225132 A CN2013102225132 A CN 2013102225132A CN 201310222513 A CN201310222513 A CN 201310222513A CN 103353858 A CN103353858 A CN 103353858A
Authority
CN
China
Prior art keywords
touch
event
sequence
touch event
uievent
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.)
Granted
Application number
CN2013102225132A
Other languages
Chinese (zh)
Other versions
CN103353858B (en
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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201310222513.2A priority Critical patent/CN103353858B/en
Publication of CN103353858A publication Critical patent/CN103353858A/en
Application granted granted Critical
Publication of CN103353858B publication Critical patent/CN103353858B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

本发明提供了一种基于动作触摸模拟的自动化测试方法和装置,生成符合测试状态的触摸事件并组合成触摸动作的触摸事件序列后,将触摸事件序列发送给被测试系统的事件转发对象,由事件转发对象对序列中的触摸事件进行转发。本发明提供的方法和装置无需连接PC端就能够执行Monkey测试,节约了资源;另外,摆脱了对Instruments工具内存的依赖,提高了测试质量。

The present invention provides an automatic test method and device based on motion touch simulation. After generating touch events conforming to the test state and combining them into a touch event sequence of touch actions, the touch event sequence is sent to the event forwarding object of the system under test. The event forwarding object forwards the touch events in the sequence. The method and device provided by the invention can execute the Monkey test without being connected to a PC, saving resources; in addition, the dependence on the Instruments tool memory is eliminated, and the test quality is improved.

Description

一种基于动作触摸模拟的自动化测试方法和装置An automated testing method and device based on motion touch simulation

【技术领域】【Technical field】

本发明涉及计算机测试技术领域,特别涉及一种基于动作触摸模拟的自动化测试方法和装置。The invention relates to the technical field of computer testing, in particular to an automatic testing method and device based on motion touch simulation.

【背景技术】【Background technique】

Monkey测试是通过Monkey程序模拟用户点击屏幕、滑动、按键等操作来对设备上的程序进行压力测试。目前iOS产品的Monkey自动化测试需要通过连接PC端(Mac机器)的Instruments工具,然后启动javascript脚本执行Monkey自动化测试。这种方式存在以下缺陷:The Monkey test uses the Monkey program to simulate user operations such as clicking on the screen, sliding, and pressing keys to stress test the programs on the device. At present, the Monkey automated testing of iOS products needs to connect to the Instruments tool on the PC side (Mac machine), and then start the javascript script to execute the Monkey automated testing. This approach has the following drawbacks:

1)必须连接Mac机器才能够执行Monkey测试,占用额外的资源。1) The Monkey test must be connected to a Mac machine, which takes up additional resources.

2)对Instruments工具的内存要求较高,如果内存不足可能导致Monkey测试停止,测试质量无法得到保证。2) The memory requirements for the Instruments tool are high. If the memory is insufficient, the Monkey test may stop, and the test quality cannot be guaranteed.

【发明内容】【Content of invention】

有鉴于此,本发明提供了一种基于动作触摸模拟的自动化测试方法和装置,以便于节约资源和提高测试质量。In view of this, the present invention provides an automatic test method and device based on motion touch simulation, so as to save resources and improve test quality.

具体技术方案如下:The specific technical scheme is as follows:

一种基于动作触摸模拟的自动化测试方法,该方法包括:An automated testing method based on motion touch simulation, the method comprising:

S1、生成符合测试状态的触摸事件并组合成触摸动作的触摸事件序列;S1. Generate a touch event conforming to the test state and combine it into a touch event sequence of a touch action;

S2、将触摸事件序列发送给被测试系统的事件转发对象,由事件转发对象对序列中的触摸事件进行转发。S2. Send the touch event sequence to the event forwarding object of the system under test, and the event forwarding object forwards the touch events in the sequence.

根据本发明一优选实施例,所述步骤S1具体包括:According to a preferred embodiment of the present invention, the step S1 specifically includes:

S11、从测试用例中获取触摸动作信息;S11. Obtain touch action information from the test case;

S12、根据获取的触摸动作信息计算触摸轨迹;S12. Calculate the touch trajectory according to the acquired touch action information;

S13、按照触摸动作方向,每隔预设时间间隔在触摸轨迹中对应位置插入与该位置的触摸动作类型对应的触摸事件,得到触摸事件序列。S13. According to the direction of the touch action, insert a touch event corresponding to the touch action type at the corresponding position in the touch track every preset time interval to obtain a touch event sequence.

根据本发明一优选实施例,所述触摸动作信息采用多元参数组进行描述,所述多元参数组包括:起始点和结束点的位置、速度、加速度、持续时间和点击次数。According to a preferred embodiment of the present invention, the touch action information is described by a multivariate parameter set, and the multivariate parameter set includes: the position, speed, acceleration, duration and number of clicks of the start point and the end point.

根据本发明一优选实施例,若所述触摸动作类型为N点触摸,则所述触摸动作信息采用N个多元参数组进行描述,在所述步骤S12中得到N条触摸轨迹,在所述步骤S13中每个触摸事件插入的位置存在N个坐标点,N为正整数。According to a preferred embodiment of the present invention, if the type of the touch action is N-point touch, the touch action information is described using N multivariate parameter groups, and N touch trajectories are obtained in the step S12. There are N coordinate points at the insertion position of each touch event in S13, where N is a positive integer.

根据本发明一优选实施例,在插入与该位置的触摸动作类型对应的触摸事件时,在起始点位置插入按下状态的触摸事件,在结束点位置插入弹起状态的触摸事件,在起始点和结束点之间的各位置插入移动状态的触摸事件。According to a preferred embodiment of the present invention, when inserting a touch event corresponding to the type of touch action at this position, a touch event in a pressed state is inserted at the start point, a touch event in a pop-up state is inserted at the end point, and a touch event in a pop-up state is inserted at the start point. Insert the touch event of the moving state at each position between and the end point.

根据本发明一优选实施例,若所述被测试系统为iSO系统,则所述触摸事件为UIEvent,所述事件转发对象为UIApplication,所述UIApplication将UIEvent序列中的UIEvent分发给目标视图;According to a preferred embodiment of the present invention, if the system under test is an ISO system, the touch event is UIEvent, the event forwarding object is UIApplication, and the UIApplication distributes the UIEvent in the UIEvent sequence to the target view;

若所述被测试系统为Android系统,则所述触摸事件为MotionEvent,所述事件转发对象为Instrumentation,所述Instrumentation将MotionEvent序列中的MotionEvent转发给Android系统,以供Android系统系统广播给监听的Application。If the system under test is an Android system, then the touch event is a MotionEvent, and the event forwarding object is an Instrumentation, and the Instrumentation forwards the MotionEvent in the MotionEvent sequence to the Android system for the Android system to broadcast to the monitoring Application .

一种基于动作触摸模拟的自动化测试装置,该装置包括:An automatic testing device based on motion touch simulation, the device comprising:

事件生成单元,用于生成符合测试状态的触摸事件并组合成触摸动作的触摸事件序列;An event generation unit, configured to generate a touch event conforming to the test state and combine it into a touch event sequence of a touch action;

事件发送单元,用于将所述触摸事件序列发送给被测试系统的事件转发对象,由事件转发对象对序列中的触摸事件进行转发。The event sending unit is configured to send the touch event sequence to the event forwarding object of the system under test, and the event forwarding object forwards the touch events in the sequence.

根据本发明一优选实施例,所述事件生成单元具体包括:According to a preferred embodiment of the present invention, the event generating unit specifically includes:

信息获取子单元,用于从测试用例中获取触摸动作信息;The information acquisition subunit is used to acquire touch action information from the test case;

轨迹计算子单元,用于根据所述触摸动作信息计算触摸轨迹;A trajectory calculation subunit, configured to calculate a touch trajectory according to the touch action information;

事件插入子单元,用于按照触摸动作方向,每隔预设时间间隔在触摸轨迹中对应位置插入与该位置的触摸动作类型对应的触摸事件,得到触摸事件序列。The event insertion subunit is configured to insert a touch event corresponding to the type of touch action at the corresponding position in the touch track at preset time intervals according to the direction of the touch action, to obtain a sequence of touch events.

根据本发明一优选实施例,所述触摸动作信息采用多元参数组进行描述,所述多元参数组包括:起始点和结束点的位置、速度、加速度、持续时间和点击次数。According to a preferred embodiment of the present invention, the touch action information is described by a multivariate parameter set, and the multivariate parameter set includes: the position, speed, acceleration, duration and number of clicks of the start point and the end point.

根据本发明一优选实施例,若所述触摸动作类型为N点触摸,则所述触摸动作信息采用N个多元参数组进行描述,所述轨迹计算子单元得到N条触摸轨迹,所述事件插入子单元在插入触摸事件时,每个触摸事件插入的位置存在N个坐标点,N为正整数。According to a preferred embodiment of the present invention, if the type of the touch action is N-point touch, the touch action information is described using N multivariate parameter groups, the trajectory calculation subunit obtains N touch trajectories, and the event insertion When the subunit inserts a touch event, there are N coordinate points at the insertion position of each touch event, where N is a positive integer.

根据本发明一优选实施例,所述事件插入子单元在插入与该位置的触摸动作类型对应的触摸事件时,在起始点位置插入按下状态的触摸事件,在结束点位置插入弹起状态的触摸事件,在起始点和结束点之间的各位置插入移动状态的触摸事件。According to a preferred embodiment of the present invention, when the event insertion subunit inserts a touch event corresponding to the touch action type at this position, a touch event in a pressed state is inserted at the start point position, and a touch event in a pop-up state is inserted at the end point position. Touch events, insert moving state touch events at each position between the start point and the end point.

根据本发明一优选实施例,若所述被测试系统为iSO系统,则所述触摸事件为UIEvent,所述事件转发对象为UIApplication,所述UIApplication将UIEvent序列中的UIEvent分发给目标视图;According to a preferred embodiment of the present invention, if the system under test is an ISO system, the touch event is UIEvent, the event forwarding object is UIApplication, and the UIApplication distributes the UIEvent in the UIEvent sequence to the target view;

若所述被测试系统为Android系统,则所述触摸事件为MotionEvent,所述事件转发对象为Instrumentation,所述Instrumentation将MotionEvent序列中的MotionEvent转发给Android系统,以供Android系统系统广播给监听的Application。If the system under test is an Android system, then the touch event is a MotionEvent, and the event forwarding object is an Instrumentation, and the Instrumentation forwards the MotionEvent in the MotionEvent sequence to the Android system for the Android system to broadcast to the monitoring Application .

由以上技术方案可以看出,本发明提供的方法和装置无需连接PC端就能够执行Monkey测试,节约了资源;另外,摆脱了对Instruments工具内存的依赖,提高了测试质量。It can be seen from the above technical solutions that the method and device provided by the present invention can execute the Monkey test without connecting to the PC, which saves resources; in addition, it gets rid of the dependence on the Instruments tool memory and improves the test quality.

【附图说明】【Description of drawings】

图1为本发明实施例一提供的自动化测试方法流程图;FIG. 1 is a flowchart of an automated testing method provided by Embodiment 1 of the present invention;

图2为本发明实施例一提供的针对滑动的触摸轨迹和UIEvent示意图;FIG. 2 is a schematic diagram of a touch track and a UIEvent for sliding provided by Embodiment 1 of the present invention;

图3为本发明实施例一提供的针对双指挤压的触摸轨迹和UIEvent示意图;FIG. 3 is a schematic diagram of a touch track and a UIEvent for two-finger squeeze provided by Embodiment 1 of the present invention;

图4为本发明实施例二提供的自动化测试装置结构图。FIG. 4 is a structural diagram of an automated testing device provided by Embodiment 2 of the present invention.

【具体实施方式】【Detailed ways】

为了使本发明的目的、技术方案和优点更加清楚,下面结合附图和具体实施例对本发明进行详细描述。In order to make the object, technical solution and advantages of the present invention clearer, the present invention will be described in detail below in conjunction with the accompanying drawings and specific embodiments.

由于Monkey自动化测试的基本流程就是随机调用与屏幕处理相关的函数接口触发各种屏幕触摸动作,以模拟用户的屏幕触摸行为,而iOS的屏幕触摸动作本质上是由UIEvent(用户界面事件)组成,也就是一个触摸动作对应一个UIEvent序列。当用户触摸屏幕时,iOS生成对应的UIEvent;然后UIAplication(用户界面应用)对象将接收到的UIEvent序列进行分发;最后,分发到的目标视图会对UIEvent进行触摸逻辑处理。基于上述原理,本发明的核心思想是通过创建符合测试状态的UIEvent组合成触摸动作的UIEvent序列,将UIEvent序列发送给UIAplication对象,由UIAplication对象进行分发处理。下面通过实施例一对本发明提供的方法进行详细描述。Since the basic process of Monkey automated testing is to randomly call the function interface related to screen processing to trigger various screen touch actions to simulate the user's screen touch behavior, and the screen touch action of iOS is essentially composed of UIEvent (user interface event), That is, a touch action corresponds to a UIEvent sequence. When the user touches the screen, iOS generates the corresponding UIEvent; then the UIAplication (user interface application) object distributes the received UIEvent sequence; finally, the distributed target view performs touch logic processing on the UIEvent. Based on the above principles, the core idea of the present invention is to combine the UIEvents conforming to the test state into a UIEvent sequence of touch actions, send the UIEvent sequence to the UIAplication object, and the UIAplication object performs distribution processing. The method provided by the present invention is described in detail below through examples.

实施例一、Embodiment one,

图1为本发明实施例一提供的方法流程图,在该实施例中基于用户提供的case(测试用例)模拟用户的测试行为进行自动化测试,如图1所示,该方法包括以下步骤:Fig. 1 is a flow chart of the method provided by Embodiment 1 of the present invention. In this embodiment, based on the case (test case) provided by the user, the user's test behavior is simulated for automated testing. As shown in Fig. 1, the method includes the following steps:

步骤101:从case中获取触摸动作信息。Step 101: Obtain touch action information from the case.

在case中通常会包含诸如被测试对象、测试环境等信息,由于本发明实施例中的测试是Monkey测试,因此case中还会包含触摸动作信息,也就是后续需要被模拟的触摸动作,鉴于触摸动作可能会包含多种类型,例如单击、滑动、多点触摸等等,但对于事件类型而言,主要有两个维度的划分,第一个维度是点击次数,即单击、双击、多击等,第二个维度是触摸点数量,即是单点、两点、多点等。在此每一种类型的触摸动作都可以采用多元参数组进行描述。该多元参数组包括:起始点和结束点的位置、速度、加速度、持续时间和点击次数。下面举几个例子:The case usually contains information such as the object to be tested, the test environment, etc. Since the test in the embodiment of the present invention is a Monkey test, the case also contains touch action information, which is the subsequent touch action that needs to be simulated. In view of the touch Actions may include multiple types, such as click, slide, multi-touch, etc., but for event types, there are mainly two dimensions. The first dimension is the number of clicks, that is, click, double-click, multi-touch, etc. Click, etc., the second dimension is the number of touch points, that is, single point, two points, multi-point, etc. Here, each type of touch action can be described by a multivariate parameter set. The multivariate parameter group includes: the position of the start point and the end point, velocity, acceleration, duration and number of clicks. Here are a few examples:

假设要测试单击屏幕坐标(100,100)处,持续1.5s,那么case中包含的触摸动作信息可以为如下多元参数组:Suppose you want to test to click on the screen coordinates (100,100) for 1.5s, then the touch action information contained in the case can be the following multivariate parameter group:

<(100,100),(100,100),0,0,1.5,1><(100,100),(100,100),0,0,1.5,1>

假设要测试从屏幕坐标(100,100)滑动到(150,200),持续2s,滑动速度为10m/s,那么case中包含的触摸动作信息可以为如下多元参数组:Suppose you want to test sliding from screen coordinates (100,100) to (150,200) for 2 seconds, and the sliding speed is 10m/s, then the touch action information contained in the case can be the following multivariate parameter group:

<(100,100),(150,200),10,0,2,1><(100,100), (150,200), 10, 0, 2, 1>

对于多点触摸,假设要测试双指挤压,从屏幕坐标(100,100)和(180,100)挤压到屏幕坐标(140,120)和(160,120),会存在两条运动轨迹,那么case中包含的触摸动作信息可以为如下两个多元参数组:For multi-touch, suppose you want to test two-finger squeeze, from screen coordinates (100,100) and (180,100) to screen coordinates (140,120) and (160,120), there will be two motion tracks, then the touch action contained in the case The information can be two multivariate parameter groups as follows:

<(100,100),(140,120),10,0,2,1><(100,100),(140,120),10,0,2,1>

<(180,100),(160,120),10,0,2,1><(180,100), (160,120), 10, 0, 2, 1>

步骤102:根据获取的触摸动作信息计算触摸轨迹,按照触摸动作方向,每隔预设时间间隔在触摸轨迹中对应位置插入与该位置的触摸动作类型对应的UIEvent,得到UIEvent序列。Step 102: Calculate the touch track according to the acquired touch action information, insert a UIEvent corresponding to the touch action type at the corresponding position in the touch track every preset time interval according to the touch action direction, and obtain a UIEvent sequence.

在计算触摸轨迹时,采用的是传统的数学方法,即

Figure BDA00003309449900051
其中,Y为动作结束点的位置,X为动作起始点的位置,
Figure BDA00003309449900052
为速度向量,为加速度向量,t为时间。When calculating the touch trajectory, the traditional mathematical method is used, namely
Figure BDA00003309449900051
Among them, Y is the position of the end point of the action, X is the position of the starting point of the action,
Figure BDA00003309449900052
is the velocity vector, is the acceleration vector, and t is the time.

在插入UIEvent时,主要需要三个因素,其一是插入点位置,其二是触摸动作类型,其三是动作状态。由于插入UIEvent是按照预设时间间隔插入的,因此可以确定出插入的时间点在触摸轨迹中的位置(即代入上述触摸轨迹的公式)。触摸动作类型上面已经描述过主要体现在两个维度:点击次数和触摸点数量,点击次数可以从case中多元参数组中直接获取,触摸点数量对应case中多元参数组的数量。动作状态主要包括三种:按下状态、移动状态和弹起状态。在插入UIEvent时在起始点位置的动作状态是按下状态,结束点位置的动作状态是弹起状态,触摸轨迹中起始点和结束点之间的各插入点的动作状态是移动状态。When inserting a UIEvent, three factors are mainly required, one is the position of the insertion point, the other is the type of touch action, and the third is the action state. Since the insertion of the UIEvent is inserted at a preset time interval, the position of the inserted time point in the touch track can be determined (that is, substituted into the above formula of the touch track). The type of touch action has been described above and is mainly reflected in two dimensions: the number of clicks and the number of touch points. The number of clicks can be directly obtained from the multivariate parameter group in the case, and the number of touch points corresponds to the number of multivariate parameter groups in the case. Action states mainly include three types: pressed state, moving state and popping state. When inserting a UIEvent, the action state at the starting point is the pressed state, the action state at the end point is the pop-up state, and the action state of each insertion point between the starting point and the end point in the touch track is the moving state.

下面分别以滑动和双指挤压为例:The following are examples of sliding and two-finger squeeze respectively:

滑动动作:从case中可以获知要测试从A点滑动到B点的触摸动作,在根据case中的触摸动作信息计算出触摸轨迹后,按照时间顺序以固定的时间间隔0.05s在触摸轨迹中插入UIEvent,具体为:计算出每隔0.05s时间点的插入点位置,即将0、0.05s、0.1s、0.15s依次类推各时间点在触摸轨迹中的位置分别确定出来,根据case中的触摸动作信息可知其动作类型属于单点单击(点击次数为1,动作轨迹也为1),在各插入点中A点插入单点单击按下状态的UIEvent,在B点插入单点单击弹起状态的UIEvent,在A和B中间各插入点位置插入单点单击移动状态的UIEvent,从而得到按照时间顺序排列的UIEvent序列,在该序列中第i个UIEvent的位置(xi,yi)为:Sliding action: From the case, it can be learned that the touch action to test sliding from point A to point B is to be tested. After calculating the touch track according to the touch action information in the case, insert it in the touch track at a fixed time interval of 0.05s in chronological order UIEvent, specifically: calculate the position of the insertion point at every 0.05s time point, that is, determine the position of each time point in the touch track at 0, 0.05s, 0.1s, 0.15s and so on, according to the touch action in the case The information shows that the action type is single-click (the number of clicks is 1, and the action track is also 1). Insert a single-click UIEvent in the pressed state at point A, and insert a single-click popup at point B. Insert the UIEvent in the starting state, and insert the UIEvent in the single-click moving state at each insertion point between A and B, so as to obtain a sequence of UIEvents arranged in chronological order. In this sequence, the position of the i-th UIEvent (x i , y i )for:

(( xx ii ,, ythe y ii )) == (( xx 00 ,, ythe y 00 )) ++ vv &RightArrow;&Right Arrow; ** (( ii -- 11 )) &Delta;t&Delta;t ,,

其中(x0,y0)为动作起始点A的坐标,Δt为插入UIEvent的时间间隔,生成的UIEvent示意图如图2所示。Wherein (x 0 , y 0 ) is the coordinate of the starting point A of the action, Δt is the time interval for inserting the UIEvent, and the schematic diagram of the generated UIEvent is shown in FIG. 2 .

双指挤压动作:Two-finger squeeze action:

从case中可以获知要测试双指挤压的动作,存在两组多元参数组,因此对两组多元参数组分别计算出触摸轨迹,就得到了两条触摸轨迹,如图3所示,两条触摸轨迹分别从A1到B1,从A2到B2。按照时间顺序以固定的时间间隔0.05s在触摸轨迹中插入UIEvent,即将0、0.05s、0.1s、0.15s依次类推各时间点在触摸轨迹中的位置分别确定出来,根据case中的触摸动作信息可知其动作类型属于多点单击(点击次数为1,动作轨迹也为2),每一个UIEvent对应两个插入点位置,在A1和A2点插入双点单击按下状态的UIEvent,在B1和B2点插入双点单击弹起状态的UIEvent,中间各插入点位置插入双点单击移动状态的UIEvent。在从而得到按照时间顺序排列的UIEvent序列。在该序列中第i个UIEvent的位置(x1i,y1i)和(x2i,y2i)为:It can be known from the case that there are two sets of multivariate parameter groups to test the two-finger squeeze action. Therefore, the touch trajectories are calculated for the two sets of multivariate parameter groups, and two touch trajectories are obtained. As shown in Figure 3, two The touch tracks are from A1 to B1 and from A2 to B2 respectively. Insert UIEvent in the touch track at a fixed time interval of 0.05s in chronological order, that is, determine the position of each time point in the touch track at 0, 0.05s, 0.1s, 0.15s and so on, according to the touch action information in the case It can be seen that its action type belongs to multi-click (the number of clicks is 1, and the action track is also 2). Each UIEvent corresponds to two insertion point positions. Insert a UIEvent in the state of double-click pressing at A1 and A2, and insert a UIEvent in the pressed state at B1. Insert a UIEvent in the double-click pop-up state at point B2, and insert a UIEvent in the double-click moving state at each insertion point in the middle. In order to get the UIEvent sequence arranged in chronological order. The positions (x1 i , y1 i ) and (x2 i , y2 i ) of the i-th UIEvent in the sequence are:

(( xx 11 ii ,, ythe y 11 ii )) == (( xx 11 00 ,, ythe y 11 00 )) ++ vv &RightArrow;&Right Arrow; 11 ** (( ii -- 11 )) &Delta;t&Delta;t

(( xx 22 ii ,, ythe y 22 ii )) == (( xx 22 00 ,, ythe y 22 00 )) ++ vv &RightArrow;&Right Arrow; 22 ** (( ii -- 11 )) &Delta;t&Delta;t

(x10,y10)为A1的坐标,(x20,y20)为A2的坐标,

Figure BDA00003309449900072
为从A1到B1对应的速度向量,
Figure BDA00003309449900073
为从A2到B2对应的速度向量,Δt为插入UIEvent的时间间隔。(x1 0 ,y1 0 ) is the coordinate of A1, (x2 0 ,y2 0 ) is the coordinate of A2,
Figure BDA00003309449900072
is the velocity vector corresponding to from A1 to B1,
Figure BDA00003309449900073
is the corresponding velocity vector from A2 to B2, and Δt is the time interval for inserting UIEvent.

在本发明实施例中可以不同点击次数和触摸点数量进行组合,模拟不同的触摸动作,也可以将不同的case进行组合,即将不同case得到的UIEvent序列进行合并,从而模拟出更加复杂的动作。In the embodiment of the present invention, different click times and touch point numbers can be combined to simulate different touch actions, and different cases can also be combined, that is, UIEvent sequences obtained from different cases are combined to simulate more complex actions.

步骤103:将UIEvent序列发送给UIAplication对象,由UIAplication对象进行分发处理。Step 103: Send the UIEvent sequence to the UIAplication object, and the UIAplication object performs distribution processing.

本发明上述实施例均以iSO系统为例进行的描述,鉴于上述生成触摸事件的方式与平台无关,因此本发明提供的方法还能够应用于诸如android等其他系统,只是在android系统中触摸事件不是UIEvent而是MotionEvent,生成的MotionEvent序列不是发送给UIAplication对象,而是发送给Instrumentation,由Instrumentation将MotionEvent序列转发给Android系统,由Android系统通过系统广播的方式提供给监听的Application(应用)。在此不再针对其他系统逐一赘述。The above-mentioned embodiments of the present invention are all described using the ISO system as an example. In view of the fact that the above-mentioned method of generating touch events has nothing to do with the platform, the method provided by the present invention can also be applied to other systems such as android, except that touch events in the android system are not UIEvent is MotionEvent. The generated MotionEvent sequence is not sent to UIAplication object, but to Instrumentation. Instrumentation forwards the MotionEvent sequence to the Android system, and the Android system provides it to the listening Application (application) through system broadcast. It is not necessary to repeat them one by one for other systems here.

以上是对本发明提供的方法进行的详细描述,下面通过实施例二对本发明提供的自动化测试装置进行详细描述。The above is a detailed description of the method provided by the present invention, and the automated testing device provided by the present invention will be described in detail below through the second embodiment.

实施例二、Embodiment two,

图4为本发明实施例二提供的装置结构图,如图4所示,该装置主要包括事件生成单元00和事件发送单元10。FIG. 4 is a structural diagram of a device provided by Embodiment 2 of the present invention. As shown in FIG. 4 , the device mainly includes an event generating unit 00 and an event sending unit 10 .

事件生成单元00负责生成符合测试状态的触摸事件并组合成触摸动作的触摸事件序列。The event generation unit 00 is responsible for generating touch events conforming to the test state and combining them into a touch event sequence of touch actions.

事件发送单元10负责将触摸事件序列发送给被测试系统的事件转发对象,由事件转发对象对序列中的触摸事件进行转发。The event sending unit 10 is responsible for sending the touch event sequence to the event forwarding object of the system under test, and the event forwarding object forwards the touch events in the sequence.

本发明提供的装置可以被用于诸如iSO系统、Android系统等被测试系统,具体地,若被测试系统为iSO系统,则触摸事件为UIEvent,事件转发对象为UIApplication,UIApplication将UIEvent序列中的UIEvent分发给目标视图。若被测试系统为Android系统,则触摸事件为MotionEvent,事件转发对象为Instrumentation,Instrumentation将MotionEvent序列中的MotionEvent转发给Android系统,以供Android系统系统广播给监听的Application。在本实施例的后续描述中仅以iSO系统为例进行描述。The device provided by the present invention can be used in tested systems such as ISO system, Android system, etc. Specifically, if the tested system is an ISO system, the touch event is UIEvent, the event forwarding object is UIApplication, and UIApplication converts the UIEvent in the UIEvent sequence Distributed to the target view. If the system under test is an Android system, the touch event is a MotionEvent, and the event forwarding object is an Instrumentation. The Instrumentation forwards the MotionEvent in the MotionEvent sequence to the Android system for the Android system to broadcast to the listening Application. In the subsequent description of this embodiment, only the iSO system is used as an example for description.

通常在进行自动化测试时,是基于case进行的,这种情况下事件生成单元00可以具体包括:信息获取子单元01、轨迹计算子单元02和事件插入子单元03。Usually, automated testing is performed on a case-by-case basis. In this case, the event generation unit 00 may specifically include: an information acquisition subunit 01 , a trajectory calculation subunit 02 , and an event insertion subunit 03 .

在case中通常会包含诸如被测试对象、测试环境等信息,由于本发明实施例中的测试是Monkey测试,因此case中还会包含触摸动作信息。首先信息获取子单元01从case中获取触摸动作信息。鉴于触摸动作可能会包含多种类型,例如单击、滑动、多点触摸等等,但对于事件类型而言,主要有两个维度的划分,第一个维度是点击次数,即单击、双击、多击等,第二个维度是触摸点数量,即是单点、两点、多点等。在此每一种类型的触摸动作都可以采用多元参数组进行描述,具体地,多元参数组可以包括:起始点和结束点的位置、速度、加速度、持续时间和点击次数,具体例子不再描述,参见实施例一。The case usually contains information such as the object to be tested and the test environment. Since the test in the embodiment of the present invention is a Monkey test, the case also contains touch action information. First, the information acquisition subunit 01 acquires touch action information from the case. In view of the fact that touch actions may include multiple types, such as click, slide, multi-touch, etc., but for event types, there are mainly two dimensions. The first dimension is the number of clicks, that is, click, double-click , multi-click, etc., the second dimension is the number of touch points, that is, single point, two points, multi-point, etc. Here, each type of touch action can be described using a multivariate parameter group. Specifically, the multivariate parameter group can include: the position, speed, acceleration, duration, and number of clicks of the start point and end point. The specific examples will not be described here. , see Embodiment 1.

然后轨迹计算子单元02根据触摸动作信息计算触摸轨迹,在计算触摸轨迹时,采用的是传统的数学方法,即

Figure BDA00003309449900081
其中,Y为动作结束点的位置,X为动作起始点的位置,
Figure BDA00003309449900082
为速度向量,
Figure BDA00003309449900083
为加速度向量,t为时间。Then the trajectory calculation subunit 02 calculates the touch trajectory according to the touch action information. When calculating the touch trajectory, it adopts a traditional mathematical method, that is,
Figure BDA00003309449900081
Among them, Y is the position of the end point of the action, X is the position of the starting point of the action,
Figure BDA00003309449900082
is the velocity vector,
Figure BDA00003309449900083
is the acceleration vector, and t is the time.

最后事件插入子单元03按照触摸动作方向,每隔预设时间间隔在触摸轨中对应位置插入与该位置的触摸动作类型对应的UIEvent,得到UIEvent序列。在插入UIEvent时,主要需要三个因素,其一是插入点位置,其二是事件类型,其三是动作状态。由于插入UIEvent是按照预设时间间隔插入的,因此可以确定出插入的时间点在触摸轨迹中的位置(即代入上述触摸轨迹的公式)。事件类型上面已经描述过主要体现在两个维度:点击次数和触摸点数量,点击次数可以从case中多元参数组中直接获取,触摸点数量对应case中多元参数组的数量。动作状态主要包括三种:按下状态、移动状态和弹起状态。在插入UIEvent时在起始点位置的动作状态是按下状态,结束点位置的动作状态是弹起状态,触摸轨迹中起始点和结束点之间的各插入点的动作状态是移动状态。Finally, the event insertion subunit 03 inserts a UIEvent corresponding to the touch action type at the corresponding position in the touch track every preset time interval according to the touch action direction, and obtains a UIEvent sequence. When inserting a UIEvent, three factors are mainly required, one is the insertion point position, the other is the event type, and the third is the action state. Since the insertion of the UIEvent is inserted at a preset time interval, the position of the inserted time point in the touch track can be determined (that is, substituted into the above formula of the touch track). The event type has been described above and is mainly reflected in two dimensions: the number of clicks and the number of touch points. The number of clicks can be directly obtained from the multivariate parameter group in the case, and the number of touch points corresponds to the number of multivariate parameter groups in the case. Action states mainly include three types: pressed state, moving state and popping state. When inserting a UIEvent, the action state at the starting point is the pressed state, the action state at the end point is the pop-up state, and the action state of each insertion point between the starting point and the end point in the touch track is the moving state.

若触摸动作类型为N点触摸,则触摸动作信息采用N个多元参数组进行描述,轨迹计算子单元02得到N条触摸轨迹,事件插入子单元03在插入UIEvent时,每个UIEvent插入的位置存在N个坐标点,N为正整数。If the touch action type is N-point touch, the touch action information is described by N multivariate parameter groups, the trajectory calculation subunit 02 obtains N touch trajectories, and when the event insertion subunit 03 inserts a UIEvent, the inserted position of each UIEvent exists N coordinate points, N is a positive integer.

在此不再列举具体的实例,可以参见上述方法实施例一中的描述。No specific examples are listed here, and reference may be made to the description in Embodiment 1 of the above-mentioned method.

在本发明所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation.

另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware, or in the form of hardware plus software functional units.

上述以软件功能单元的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本发明各个实施例所述方法的部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The above-mentioned integrated units implemented in the form of software functional units may be stored in a computer-readable storage medium. The above-mentioned software functional units are stored in a storage medium, including several instructions to enable a computer device (which may be a personal computer, server, or network device, etc.) or a processor (processor) to execute the methods described in various embodiments of the present invention. partial steps. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes. .

以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明保护的范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included in the present invention. within the scope of protection.

Claims (12)

  1. One kind based on the action touch simulation automated testing method, it is characterized in that the method comprises:
    S1, generation meet the touch event of test mode and are combined into the touch event sequence of touch action;
    S2, the touch event sequence is sent to the event forwarding object of tested system, by the event forwarding object touch event in the sequence is transmitted.
  2. 2. method according to claim 1 is characterized in that, described step S1 specifically comprises:
    S11, from test case, obtain touch action information;
    The touch action information calculations touch track that S12, basis are obtained;
    S13, according to the touch action direction, correspondence position in touch track inserts the touch event corresponding with the touch action type of this position every the Preset Time interval, obtains the touch event sequence.
  3. 3. method according to claim 2 is characterized in that, described touch action information adopts the multiple parameters group to be described, and described multiple parameters group comprises: the position of starting point and end point, speed, acceleration, duration and number of clicks.
  4. 4. method according to claim 3, it is characterized in that, if being the N point, described touch action type touches, then described touch action information adopts N multiple parameters group to be described, in described step S12, obtain N bar touch track, there be N coordinate points in the position that each touch event inserts in described step S13, and N is positive integer.
  5. 5. method according to claim 2, it is characterized in that, when inserting the touch event corresponding with the touch action type of this position, insert the touch event of down state in initial point position, insert the touch event of the state of upspringing in the end point position, the touch event of mobile status is inserted in each position between starting point and end point.
  6. 6. according to claim 1 to the described method of 5 arbitrary claims, it is characterized in that, if described tested system is the iSO system, then described touch event is UIEvent, described event forwarding object is UIApplication, and described UIApplication is distributed to target view with the UIEvent in the UIEvent sequence;
    If described tested system is the Android system, then described touch event is MotionEvent, described event forwarding object is Instrumentation, described Instrumentation is transmitted to the Android system with the MotionEvent in the MotionEvent sequence, is broadcast to the Application of monitoring for the Android service system.
  7. One kind based on the action touch simulation automatic test device, it is characterized in that this device comprises:
    The event generation unit is used for generating the touch event sequence that meets the touch event of test mode and be combined into touch action;
    The event transmitting element for the event forwarding object that described touch event sequence is sent to tested system, is transmitted the touch event in the sequence by the event forwarding object.
  8. 8. device according to claim 7 is characterized in that, described event generation unit specifically comprises:
    The acquisition of information subelement is used for obtaining touch action information from test case;
    The track computation subunit is used for according to described touch action information calculations touch track;
    Event intron unit is used for according to the touch action direction, and correspondence position in touch track inserts the touch event corresponding with the touch action type of this position every the Preset Time interval, obtains the touch event sequence.
  9. 9. device according to claim 8 is characterized in that, described touch action information adopts the multiple parameters group to be described, and described multiple parameters group comprises: the position of starting point and end point, speed, acceleration, duration and number of clicks.
  10. 10. device according to claim 9, it is characterized in that, if being the N point, described touch action type touches, then described touch action information adopts N multiple parameters group to be described, described track computation subunit obtains N bar touch track, described event intron unit is when inserting touch event, and there be N coordinate points in the position that each touch event inserts, and N is positive integer.
  11. 11. device according to claim 8, it is characterized in that, described event intron unit is when inserting the touch event corresponding with the touch action type of this position, insert the touch event of down state in initial point position, insert the touch event of the state of upspringing in the end point position, the touch event of mobile status is inserted in each position between starting point and end point.
  12. 12. according to claim 7 to the described device of 11 arbitrary claims, it is characterized in that, if described tested system is the iSO system, then described touch event is UIEvent, described event forwarding object is UIApplication, and described UIApplication is distributed to target view with the UIEvent in the UIEvent sequence;
    If described tested system is the Android system, then described touch event is MotionEvent, described event forwarding object is Instrumentation, described Instrumentation is transmitted to the Android system with the MotionEvent in the MotionEvent sequence, is broadcast to the Application of monitoring for the Android service system.
CN201310222513.2A 2013-06-06 2013-06-06 A kind of automated testing method based on action touch simulation and device Expired - Fee Related CN103353858B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310222513.2A CN103353858B (en) 2013-06-06 2013-06-06 A kind of automated testing method based on action touch simulation and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310222513.2A CN103353858B (en) 2013-06-06 2013-06-06 A kind of automated testing method based on action touch simulation and device

Publications (2)

Publication Number Publication Date
CN103353858A true CN103353858A (en) 2013-10-16
CN103353858B CN103353858B (en) 2016-03-16

Family

ID=49310232

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310222513.2A Expired - Fee Related CN103353858B (en) 2013-06-06 2013-06-06 A kind of automated testing method based on action touch simulation and device

Country Status (1)

Country Link
CN (1) CN103353858B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104090836A (en) * 2014-02-17 2014-10-08 腾讯科技(深圳)有限公司 Response test method and device of application program for system broadcast
CN104765680A (en) * 2015-03-13 2015-07-08 安一恒通(北京)科技有限公司 Method and device for automatically testing software
CN105279052A (en) * 2014-07-04 2016-01-27 福建天晴数码有限公司 IOS stability test method and apparatus
CN105975367A (en) * 2016-04-29 2016-09-28 腾讯科技(深圳)有限公司 Mobile equipment test method and device
CN106528412A (en) * 2016-10-27 2017-03-22 南京大学 Test framework for putting of related gesture of android application
CN111142470A (en) * 2019-12-31 2020-05-12 连云港新东方国际货柜码头有限公司 Automatic analog control system for wharf equipment and fault detection method
CN112817790A (en) * 2021-03-02 2021-05-18 腾讯音乐娱乐科技(深圳)有限公司 Method for simulating user behavior
CN119690842A (en) * 2024-12-18 2025-03-25 中国航空工业集团公司西安飞机设计研究所 Display control processor test method and system for simulating touch screen operation

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080250051A1 (en) * 2007-04-05 2008-10-09 Accenture Global Services Gmbh Automatic test generation for reference testing
CN102073590A (en) * 2011-01-11 2011-05-25 百度在线网络技术(北京)有限公司 Event simulation-based user interface test method and device
CN102141960A (en) * 2011-03-18 2011-08-03 广东欧珀移动通信有限公司 Automatic test method based on Android
CN102541734A (en) * 2011-12-27 2012-07-04 Tcl集团股份有限公司 Method and device for testing pressure of equipment based on android platform
CN103049371A (en) * 2012-11-07 2013-04-17 青岛海信传媒网络技术有限公司 Testing method and testing device of Android application programs
US20130138381A1 (en) * 2011-11-25 2013-05-30 Askey Computer Corp. Handheld electronic device testing method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080250051A1 (en) * 2007-04-05 2008-10-09 Accenture Global Services Gmbh Automatic test generation for reference testing
CN102073590A (en) * 2011-01-11 2011-05-25 百度在线网络技术(北京)有限公司 Event simulation-based user interface test method and device
CN102141960A (en) * 2011-03-18 2011-08-03 广东欧珀移动通信有限公司 Automatic test method based on Android
US20130138381A1 (en) * 2011-11-25 2013-05-30 Askey Computer Corp. Handheld electronic device testing method
CN102541734A (en) * 2011-12-27 2012-07-04 Tcl集团股份有限公司 Method and device for testing pressure of equipment based on android platform
CN103049371A (en) * 2012-11-07 2013-04-17 青岛海信传媒网络技术有限公司 Testing method and testing device of Android application programs

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
刘冠琼: ""基于OPhoneOS平台的MTBF测试研究与应用"", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
熊斌: "《iOS开发从入门到精通》", 31 January 2013, 北京希望电子出版社 *

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104090836A (en) * 2014-02-17 2014-10-08 腾讯科技(深圳)有限公司 Response test method and device of application program for system broadcast
CN104090836B (en) * 2014-02-17 2016-04-13 腾讯科技(深圳)有限公司 Application program is to the response test method of system broadcasts and device
CN105279052A (en) * 2014-07-04 2016-01-27 福建天晴数码有限公司 IOS stability test method and apparatus
CN104765680A (en) * 2015-03-13 2015-07-08 安一恒通(北京)科技有限公司 Method and device for automatically testing software
CN104765680B (en) * 2015-03-13 2017-11-03 安一恒通(北京)科技有限公司 Method and device for automatically testing software
CN105975367A (en) * 2016-04-29 2016-09-28 腾讯科技(深圳)有限公司 Mobile equipment test method and device
CN106528412A (en) * 2016-10-27 2017-03-22 南京大学 Test framework for putting of related gesture of android application
CN106528412B (en) * 2016-10-27 2019-01-08 南京大学 A kind of related gesture dispensing test frame of Android application
CN111142470A (en) * 2019-12-31 2020-05-12 连云港新东方国际货柜码头有限公司 Automatic analog control system for wharf equipment and fault detection method
CN112817790A (en) * 2021-03-02 2021-05-18 腾讯音乐娱乐科技(深圳)有限公司 Method for simulating user behavior
CN119690842A (en) * 2024-12-18 2025-03-25 中国航空工业集团公司西安飞机设计研究所 Display control processor test method and system for simulating touch screen operation

Also Published As

Publication number Publication date
CN103353858B (en) 2016-03-16

Similar Documents

Publication Publication Date Title
CN103353858B (en) A kind of automated testing method based on action touch simulation and device
CN106020595B (en) Message reply method and device
Mikucionis et al. T-uppaal: Online model-based testing of real-time systems
CN109739712B (en) FPGA accelerator card transmission performance test method, device, equipment and medium
CN111901155B (en) Internet of things debugging method, device and system and storage medium
CN103984619A (en) Performance monitoring method of network storage system
CN104317390A (en) Method and system for replacing mouse operation by multiple gestures based on virtual machine of mobile terminal
CN111934908A (en) Internet of things simulation method, device and system and storage medium
CN104699408A (en) Touch screen operation method, device and touch device
CN108600145B (en) Method and device for determining DDoS attack equipment
CN109034867A (en) click traffic detection method, device and storage medium
WO2021093367A1 (en) Model training and risk identification method, apparatus and device
Du et al. Hawkeye: Adaptive straggler identification on heterogeneous spark cluster with reinforcement learning
WO2016172985A1 (en) Commission allocation method and system
CN109508216B (en) Screen capture processing method and device, storage medium and user terminal
CN114327201B (en) Cloud mobile phone control method and device and computer equipment
CN107018039B (en) Method and device for testing performance bottleneck of server cluster
CN104142885B (en) A kind of method and apparatus for carrying out abnormality test to tested program
CN110119602B (en) Man-machine recognition method, device, server, client and storage medium
US20160112289A1 (en) Quality estimation method, quality estimation apparatus, and recording medium
CN108415822B (en) Random test method and device
CN108073502B (en) A test method and system thereof
CN109756350A (en) A method and device for pushing messages in a group conversation
CN105099764A (en) Log processing method and log processing device
Brown et al. Tracing data movements within MPI collectives

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20160316

CF01 Termination of patent right due to non-payment of annual fee