In this chapter we focus on the event source that deals with the commands of the network Monkeysourcenetwork to illustrate how learning Monkey handles Monkeyrunner commands. Following is a summary of the process of Monkeyrunner from starting monkey to how to handle the completion of a command:
- monkeyrunner send Shell command "Monkey--port 12345" via ADB to start monkey
- monkey start running into Runmonkeycycles method to loop get and execute event
- runmonkeycycles method first determines that the--port event source needs to be initialized to handle the network command
based on the start command line parameter "Monkeysourcenetwork".
- after initializing the event source, Runmonkeycycles invokes the getnextevent of the event source to try to get an event to execute the
- Event source when trying to get an event, go to the command queue to see if there are any events, and then return directly to the Runmonkeycycles to perform the event injection, and continue down without saying:
-
- < Span class= "S1" to parse the command string's commands, and then refer to Command_map to get the command for the command translation object
- Call the Translatecommand method of the command translation object to establish the corresponding event object according to the command and command parameters
-
- Enter Runmonkeycycles's next loop to get event execution
Finally, take a look at the flowchart below for a description of the entire command acquisition, translation, build event, and injection event flow:
Figure 6-8-1 Network Event processing flowchart
Note: More articles please pay attention to the public number: Techgogogo or personal blog http://techgogogo.com. Of course, you are also very welcome to pick up directly (ZHUBAITIAN1). This article by Heaven Zhuhai Branch Rudder original. Reproduced please consciously, whether the complaint rights to look at the mood.
6th Chapter 8 "Monkeyrunner Source code Analysis" Monkey principle-Event Source-Event Source Overview-Summary