>>分享Android开发相关的技术 书籍支持  卫琴直播  品书摘要  在线测试  资源下载  联系我们
发表一个新主题 开启一个新投票 回复文章 您是本文章第 26705 个阅读者 刷新本主题
 * 贴子主题:  android cts 相关 回复文章 点赞(0)  收藏  
作者:Jacky    发表时间:2020-05-15 08:05:18     消息  查看  搜索  好友  邮件  复制  引用

   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的文件之后,才能截屏时,替换原来的文件

b)

使用当前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)

需要添加权限:

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

        

----------------------------
原文链接:https://blog.51cto.com/yingerfei/1737367

程序猿的技术大观园:www.javathinker.net



[这个贴子最后由 flybird 在 2020-05-15 17:14:23 重新编辑]
  Java面向对象编程-->数据类型
  JavaWeb开发-->JSP中使用JavaBean(Ⅱ)
  JSP与Hibernate开发-->映射组成关系
  Java网络编程-->创建非阻塞的HTTP服务器
  精通Spring-->计算属性和数据监听
  Vue3开发-->计算属性和数据监听
  Android Gallery实现循环显示图像
  Android网络编程之WebKit应用
  Android在SDcard建文件夹(在Android中移动文件必用)
  Android实用测试方法之Monkey与MonkeyRunner
  编译Irrlicht On Android
  Android自动化测试之Robotium学习
  Android Application Theme的实现及管理
  Android DownloadManager用法举例
  Android HelloGallery范例实验记录
  Scroll的原理和简单使用
  Android性能优化技巧
  Android内存优化—dumpsys meminfo详解
  自定义ViewGroup和FrameLayout实现轮播图(包括底部小圆点)
  MVVM 架构与数据绑定库
  Flutter 插件开发:以微信SDK为例-Android架构的博客
  更多...
 IPIP: 已设置保密
楼主      
1页 0条记录 当前第1
发表一个新主题 开启一个新投票 回复文章


中文版权所有: JavaThinker技术网站 Copyright 2016-2026 沪ICP备16029593号-2
荟萃Java程序员智慧的结晶,分享交流Java前沿技术。  联系我们
如有技术文章涉及侵权,请与本站管理员联系。