11 | How to test based on Unity3D game engine

11 | How to test based on Unity3D game engine

Since the game's interface is rendered by the game engine, the game interface is not native to control information system, so for the game, we need access Poco-SDK in order to obtain information to control the game interface. Below Unity development of hand travel example, describes how to connect the Android and iOS platforms.



11.1 Android platform


  1. From Poco SDK Repo will Unity3D this folder clone down. 

  2. The clone down the Unity3D placed in a folder of your Unity project Assets / Scripts folder. 

  3. The next Assets / Scripts / Unity3D directory UI system is not used in the name of the folder is deleted. Example: If your project is using the UI system is UGUI, please FairyGUI and NGUI two folders removed, leaving UGUI folder.

  4. Open your project in Unity3D, and the Unity3D / PocoManager.cs as a script component to your GameObject in, usually your main camera. Example: Click demo Main Camera Under this scenario, the inspector will appear on the right interface, click among the inspector interface Add Component. In the dialog box, enter Poco, Poco Manager appears select this option. Component appears as shown in inspector interface after completion.

  5. Click on the upper left corner File-> Build Settings, Andrews generate a suitable package, and install it on your phone. 

  6. Start AirtestIDE, as described above, will AirtestIDE link with your phone, and start the corresponding game. 

  7. Unity mode selection in the lower left corner of the window Poco aid, you can see the tree structure of the current UI interface:

  8. After selecting the Unity mode, Airtest IDE automatically inserts Poco initialization code: 


    scripting later, the elements can be on the game interface operation using API Poco provided. 

    Here is a simple test case. You can from here to download this simple Unity3D game. After the installation is complete, open the game click Start and then click drag drop interface will appear as shown below. The star drag on each of the center of the screen shell, and the resulting 20 minutes; five star sequentially if dragged onto the shell, it would receive 100 points. The following script is in turn drag test whether five stars will get 100 points score.

from airtest.core.api import *

auto_setup(__file__)

from poco.drivers.unity3d import UnityPoco
poco = UnityPoco()

poco('btn_start').click()
time.sleep(1.5)


poco('drag_and_drop').click() shell = poco('shell').focus('center') for star in poco('plays').offspring('star'): star.drag_to(shell) time.sleep(1) assert poco('scoreVal').get_text() == "100", "score correct." poco('btn_back', type='Button').click() 

Click the Run Script button, you will get the results shown below.



11.2 iOS platform


  1. Similarly, access to complete engine SDK, then Airtest IDE connector iOS phone; 

  2. The difference is that with Android, iOS connection Unity Poco need to launch two proxy, 8100 port for connecting iOS phone, 5001 port for connecting Poco-SDK RPC port.

iproxy 8100 8100
iproxy 5001 5001

iproxy here is equivalent to the ADB forward. 

  1. After connecting iOS phone, select Poco auxiliary windows in Unity mode, you can see the tree structure of the current UI interface:

    1. After the API can be provided by Poco, for games on iOS writing automated test scripts.

Guess you like

Origin www.cnblogs.com/ShineLeem/p/11326222.html