Lao Li recommended: the 6th Chapter 3, "Monkeyrunner Source Analysis" Monkey principle-Event Source-Event Source Overview-command translation class

Source: Internet
Author: User

Each string command from the network needs to be parsed, but some are executed directly in the parsing process, while others need to create the corresponding event class instance after parsing and add it to the command queue for execution. This part of the job is to command the translation class. So we're going to go down here. What is the Monkeycommand class in the Monkeysourcenetwork category:

Figure 6-3-1 Monkeycommand Genealogy

The Monkeycommand in the middle of the diagram is an interface that defines the Translatecommand method, which is a string command, a list of parameters, and a command queue that all implementation classes must implement to parse the command string:

    • If the command string needs to establish a corresponding monkeyevent instance, the command string is translated into the corresponding Monkeyevent instance and added to the incoming command queue
    • If the command string does not need to establish the corresponding Monkeyevent instance, then parse the command string directly and then return

command string format

command Translation class

MR support

comments

Touch down X Y

Touchcommand

Is

x for x -coordinate,y for y- coordinate

Touch Up X Y

Touchcommand

Is

Ditto

Touch Move x Y

Touchcommand

Is

Ditto

Tap x Y

Tapcommand

Is

Ditto

Press Name

Presscommand

Is

Name represents the key name, such as "menu", "HOME", "SEARCH", etc.

Key down Name

Keycommand

Is

Ditto

Key up Name

Keycommand

Is

Ditto

GetVar Name

Getvarcommand

Is

Name represents the property name

Listvar

Listviewscommand

Is

Type line

Typecommand

Is

Line represents input string

Wake

Wakecommand

Is

ListViews

Listviewscommand

Is

QueryView

Queryviewcommand

Is

Getrootview

Getrootviewcommand

Is

Getviewwithtext

Getviewswithtextcommand

Is

Done

N/A

Is

After the test is complete,Monkey will stop the Socket monitoring after receiving the command .

Quit

N/A

Is

Test request exits,Monkey received will not stop the Socket monitoring,

Flip Open

Monkeyflipevent

Whether

Monkeyrunner does not support sending these two commands

Flip Close

Monkeyflipevent

Whether

Trackball DX dy

Whether

Deferredreturn

Deferreturncommand

Whether

This command is more special, and the thing to do is to wait for one command to complete and then execute another command. However , there is no support in the Monkeyrunner framework.

Note : MR represents monkeyrunner

Table 6-3-1 command string and corresponding command translation class reference table

All the classes in Monkeycommand are actually internal classes, such as command translation classes related to network commands, or subclasses of Monkeysourcenetwork, or subclasses of Monkeysourcenetworkvars, Otherwise it is Monkeysourcenetworkviews's subclass:

Figure 6-3-2 Command translation class as the inner class of the event source

Once the event source gets to the string command it is convenient to call the internal command translation class through Command_map to translate the command, so we can also think that the event source relies on the corresponding command translation class to do things:

Figure 6-3-3 Event source Dependent command translation class

In the next section we go through an example to see how the event translation class translates the string commands sent by Monkeyrunner and translates them into event instances.

Lao Li recommended: the 6th Chapter 3, "Monkeyrunner Source Analysis" Monkey principle-Event Source-Event Source Overview-command translation class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.