溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

android cts 相關(guān)

發(fā)布時間:2020-07-06 20:36:22 來源:網(wǎng)絡(luò) 閱讀:1218 作者:CamilleIT 欄目:移動開發(fā)

1 在linux和windows中使用不同的命令打開窗口,比如使用adb 時,linux要用:

Runtime.getRuntime().exec(new String[] {"/bin/sh","-c",cmd});

而windows會用 

Runtime.getRuntime().exec(new String[] {"cmd","/c",cmd});,

如果都用/bin/bash,會報以下錯誤:

java.io.IOException: Cannot run program "/bin/bash": CreateProcess error=2, The system cannot find the file specified

    at java.lang.ProcessBuilder.start(Unknown Source)

    at java.lang.Runtime.exec(Unknown Source)

    at java.lang.Runtime.exec(Unknown Source)


2 set aapt before running CTS

CTS currently supports 64-bit Linux and Mac OS host machines.


Before running the CTS, make sure you have recent versions of both Android Debug Bridge (adb) and Android Asset Packaging Tool (AAPT) installed and those tools' location added to the system path of your machine.


To install ADB, download the Android SDK Tools package for your operating system, open it, and follow the instructions in the included README file. For troubleshooting information, see Installing the Stand-alone SDK Tools.


Ensure adb and aapt are in your system path. The following command assumes you've opened the package archive in your home directory:


export PATH=$PATH:$HOME/android-sdk-linux/build-tools/<version>


3 UI automator

使用UI.takeScreenshot(path), path related


a) 使用

/data/local/tmp/

時生成文件aa.png報錯,只能先push 一個叫aa.png的文件之后,才能截屏?xí)r,替換原來的文件

b)

使用當(dāng)前testcase本身的包路徑,可以生成文件,但是不能pull出來 Permission denied

文件實際路徑:/data/user/0/com.test/files/aa.png

c) 

save files that are private to your app

File f=  mContext.getApplicationContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
File path = new File(f.getAbsolutePath()+File.separator+"99.png");
mDevice.takeScreenshot(path);

可以直接生成文件aa.png.

文件實際路徑:

/storage/emulated/0/Android/data/com.test/files/Download/aa.png

d)

save public files on the external stroage

File f=  Environment.(Environment.)File path = File(f.getAbsolutePath()+File.+)

takeScreenshot--- /storage/emulated/0/Download/8888.png

 E/UiDevice: failed to save screen shot to file

  java.io.FileNotFoundException: /storage/emulated/0/Download/8888.png (Permission denied)

需要添加權(quán)限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI