Android function automated testing processing of off-keyboard pop-up

Source: Internet
Author: User

 

Automated Testing of the android function of robotium

When robotium is used for automated functional testing, some edittext and other virtual keyboard pop-up problems often lead to additional workload to handle the problem of the virtual keyboard.

Now, specify a method to handle the virtual keyboard:

Inputmethodmanager:

Central system API to the overall input method framework (IMF) architecture, which arbitrates interaction between applications and the current input method. You can retrieve an instance of this interface with context. getsystemservice ().

Inputmethodmanager is used to control the input method:

Java code

Inputmethodmanager Imm = (inputmethodmanager) getsystemservice (context. input_method_service );
Use: Java code

If (IMM. isactive ())
To check whether the virtual keyboard is enabled.
Then you can use the toggle method to close its Java code.

Imm. togglesoftinput (inputmethodmanager. show_implicit, inputmethodmanager. hide_not_always );
Of course, if the current virtual keyboard is disabled, toggle will enable the keyboard.
Inputmethodmanager can also be enabled and disabled independently: Java code

Imm. showsoftinput (view, flags );

Imm. showsoftinputfrominputmethod (token, flags );

Imm. hidesoftinputfrominputmethod (token, flags );


In robotium:

Inputmethodmanager Imm = (inputmethodmanager) Solo. getcurrentactivity (). getsystemservice (context. input_method_service );

Asserttrue (IMM. isactive ());

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.