• No se han encontrado resultados

de Drenaje Sostenible en BarcelonaEvolución de los

The Log parser module is in charge of extracting all the information related to the operations performed on the application. It is launched after the execution of the test cases is finished on the Android Virtual Device.

The first operation performed by the Logcat Parser is an access to the full log of the Android app through the Android Debug Bridge, using the command adb logcat -dto locally save the full log. Then, the full log is filtered for rows containing the

"TOGGLELOG" keyword.

Hence, for each line in the filtered logcat, a ToggleInteraction object is created. As shown in figure 9.12, the class is characterized by the following attributes:

packagename : A string with the packagename of the tested application. It is used for searching ids or resources in the dump .xml files.

search_type : A string indicating the type of search that is performed to identify the interacted element in the visual hierarchy.

search_keyword : A string indicating the keyword used to identify the interacted element in the visual hierarchy, according to the type of attribute searched.

9.2 Layout-based to Visual Translator Architecture 137

Fig. 9.12 TOGGLE - Log Parser: ToggleInteraction Class

time : A string containing the timestamp of the moment at which the interaction has been performed.

interaction_type : A string indicating the type of interaction performed on the view.

interaction_args : A string containing one or multiple arguments to describe the interaction that is performed on the view.

screen_capture : A File pointer to the Bitmap capture of the full screen, taken right before the interaction is performed.

dump : A File pointer to the .xml file containing the full dump of the current activity, taken right before the interaction is performed.

left, top, right, bottom : Coordinates for identifying the corners of the rectangle occupied by the view on the screen.

cropped_image : A bitmap of the actual appearance of the view that has been interacted, extracted from the full screen capture.

Most of the attributes of the ToggleInteraction object are populated by its con- structor, by passing the string elements extracted from each filtered Logcat line. The

private method extractBoundsFromDump() of the ToggleInteraction class allows obtaining the exact coordinates inside the screen of the interacted view. They are obtained through recursive inspection of the .xml dump file, searching the innermost attribute search_type with value search_keyword and returning the value of the node-boundsattribute.

Once the boundaries are obtained, the manageScreenshot() method cuts the rectangle with the given boundaries from the full screen capture of the current activity and saves it in an image which is named timestamp_cropped.png.

Several interactions do not require movements of the mouse pointer or click operations, and hence do not require a screenshot to be managed, cut and resized. For instance, a TypeTextIntoFocusedView interaction will be translated in just a set of key presses, without any click on the app GUI. In those cases, the manageScreenshot() method is not called and a screen capture is not created for the specific interaction.

The output of the Logcat Parser module is a sequence of interaction types, coupled with exact screen captures (when required) of the views that have to be found by the Visual Testing Tool for the execution of the test case, and with the required arguments by the specific interaction types.

9.2.4

3

rd

generation script creator

The 3rdGenerationScriptCreator module is dependent on the Visual testing tool towards which the test case is translated. It receives as input a sequence of ToggleIn- teractions, and translates each operation to the destination syntax, using the set of commands that are available with the destination tool.

For instance, the click operation on a given screen capture can be translated to the following line if the EyeAutomate Visual testing tool is used:

C l i c k " i m a g e _ f o l d e r \ 1 5 4 0 3 9 3 2 6 4 9 3 2 _ c r o p p e d . png "

or, instead, to the following line if the Sikuli Visual testing tool is used:

c l i c k ( " 1 5 4 0 3 9 3 2 5 5 0 9 7 _ c r o p p e d . png " ) .

In general, however, a 1-to-1 mapping between 2nd-generation layout-based in- teractions and 3rd-generation image recognition-based is not possible. Espresso, like all 2nd-generation tools, uses platform-specific information to identify the widgets

9.2 Layout-based to Visual Translator Architecture 139

Table 9.6 Translation alternatives

Name Meaning

EA EyeStudio Text Script

S SikuliX Ide Python Script

EAJ EyeAutomate Java Method

SJ SikuliX Java Method

CES Combined Java Method, EyeAutomate First

CEJ Combined Java Method, Sikuli First

on which to perform interactions, and several atomic operations may be included in a single Espresso interaction. Those interactions, hence, must be translated to a series of atomic mouse and keyboard operations when they have to be translated to a visual test script operated on an emulated device on a desktop pc.

Toggle supports translation to EyeAutomateì and Sikuli. The translated scripts are in the native formats of the two tools that can be run by the tools’ respective IDEs.

However, since both the tools also have Java APIs, the creation of Java code calling the respective APIs has also been considered.

Finally, the Java APIs allow translations of the 2nd generation scripts into com- binedtest cases that use both tools, such that if one tool’s image recognition fails, the script will try to perform the interaction, or a check, with the other. Two different combined, Java-based, test script types can thereby be obtained, with EyeAuto- mate interactions first (followed by Sikuli if EyeAutomate fails) and with Sikuli interactions first (followed by EyeAutomate if Sikuli fails).

Table 9.6 summarizes the six possible translations for 2nd generation test cases that are offered by the 3rd generation script creator, along with the acronyms that are used in the continuation of the manuscript.

Section C.2 of appendix C reports the translated commands into the destination EyeAutomate or Sikuli syntax (respectively, in the plain text and python format). In the table the parameters of the commands are indicated, with img being the screen capture attached to the log, and argN the n-th argument in the log line.

Fig. 9.13 TOGGLE: Architecture of the translator from Visual to Layout-based GUI testing tools (Proof of Concept)

9.3

Visual to Layout-based GUI test scripts transla-