"Golden Sun Test" based on the core technology of control---Android self-initiated series (2)---May 2013

Source: Internet
Author: User


The first share of the next Android self-initiative some of the profiles and some of their own proactive framework status and technology can solve what kind of problems.

This lesson went deep into the Android world. Swim, soar. Gain insight into your own proactive testing core technology.

have been engaged in programming development of the classmate heard instrumentation this thing must be no stranger. The Android architecture is divided into four layers (the following is the hardware-driven abstraction layer. is not the scope of the content discussed by the author), the above point is the protocol stack. It's not the core of the discussion, it's all about C language. Until the third layer of the framework layer (framework).

There are two segments:

A. Android's improved virtual machine Dalvik and runtime (Java Execution time environment). This I would like to explain a little bit (understand the people please skip), Google the Java Virtual machine (PC above the virtual machine) to improve, memory optimization, such as the cancellation of remote login and other functions. Evolve to become your own virtual machine. The advantage is that each individual process is encapsulated in a virtual machine, and the process crashes without affecting the system process. Ensures the stability of the Android system.

B. Runtime is an interface to external programs (some places are called protocols) to introduce a very rich library of C + + libraries, 3D and 2D animations, media libraries, font libraries, sqilite and other excellent features into the upper layer.

When an Android system starts, loading the completion daemon and some drivers and so on will call the Init method: The android init process binds sigchld to the signal processing function sigchld_handler (). and creates a socket to receive the socket message sent in the function. The Sigchld_handler () function is simply a simple dispatch of a message to the socket.

The students who see the dizziness please ignore them.

You just have to remember that the frame layer on the C side is loaded and is going to invoke a parent class on the root of the Java layer. Is zygote. The English name is hatching, the fertilized egg, the effect is the birth child. All processes are produced by it, and together with the system services to produce Activitymanagerservice, windowsmanagerservice and Dialogservicesmanager, etc., The zygote controls them and thread binder objects to communicate, creating four Android components (activity, broadcast, services, Contentprovide) together. The zygote creates the process (thread) object at the same time. We finally see the instrumentation behind the scenes.

A great circle of Gestapo eventually appeared. It can be generated before the initialization of all components, all of which can monitor all component information, status, change, extinction, and, of course, before monitoring. It gets the context reference for these components, which controls multiple life cycles of the application. Send UI events to the application, and check program status during run time.

This is the self-initiative of the core technology-design mode of the listener mode.

In the operating system. The application component is the parent class of the control. Information is monitored and obtained by instrumentation. The script is then controlled by Instrumentationtestrunner to make a self-motivated test, you can execute the script in the ADB shell, or use the Eclipse+junit method to execute the script. are capable of.

Here's the instrumentation class. It can monitor the interaction of the application with the system. The instrumentation object is instantiated before all other components of the app are instantiated. The need to call the instrumentation class must inherit android.app.instrumentation talent to use it.

Because Android's core is not the app, it's activity.

This is very different from iOS Apple. Apple is the MVC model (view, controller and model) that delegate and sends the message mechanism, the specific Apple iOS self-motivated test document will be available after the 9th lecture. Although Android also has news, but the message of Android is usually pass the key value pair (Key-_value), in the Android inside called Bundle object. is a dictionary of generic type. Here by the way the rising star Winphone 8. Its mechanism is more bizarre, is a tombstone dormancy preservation mechanism (this Winphone self-initiative and unit test will be in the 15th after the detailed analysis). Because of it, winphone to achieve its best user experience, although multi-threaded, but only one can be activated at the same time, because of this, its single-core machine performance and efficiency far more than Android and Apple. So. The Microsoft level that did 30 years of operating system is really not covered. User experience and much more are superior to Apple and Android, although very few people use it.

Okay, cut the crap.

Instrumentation will go to Androidmanifest.xml for some component information, such as activity, service, etc. Of course, it will also contain the XML components and controls in the layout file layouts that are generated in the Gen directory with the IDs of the R.java collected and saved, these IDs are in the 0x 16 binary int. Can be said to be a control's identity card information. If you think the trouble, can use Hierarchyviewer to check, by the way, with this tool must root mobile phone, of course, I do not advocate a good user version of the phone randomly brush to root, here to buy the ordinary user mobile phone is the right to justify, Root is to open the Administrator Su permissions, let the end user has the highest authority to operate the phone, no matter what the pros and cons. The downside is that you give the app the right permissions at the same time: for example, other applications can access across processes (which in the Android world is a breach of Google's set of design rules), and Android developers know that the process is not able to easily access and establish communications. Unless you open the Aidl bound service interface or when you compile your phone, secretly make the app signature into a system-level signature.

Besides. In general user rights have done a lot of restrictions, greatly guarantee the stability and security of your machine. But if you want to root. A lot of stuff is out of control. The phenomenon is that your phone inexplicably restarts, crashes, no response. Or you do not mistakenly delete the practical module, such as the phone accidentally uninstall, you can only go to brush the machine again, so that the ordinary user or not casually brush machine, because Google does not restrict you to install the application, not like Apple has to escape the ability to install any application.

Of course, you have to use your own initiative to test the time also must be in manifest declaration. For example with

The first Red arrow with this band. Resultactivity in front of the namespace (Android called the package name), due to a package. Of course in the real test demo inside. We still want to create a new package name +test, test to complete the deletion is good;

The second uses-library, because of the existing control-based instrumentation and perhaps to introduce the Robtium framework, is encapsulated instrumentation. Can not be tested alone, must cooperate with JUNIT4 (Junit3 has been discarded. Although can use, but the advanced function and annotation need junit4, this is a meta data. That is to explain the data, unclear students can search the Internet, not the focus of this.

(This specific use will be described later in the 5th article)) The framework is tested together, so this statement is meant to import the JUnit package. Let the results be executed inside the JUnit framework.

The third Red Arrow is the Gestapo, with it we can call at any time and give you see the layout File menu to operate, do not need to open permissions, of course, you have to unify the signature, because the test source we have, this step omitted. (The 7th chapter will teach you how to use the source code), you can click, Assert, back and so on are able.

At this point, one of the----based controls is the essence of your own proactive core technology. In the future, we will not see how many kinds of Android self-active tools on the market boast: the ability to remotely control, the ability to control the mouse mobile phone, can actively record the script.

Yes, but they are not capable of high strength. In fact all are called the Google Package instrumentation. So it's Google. It is not the people who do their own active tools, and the students who do not believe can follow my lectures. I also casually integrated a so-called framework to carry out their own active script, do the test work of the project, then please everyone to shoot bricks.

^_^ (in addition to the second self-active core technology---ORC and element recognition, will be revealed after the 7th chapter)

This technology sharing is here, and the third is to share their own initiative to test the originator of the monkey principle and flexible use of some of its high-level rules, flexible implementation of it can be a very big help to test.

Golden Sun Self-active data + video:
1. Official website: http://www.goldensunshine.cc/
2. Follow me Sina Weibo: Golden Sun Woody
3. Baidu Search: Gold Sunshine Test, find golden Sunshine Teacher video
4. Many other latest videos in QQ Group: 212260449 Update

5. Information CSDN Blog: http://blog.csdn.net/haorenmin2008

6. Golden Sun Public account: Search Gold Sunshine own initiative

"Golden Sun Test" based on the core technology of control---Android self-initiated series (2)---May 2013

Related Article

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.