Android--ubuntu "CTS" Test TV real Machine

Source: Internet
Author: User

Recently contacted CTS, is rumored not to understand CTS is not counted as a qualified Android developer, I have not seen around who used, as a product development of Android personnel, I still too young ~



Writing is not easy, reproduced please specify the source: http://blog.csdn.net/jscese/article/details/40650001#t11


Concept:

The compatibility Test Suite (CTS) Compatibility Testing group, a set of test frameworks provided by Google, contains many test cases,

The framework is used to manage the execution of test cases on a real machine device or simulator, and those use cases are all written in Java apk, and the results from running these apk are tested to test the compatibility and stability of the system platform.

compatibility definition Document (CDD) a defined standard that requires compliance with software and hardware-related parameters.

You can send the test results to [email protected]. When you submit a CTS report, you can also request access to AndroidMarket.



Configuration:

There are Android source code can be directly under the source make CTS , and finally generate /out/host/linux-x86/cts/android-cts

You can also go to http://source.android.com/compatibility/downloads.html download the various versions of the CTS components provided by Google, extracted android-cts The catalog needs to be version-compatible!

The directory structure is as follows:



Where docs is empty,

There are plans in the repository directory. testcases

The Tools directory is the toolkit that starts the CTS console and is launched by the cts-tradefed script! One of them is a README .

The configuration of the Internet is so varied that it is straightforward to read directly:

Configuring Cts-tradefed------------------------1. Ensure ' adb ' is in your current PATH. ADB can be found in Theandroid SDK available from http://developer.android.comExample:PATH= $PATH:/home/myuser/android-s Dk-linux_x86/platform-tools2. Follow the ' Setting up your device ' steps documented in Thects User Manual. The CTS User Manual can be downloaded ATHTTP://SOURCE.ANDROID.COM/COMPATIBILITY/DOWNLOADS.HTML3. Connect the device to the host machine.4. Ensure device is the visible via ' adb devices ' Using cts-tradefed-------------------to run a test plan on a single device:1. Make sure least one device connected2. Launch the cts-tradefed console by running the ' cts-tradefed ' script atandroid-cts/tools/cts-tradefed3. Type: ' Run CTS--plan CTS ' to run the default CTS plansome other useful commands Areto run a test package: ' Run CTS--packag E <packagename> ' To run a test class: ' Run CTS--class <full test Class name> ' to Shard a plan test run on Multip Le devices ' run CTS--planCTS--shards <number of Shards>note:all connected devices must is running the same buildfor more options: ' Run CTS- -help ' CTS tradefed development------------------------See http://source.android.com for instructions on obtaining the Androidplatform source code and setting up a build environment. The source for the CTS extensions for tradefed can is found at<android source root>/cts/tools/tradefed-hostthe Sourc E for the tradefed framework can is found on the ' tradefed ' branch. Perform these steps to build and run cts-tradefed from the DEVELOPMENTENVIRONMENT:CD <path to Android source Root>ma Ke ctscts-tradefed

Google's Readme is very clear, the need for the terminal to use adbThis is available in the SDK provided by Google, the download link is given, and then set to the environment variable path!

You can look at the cts-tradefed script:

Checkpath adbcheckpath java# Check java versionjava_version=$ (java-version 2>&1 | head-n 1 | grep ' ["]1\.6[\." $$] If ["${java_version}" = = ""]; Then    echo "wrong Java version. 1.6 is required. "    Exitfi

Can see is needed JDK 1.6Above the support of!

The CTS under Android Source may not be up-to-date, so it is best to go to the Google website mentioned above to download the corresponding CTS components!


Use:
Start:

First turn on the TV's adb debug switch, Ubuntu through the ADB connect tv_ip connection, android-cts execute cts-tradefed script into the CTS console:



You can see the information about the device by using the L-d command under CTS-TF.


Command:

Use Help to view:


You can see the set of supported commands !

Where version is 4.2_R4, defined in /cts/tools/tradefed-host/src/com/android/cts/tradefed/build/ctsbuildprovider.java

Use L p to view a testable plan:

CTS-TF > L pcts-tfctsvm-tfappsecuritypdkjavaandroidsignature

These are the things that exist Android-cts/repository/plansUnder

A plan contains multiple package, and each execution of the run CTS assigns a Session number, starting with 0.

L d Display connected devices, L packages display testable packages, l R displays recorded results


Run cts-p package_name test the Package_name package separately


Run CTS--continue-session SessionID--disable-reboot

Continue the test according to SessionID, do not restart, because the restart of ADB is broken!


run cts-c com.class_name-m methmod_name The method of testing a class-C followed by the class name full path –m followed by the method name


Other commands can read the comments, do not explain more!


Get ready:

If you need to test media -related packages, you can download CTS Media 1.0 to the SDcard test directory on Google's website.

Additional preparations to be made are:

Install the CTS test required APK to target board: ctsdelegatingaccessibilityservice.apk,ctsdeviceadmin.apk
(These two apk can be found in the testcase of the CTS source code directory)

Configuration of the system setting
(If the project deleted the default setting or the depth of the change, you can use Google's native setting to replace the original setting to set up)
Enter settings to open Wi-Fi and connect to the AP (AP needs to be connected to the extranet)
Enter Settings->security->screenlock set to None
Enter settings->security->deviceadministrators->enable two options
Enter Language&input->language set to 中文版 (UnitedStates)
Enter Settings->display->sleep set to 30minutes or none
Enter settings->accessibility->enabledelegating accessibility Service
Enter settings->developeroptions->enable USB debugging, Stay awake, allowmock locations
Set the time manually and set the timezone to Beijing, setting the country to China

This allows running the run CTS * for testing!



Results:

results saved in /android-cts/repository/results/2014.10.31_11.53.42/testresult.xml after the test

You can see the results in four ways: [pass/fail/notexecuted/timeout]

If a function module is not supported on our hardware, we can modify the result= "fail" to result= "notexecuted" in Testresult.xml

If it is fail, there is a certain additional information:

 <test name= "testPlay00" result= "fail" starttime= "Week Grone 12:01:24 CST" endtime= "Week Grone 12:01:26 CST"              ; <failedscene message= "Junit.framework.assertionfailederror:playback/mnt/sdcard/test/bbb_short/176x144/3gp_ H263_libfaac/bbb_short.ffmpeg.176x144.3gp.h263_300kbps_12fps.libfaac_mono_24kbps_11025hz.3gpat Android.mediastress.cts.MediaPlayerStressTest.doTestVideoPlayback (mediaplayerstresstest.java:161) "> < Stacktrace>junit.framework.assertionfailederror:playback/mnt/sdcard/test/bbb_short/176x144/3gp_h263_libfaac /bbb_short.ffmpeg.176x144.3gp.h263_300kbps_12fps.libfaac_mono_24kbps_11025hz.3gpat Android.mediastress.cts.MediaPlayerStressTest.doTestVideoPlayback (mediaplayerstresstest.java:161) at Android.mediastress.cts.MediaPlayerStressTest.doTestVideoPlaybackShort (mediaplayerstresstest.java:165) at Android.mediastress.cts.H263QcifShortPlayerTest.testPlay00 (h263qcifshortplayertest.java:49) at Java.lang.reflect.Method.invokeNative (NatIve Method) at Android.test.InstrumentationTestCase.runMethod (instrumentationtestcase.java:214) at Android.test.InstrumentationTestCase.runTest (instrumentationtestcase.java:199) at Android.test.AndroidTestRunner.runTest (androidtestrunner.java:190) at Android.test.AndroidTestRunner.runTest ( androidtestrunner.java:175) at Android.test.InstrumentationTestRunner.onStart (instrumentationtestrunner.java:555 ) at Android.app.instrumentation$instrumentationthread.run (instrumentation.java:1661) </StackTrace> </ Failedscene> </Test>

You can see that there is also a stack of information that can be used to find the reason for asking fail!



Add TestCase:

We can see all the testcase under the source /cts/tests/tests/ .

Online method, here is the borrowing record as follows:

Configure TestCaseThe structure is as follows:Example├── androidmanifest.xml ├── android.mk └── src └── android └── example ├── cts Steps: 1, in the cts/tests/tests/ directory to create a own set of Use Cases (folder) name XXX; 2. construct the following structure in this folder:XXX├──androidmanifest.xml ( can copy example under this file ) ├── android.mk ( can copy example under this file ) └── src └── android └── XXX └── cts 3. Write test CodeSpecific operation:add your own use case under the src/android/xxx/cts directory (XXX is the name of your own test case set, for example: test)Detail Description: 1, theGoogle official CTS test case, when testing a class, not all of the methods of the class test, but the use of some of the most frequently used methods in the class, so we ourselves to program the test case, can also follow the principle of operation; 2. The directory of res resource files used in the window control class is source_android4\cts\tests\res 3, preferably written in Eclipse , you need res file, you can copy to the current project, so you can check the programming through eclipse syntax errors; 4. Format of package Name: PackAndroid. xxx.cts; 4 . Modify the android.mk file in the xxx/ directory local_package_name:= ctsxxxtestcases(this variable is the name of the set of test cases that defines itself; the APK file with the same name will be generated after compilation) local_instrumentation_for:= ctsteststubs(this variable locates some test cases involving virtual machines, using the junit framework; Teststubs This class is under directory cts\tools\vm-tests-tf\src\dot\junit\opcodes ) 5. Modify the androidmanifest.xml file in the xxx/ directory
<manifestxmlns:android= "http://schemas.android.com/apk/res/android"    package= "Com.android.cts.XXX" >    <uses-permissionandroid:name= "Android.permission.DISABLE_KEYGUARD"/>    <application>        <uses-libraryandroid:name= "Android.test.runner"/>    </application>    < Instrumentationandroid:name= "Android.test.InstrumentationCtsTestRunner"                    android:targetpackage= " Com.android.cts.stub "                     android:label=" ctstests of Android.xxx "/></manifest>


6, modify the source_android4.2/cts directory ctstestcaselist.mk; ( Important)Append your own test case set name to the variable cts_test_packages in the file ctsxxxtestcases Description: The file will be compiled at the time of theBuild/core/tasks/cts.mkcalled to generate the final CTS package. description of the ctstestcaselist.mk file: cts_coverage_test_case_list(core variable)├── cts_support_packages(this variable contains some use cases for test dependencies, which are cts/hostsidetestsfor the code directory)├── ctsaccelerationteststubs\ ├──ctsdelegatingaccessibilityservice \ ├──ctsdeviceadmin \ ├──ctsmonkeyapp \ ├──CtsMonkeyApp2 \ ├──ctssomeaccessibilityservices \ ├──ctsteststubs \ ├──signaturetest \ ├──testdevicesetup \ ├──$ (cts_security_apps_list) ├── cts_test_packages(this variable corresponds to a test case in the cts/tests/tests/ directory)


compiling your own CTS packageExecute make cts-j4


test on a real machinebecause it takes a long time to complete the CTS test, we can create a test plan ourselves, with the following steps: 1. Unzip the CTS package and create an XML named XXX under android-cts\repository\plans Documents; 2. This XML file format is:<?xmlversion= "1.0" encoding= "UTF-8"?><testplan version= "1.0" ><entry uri= "android.xxx"/></TestPlan> 3. Perform cts test when run CTS--plan XXX










Android--ubuntu "CTS" Test TV real Machine

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.