Chapter: The basic of automation--Baidu Cafe Principle Preliminary (eighth lecture)
Golden Sun Test Website:
Http://www.goldensunshine.cc/forum.php?mod=viewthread&tid=20&extra=page%3D2
Main content and notes:
First, Cafe principle
Cafe is an automated testing framework that solves problems: cross-process testing, rapid in-depth testing
Official website:http://baiduqa.github.io/Cafe/
Cafe provides the following benefits:
* You can develop test cases across processes by operating them via Cafe.
* You can get & set system state without changed tested application, such as open or close WiFi. --Using a android4.2 system vulnerability, more than 4.2 of the version to fill the vulnerability, the function should be invalidated
* You can get & set fields of tested objects even invoke functions by calling API.
* The framework can handle system running log for some non-ui check point.
* You can do application UI Depth-first travel automated by invoking only one API.
* Can record hand-operations to café code and replay it even at another phone or others version Android.
Second, the core technology
1. Cross-process--aidl analysis
Aidl (Android Interface definition language--Android Interface Definition language)
Aidl is similar to other interface definition languages, which allows you to define programming interfaces that use interprocess communication (interprocess communication, or IPC) to enable communication between client and server. There is no sharing of memory between processes in the Android system, so you need to define mechanisms for data communication between different processes.
Steps to establish a AIDL service (from Baidu, you have to try it yourself, the content does not understand) ——————
Establishing a AIDL service is more complex than building a common service, as follows: (1) Create a file with the extension aidl in the Java package directory of the Eclipse Android project. The syntax of the file is similar to Java code, but slightly different. (2) If the contents of the Aidl file are correct, ADT will automatically generate a Java interface file (*.java). (3) Set up a service class (subclass of Services). (4) Implement the Java interface generated by the Aidl file. (5) Configure the Aidl service in the Androidmanifest.xml file, especially note that the attribute value Android:name in the,<action> tag is the ID of the client to reference the service, which is the parameter value of the intent class. &NBSP;2:-Setting the system time, System Properties-restarting ADB, restarting the phone using the Android Signature Checker Vulnerability (Zipfile.java) first explain what is an Android signature check vulnerability? (see: http://www.isucc.me/390.html) is actually the ZIP compression package (apk is originally a ZIP compression package) allows the existence of multiple files with the same name in the unified path caused by the characteristics, and then the program check the signature, will check the last, but the decompression program, Android system loading the file is also the front of the one (as long as the new file in the original file stream before the location can be), the damage is very large, so the system after Android 4.2 fixed the vulnerability - Modify the code logic of settings.apk without platform signature: Android 1.6-4.2 has this vulnerability, can be used as a test to extract the right-zip allow files with the same name exists, the first is the modified Class.dex, the second is the original class.dex-using the installation signature check , the file with the same name will only verify the last side of the other technology: schema usage-can not start instrument, through intent can invoke the interface in the cafe.apk example does not understand, and so I try to come back to add -get and set method: Get System Properties, Use of the Java Reflection mechanism (do not understand, check!!!) )-Traversal optimization algorithm: Local.traveler () Three, demo demo this to run, note that: signature to the same, otherwise it can not be used, this is consistent with robotium, that is, you want to test the program and TESTAPK signature is consistent, And then this testapk can run on the program under test. IV. Source Code Analysis 1, com.baidu.cafe.remote--iremotearms.aidl (all operations related to Android are defined to get the operation) 2, com.baidu.cafe.local.traveler-- Apptraveler.java (improved monkey traversal algorithm, to avoid the monkey inside the Dead loop) 3, recorder (you can try it yourself, with their own program to try, haha!!) )-hook-based recording principle (there are hooks on windows, and now many programs use hooks to write what drives, causing no unloading at all)-ui traverse Test 4,Com.baidu.cafe.local--locallib.java(Searchtextfromparent, locate the parent control, and then you can find the nested child controls, Using the principle of reflection: The specific program is com.baidu.cafe.remote in the Reflecthelper.java) Note: Dynamically generated view is also can GetView 5, Generate reports (Android-junit-report-x.x.x.jar)--This I can use in my Robotium program, generate report AH 6, because the Robotium did a package, you can directly in the inside with robotium things, Solo, Solo. Five, the advantages and disadvantages of Cafe advantages: Automatic test case interception on Failure logcat log automatically generated JUnit report XML gets the application current frame rate (such as "League of Legends" program, in the same situation, the higher the frame rate, the better the program performance, The need for similar programs or videos to get the current TCP send and receive traffic (news, video, etc., especially if 3G traffic is used) execute the shell with root privileges (on the root system?). Root can be right) disadvantage: Android 4.2 or more system anti-signature problems (the latest version is not fixed?) The script writer will Junit+java (Java is learning, JUnit actually used a bit, the system knowledge or need to check) not to encapsulate the stable version of the Uiautomator (so still need to look at the Uiautomator framework, Familiarity and understanding of Uiautomator and Robotium framework) 1, official website: www.goldensunshine.cc
2, Baidu Search: Golden Sunshine Test, find the golden Sun study Materials and official website, video.
3, the official Sina Weibo: Golden Sun Woody
4. Official qq:212260449
6, the official YY education channel: 74894998
7, the official CSDN technical information: http://blog.csdn.net/haorenmin2008
"Golden Sun Test" Android Automation-learning history: Baidu Cafe principle