├── README.md ├── TestDemo ├── javaDemo │ ├── Test.java │ └── app │ │ └── ApiDemos.apk └── pythonDemo │ ├── Test.py │ └── app │ └── ApiDemos.apk ├── java ├── AdbForTest │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ └── org.eclipse.jdt.core.prefs │ ├── doc │ │ ├── allclasses-frame.html │ │ ├── allclasses-noframe.html │ │ ├── constant-values.html │ │ ├── deprecated-list.html │ │ ├── help-doc.html │ │ ├── index-files │ │ │ ├── index-1.html │ │ │ ├── index-10.html │ │ │ ├── index-11.html │ │ │ ├── index-12.html │ │ │ ├── index-13.html │ │ │ ├── index-14.html │ │ │ ├── index-15.html │ │ │ ├── index-16.html │ │ │ ├── index-17.html │ │ │ ├── index-18.html │ │ │ ├── index-19.html │ │ │ ├── index-2.html │ │ │ ├── index-20.html │ │ │ ├── index-21.html │ │ │ ├── index-3.html │ │ │ ├── index-4.html │ │ │ ├── index-5.html │ │ │ ├── index-6.html │ │ │ ├── index-7.html │ │ │ ├── index-8.html │ │ │ └── index-9.html │ │ ├── index.html │ │ ├── overview-frame.html │ │ ├── overview-summary.html │ │ ├── overview-tree.html │ │ ├── package-list │ │ ├── resources │ │ │ ├── background.gif │ │ │ ├── tab.gif │ │ │ ├── titlebar.gif │ │ │ └── titlebar_end.gif │ │ ├── serialized-form.html │ │ ├── stylesheet.css │ │ └── xuxu │ │ │ └── autotest │ │ │ ├── AdbDevice.html │ │ │ ├── AndroidKeyCode.html │ │ │ ├── TestException.html │ │ │ ├── XuImage.html │ │ │ ├── class-use │ │ │ ├── AdbDevice.html │ │ │ ├── AndroidKeyCode.html │ │ │ ├── TestException.html │ │ │ └── XuImage.html │ │ │ ├── element │ │ │ ├── Element.html │ │ │ ├── ElementAttribs.html │ │ │ ├── Position.html │ │ │ ├── UiDump.html │ │ │ ├── UiDumpService.html │ │ │ ├── class-use │ │ │ │ ├── Element.html │ │ │ │ ├── ElementAttribs.html │ │ │ │ ├── Position.html │ │ │ │ ├── UiDump.html │ │ │ │ └── UiDumpService.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ ├── package-use.html │ │ │ └── utils │ │ │ ├── DataUtils.html │ │ │ ├── ImageUtils.html │ │ │ ├── ReUtils.html │ │ │ ├── ShellUtils.html │ │ │ ├── class-use │ │ │ ├── DataUtils.html │ │ │ ├── ImageUtils.html │ │ │ ├── ReUtils.html │ │ │ └── ShellUtils.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ └── src │ │ └── xuxu │ │ └── autotest │ │ ├── AdbDevice.java │ │ ├── AndroidKeyCode.java │ │ ├── TestException.java │ │ ├── XuImage.java │ │ ├── element │ │ ├── Element.java │ │ ├── ElementAttribs.java │ │ ├── Position.java │ │ ├── UiDump.java │ │ └── UiDumpService.java │ │ └── utils │ │ ├── DataUtils.java │ │ ├── ImageUtils.java │ │ ├── MonkeyScriptUtils.java │ │ ├── ReUtils.java │ │ └── ShellUtils.java └── jar │ ├── Adb-For-Test-2015-12-24.jar │ └── Adb-For-Test-source-2015-12-24.jar └── python ├── adbUtils ├── __init__.py └── utils │ ├── __init__.py │ ├── adbUtils.py │ ├── element.py │ ├── imageUtils.py │ ├── keycode.py │ └── logUtils.py ├── doc └── doc.txt └── setup.py /README.md: -------------------------------------------------------------------------------- 1 | # Adb-For-Test 2 | 3 | 4 | 通过 `adb 命令`实现简单的点击、滑动、长按等效果,可通过比例定位元素、通过元素定位(需要 Android 版本高于 4.0),用于`Android Test`,拥有 monkeyrunner 的绝大部分功能 5 | 6 | ### 2018.05.17 7 | python 版本获取分辨率方法添加对 4.3 及以上机型通过`wm size`命令获取 8 | 9 | ### 2015.12.24 10 | java 版本增加 pinchZoom 方法,对屏幕进行缩放 11 | 12 | ### 2015.04.28 13 | * 重构 `python 版本`中的 adbUitils 模块,合并 `AppInfo`、`Action` 类至 `ADB`中 14 | 15 | > 初始化方法: 16 | 17 | > adb = ADB() 或 adb = ADB("device_id") 18 | * 重构的目的是增加 python 版本对多设备的支持,通过传入 device_id,解决有多台设备连接 USB 时无法执行脚本的问题 19 | * `Element` 类中增加通过属性 `content-desc` 定位元素的方法 20 | 21 | ### Robotium 22 | * 如果想用于`Robotium`处理跨进程,需要修改部分代码,请参考[Adb-For-Robotium](https://github.com/gb112211/Adb-For-Robotium) 23 | 24 | ### 为何写这么个东西? 25 | 26 | * 目前所做的工作是对 rom 的测试,所以基本上所有的测试环境都集中在 Android4.2、4.3、4.4平台,平台比较固定 27 | * Android 测试中最为熟悉的就是 adb 命令,很多功能都可通过adb命令去实现,因此几乎可以使用任何的编程语言去编写脚本调用 adb 命令,去实现对设备的操作 28 | * 将日常工作中封装的一些由 adb 命令完成的功能整合在一起,方便于使用 29 | * 作为自己学习 java、python 的一种实践 30 | 31 | ### 优点 32 | 33 | * 分别采用两种语言(java、python)实现,需要的环境都极其的简单,不需要 root 34 | * 基本上都以 adb 命令完成功能,可从代码中剥离部分代码形成日常用的脚本(参考[AndroidTestScripts](https://github.com/gb112211/AndroidTestScripts)项目) 35 | * 由于是通过 adb 命令去发送事件,所以可跨应用进行测试,可用来扩展其他 Android 测试框架 36 | * 通过设备分辨率与坐标转换,可以方便的以屏幕比例作为参数来操作设备 37 | * 调用了 `uiautomator` 命令,Android4.0 以上,可通过界面元素进行定位,可获取界面内单个元素区域的坐标范围,以此截取图片(区别于截取整个屏幕) 38 | * 可采用截图对比全图、部分区域图片、获取当前界面某个元素、获取当前界面的 Activity 等各种属性,对测试结果进行判断 39 | 40 | ### 缺点 41 | 42 | * 部分功能需要较高的 Android 版本,低版本的未去验证,所以局限性很大,纯当练手 43 | * 初学 java、python,代码写得比较烂 44 | * 很多地方未做异常处理 45 | * 暂时未写单元测试,所以使用时需要读者阅读具体的源码 46 | * 有疑问有吐槽请联系:Email: xuxu_1988@126.com QQ:274925460 47 | 48 | ### 需要的环境 49 | 50 | * 环境变量:需配置 ANDROID_HOME 51 | * python:python2.7,如果用到截图对比功能,需要安装 PIL 库,PIL 无法安装时可用[Pillow](http://www.pythonware.com/products/pil/index.htm "PIL地址") 52 | * java: jdk1.6 以上,不需要其他任何第三方 jar 包, jar 不可用时,可能是 jdk 版本问题,请自行编译 53 | 54 | ### 如何使用 55 | 56 | * python:使用 setup.py install 安装,未去强制判断要求安装 PIL,使用 ImageUtils 时则需要安装 57 | * java:导入 `Adb-For-Test.jar` 即可 58 | 59 | ### 简单例子 60 | 61 | * 在 TestDemo 目录下分别有 python、java 的例子,使用的 apk 是 ApiDemos.apk 62 | 63 | * 这里使用 python 写一个截取桌面应用图标的例子: 64 | 65 | ``` 66 | #coding=utf-8 67 | 68 | import os 69 | 70 | from adbUtils.utils.adbUtils import ADB 71 | from adbUtils.utils.imageUtils import ImageUtils 72 | from adbUtils.utils.element import Element 73 | 74 | #单个设备可不传入device_id 75 | adb = ADB(“device_id”) 76 | element = Element("device_id") 77 | 78 | #获取图片区域 79 | icon = element.getElementBoundsByClass("android.widget.TextView")[0] 80 | image = ImageUtils() 81 | #截取图片 82 | image.screenShot().subImage(icon).writeToFile(os.getcwd(), "image") 83 | 84 | #加载需要对比的目标图片 85 | #load = image.loadImage(os.getcwd() + "\\image.png") 86 | #print image.screenShot().subImage(icon).sameAs(load) 87 | ``` -------------------------------------------------------------------------------- /TestDemo/javaDemo/Test.java: -------------------------------------------------------------------------------- 1 | package testdemo; 2 | 3 | import java.util.ArrayList; 4 | 5 | import xuxu.autotest.AdbDevice; 6 | import xuxu.autotest.AndroidKeyCode; 7 | import xuxu.autotest.element.Element; 8 | import xuxu.autotest.element.Position; 9 | 10 | /** 11 | * demo为ApiDemos.apk,使用的真机平台为android 4.3 12 | * 13 | * @author xuxu 14 | * 15 | */ 16 | 17 | public class Test { 18 | 19 | public static void main(String[] args) throws Exception { 20 | //获取adb连接 21 | AdbDevice device = new AdbDevice(); 22 | 23 | //获取设备信息 24 | System.out.println("设备序列号: " + device.getDeviceId()); 25 | int[] resolution = device.getScreenResolution(); 26 | System.out.println("设备屏幕分辨率: " + resolution[0] + "x" + resolution[1]); 27 | System.out.println("设备Android版本: " + device.getAndroidVersion()); 28 | System.out.println("设备SDK版本: " + device.getSdkVersion()); 29 | System.out.println("设备电池状态: " + device.getBatteryStatus()); 30 | System.out.println("设备电池温度: " + device.getBatteryTemp()); 31 | System.out.println("设备电池电量: " + device.getBatteryLevel()); 32 | 33 | //安装d:\app\ApiDemos.apk 34 | device.installApp("d:\\app\\ApiDemos.apk"); 35 | //启动ApiDemos 36 | device.startActivity("com.example.android.apis/.ApiDemos"); 37 | Thread.sleep(2000); 38 | 39 | //获取获取当前应用的包名、类名、包名/类名 40 | System.out.println("package name: " + device.getCurrentPackageName()); 41 | System.out.println("activite: " + device.getCurrentActivity()); 42 | String component = device.getFocusedPackageAndActivity(); 43 | System.out.println("package name/activity: " + component); 44 | 45 | //获取当前应用的pid 46 | System.out.println("PID: " + device.getPid(device.getCurrentPackageName())); 47 | //退出当前应用 48 | device.quitCurrentApp(); 49 | Thread.sleep(1000); 50 | 51 | //重新启动应用 52 | device.startActivity(component); 53 | Thread.sleep(2000); 54 | 55 | //通过元素的text属性定位,点击App>>Dialog>>Single choice list>>Traffic>>OK 56 | Position position = new Position(); 57 | Element e_text = position.findElementByText("App"); 58 | device.tap(e_text); 59 | Thread.sleep(1000); 60 | 61 | Element e_dialog = position.findElementByText("Dialog"); 62 | device.tap(e_dialog); 63 | Thread.sleep(1000); 64 | 65 | Element e_single = position.findElementByText("Single choice list"); 66 | device.tap(e_single); 67 | Thread.sleep(1000); 68 | 69 | //通过元素的class定位:Traffic>>OK 70 | ArrayList textViews = position.findElementsByClass("android.widget.CheckedTextView"); 71 | device.tap(textViews.get(2)); 72 | Thread.sleep(1000); 73 | 74 | Element e_ok = position.findElementsByClass("android.widget.Button").get(1); 75 | device.tap(e_ok); 76 | Thread.sleep(1000); 77 | 78 | //遍历的点击当前界面所有的button 79 | ArrayList buttons = position.findElementsByClass("android.widget.Button"); 80 | for (Element element : buttons) { 81 | device.tap(element); 82 | Thread.sleep(1000); 83 | device.sendKeyEvent(AndroidKeyCode.BACK); 84 | } 85 | 86 | //点击Text Entry dialog 87 | device.tap(buttons.get(buttons.size() - 1)); 88 | Thread.sleep(1000); 89 | 90 | //需要英文键盘 91 | //输入Name:test, Password: TEST, 点击OK 92 | ArrayList edits = position.findElementsByClass("android.widget.EditText"); 93 | device.tap(edits.get(0)); 94 | device.sendText("test"); 95 | 96 | device.tap(edits.get(1)); 97 | device.sendText("TEST"); 98 | 99 | device.tap(position.findElementByText("OK")); 100 | 101 | } 102 | } -------------------------------------------------------------------------------- /TestDemo/javaDemo/app/ApiDemos.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gb112211/Adb-For-Test/0b850dab28bc39777617ec7efd90b168502d2d3e/TestDemo/javaDemo/app/ApiDemos.apk -------------------------------------------------------------------------------- /TestDemo/pythonDemo/Test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #coding=utf-8 3 | 4 | __author__ = "xuxu" 5 | 6 | from adbUtils.utils.adbUtils import ADB 7 | from adbUtils.utils.element import Element 8 | from adbUtils.utils import keycode 9 | 10 | import os 11 | import time 12 | 13 | #demo为ApiDemos.apk,使用的真机平台为android 4.3 14 | 15 | PATH = lambda p : os.path.abspath(p) 16 | 17 | def test(): 18 | #获取adb连接,单个设备可以不传该参数 19 | adb = ADB() 20 | 21 | #获取设备信息 22 | print "设备序列号: " + adb.getDeviceID() 23 | print "设备状态: " + adb.getDeviceState() 24 | print "设备屏幕分辨率: " + str(adb.getScreenResolution()) 25 | print "设备电池状态: " + adb.getBatteryStatus() 26 | print "设备电池温度: " + str(adb.getBatteryTemp()) 27 | print "设备电池电量: " + str(adb.getBatteryLevel()) 28 | 29 | #安装当前目录下的ApiDemos.apk 30 | if(not adb.isInstall("com.example.android.apis")): 31 | #应用不存在则安装 32 | adb.installApp(PATH(os.getcwd() + "/app/ApiDemos.apk")) 33 | else: 34 | #存在则先卸载,后安装 35 | adb.removeApp("com.example.android.apis") 36 | time.sleep(3) 37 | adb.installApp(PATH(os.getcwd() + "/app/ApiDemos.apk")) 38 | 39 | time.sleep(3) 40 | adb.startActivity("com.example.android.apis/.ApiDemos") 41 | time.sleep(3) 42 | 43 | #获取当前应用的包名、类名、包名/类名 44 | print adb.getCurrentPackageName() 45 | print adb.getCurrentActivity() 46 | component = adb.getFocusedPackageAndActivity() 47 | print component 48 | 49 | #获取当前应用的pid 50 | print adb.getCurrentPackageName() + "-pid: " + str(adb.getPid(adb.getCurrentPackageName())) 51 | #结束当前应用 52 | adb.quitApp(adb.getCurrentPackageName()) 53 | 54 | #重新启动 55 | adb.startActivity(component) 56 | #延时2s 57 | time.sleep(2) 58 | #通过元素的text属性定位,点击App>>Dialog>>Single choice list>>Traffic>>OK 59 | element = Element() 60 | 61 | e_app = element.findElementByName("App") 62 | adb.touchByElement(e_app) 63 | time.sleep(1) 64 | 65 | e_dialog = element.findElementByName("Dialog") 66 | adb.touchByElement(e_dialog) 67 | time.sleep(1) 68 | 69 | e_single = element.findElementByName("Single choice list") 70 | adb.touchByElement(e_single) 71 | time.sleep(1) 72 | 73 | #通过元素的class定位:Traffic>>OK 74 | textViews = element.findElementsByClass("android.widget.CheckedTextView") 75 | adb.touchByElement(textViews[2]) 76 | time.sleep(1) 77 | 78 | e_ok = element.findElementsByClass("android.widget.Button")[1] 79 | adb.touchByElement(e_ok) 80 | time.sleep(1) 81 | 82 | #遍历的点击当前界面所有的button 83 | buttons = element.findElementsByClass("android.widget.Button") 84 | for button in buttons: 85 | adb.touchByElement(button) 86 | time.sleep(1) 87 | adb.sendKeyEvent(keycode.BACK) 88 | 89 | #点击Text Entry dialog 90 | adb.touchByElement(buttons[-1]) 91 | time.sleep(1) 92 | #需要英文键盘 93 | #输入Name:test, Password: TEST, 点击OK 94 | edits = element.findElementsByClass("android.widget.EditText") 95 | adb.touchByElement(edits[0]) 96 | adb.sendText("test") 97 | 98 | adb.touchByElement(edits[-1]) 99 | adb.sendText("TEST") 100 | 101 | adb.touchByElement(element.findElementByName("OK")) 102 | 103 | if __name__ == "__main__": 104 | test() 105 | -------------------------------------------------------------------------------- /TestDemo/pythonDemo/app/ApiDemos.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gb112211/Adb-For-Test/0b850dab28bc39777617ec7efd90b168502d2d3e/TestDemo/pythonDemo/app/ApiDemos.apk -------------------------------------------------------------------------------- /java/AdbForTest/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /java/AdbForTest/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | -------------------------------------------------------------------------------- /java/AdbForTest/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | AdbForTest 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /java/AdbForTest/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.6 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.6 12 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 所有类 8 | 9 | 10 | 11 | 12 |

所有类

13 |
14 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 所有类 8 | 9 | 10 | 11 | 12 |

所有类

13 |
14 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 已过时的列表 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

已过时的 API

68 |

目录

69 |
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | A - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

A

70 |
71 |
AdbDevice - xuxu.autotest中的类
72 |
 
73 |
AdbDevice() - 类 的构造器xuxu.autotest.AdbDevice
74 |
 
75 |
AndroidKeyCode - xuxu.autotest中的接口
76 |
 
77 |
78 | A B C D E F G H I K L M P Q R S T U V W X 
79 | 80 |
81 | 82 | 83 | 84 | 85 | 95 |
96 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-10.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | K - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

K

70 |
71 |
killProcess(int) - 类 中的方法xuxu.autotest.AdbDevice
72 |
 
73 |
74 | A B C D E F G H I K L M P Q R S T U V W X 
75 | 76 |
77 | 78 | 79 | 80 | 81 | 91 |
92 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-14.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Q - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

Q

70 |
71 |
quitCurrentApp() - 类 中的方法xuxu.autotest.AdbDevice
72 |
73 |
退出当前应用
74 |
75 |
76 | A B C D E F G H I K L M P Q R S T U V W X 
77 | 78 |
79 | 80 | 81 | 82 | 83 | 93 |
94 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-18.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | U - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

U

70 |
71 |
UiDump - xuxu.autotest.element中的类
72 |
 
73 |
UiDump() - 类 的构造器xuxu.autotest.element.UiDump
74 |
 
75 |
UiDumpService - xuxu.autotest.element中的类
76 |
 
77 |
UiDumpService() - 类 的构造器xuxu.autotest.element.UiDumpService
78 |
 
79 |
80 | A B C D E F G H I K L M P Q R S T U V W X 
81 | 82 |
83 | 84 | 85 | 86 | 87 | 97 |
98 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-19.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | V - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

V

70 |
71 |
VOLUME_DOWN - 接口 中的静态变量xuxu.autotest.AndroidKeyCode
72 |
 
73 |
VOLUME_UP - 接口 中的静态变量xuxu.autotest.AndroidKeyCode
74 |
 
75 |
76 | A B C D E F G H I K L M P Q R S T U V W X 
77 | 78 |
79 | 80 | 81 | 82 | 83 | 93 |
94 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | B - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

B

70 |
71 |
BACK - 接口 中的静态变量xuxu.autotest.AndroidKeyCode
72 |
 
73 |
BACKSPACE - 接口 中的静态变量xuxu.autotest.AndroidKeyCode
74 |
 
75 |
BOUNDS - 接口 中的静态变量xuxu.autotest.element.ElementAttribs
76 |
 
77 |
78 | A B C D E F G H I K L M P Q R S T U V W X 
79 | 80 |
81 | 82 | 83 | 84 | 85 | 95 |
96 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-20.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | W - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

W

70 |
71 |
writeToFile(String) - 类 中的方法xuxu.autotest.XuImage
72 |
73 |
将截屏文件写入本地,以当前系统时间戳命名,格式为PNG
74 |
75 |
76 | A B C D E F G H I K L M P Q R S T U V W X 
77 | 78 |
79 | 80 | 81 | 82 | 83 | 93 |
94 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-21.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | X - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

X

70 |
71 |
XuImage - xuxu.autotest中的类
72 |
 
73 |
xuxu.autotest - 程序包 xuxu.autotest
74 |
 
75 |
xuxu.autotest.element - 程序包 xuxu.autotest.element
76 |
 
77 |
xuxu.autotest.utils - 程序包 xuxu.autotest.utils
78 |
 
79 |
80 | A B C D E F G H I K L M P Q R S T U V W X 
81 | 82 |
83 | 84 | 85 | 86 | 87 | 97 |
98 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | D - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

D

70 |
71 |
DataUtils - xuxu.autotest.utils中的类
72 |
 
73 |
DataUtils() - 类 的构造器xuxu.autotest.utils.DataUtils
74 |
 
75 |
76 | A B C D E F G H I K L M P Q R S T U V W X 
77 | 78 |
79 | 80 | 81 | 82 | 83 | 93 |
94 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | E - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

E

70 |
71 |
Element - xuxu.autotest.element中的类
72 |
 
73 |
Element() - 类 的构造器xuxu.autotest.element.Element
74 |
 
75 |
ElementAttribs - xuxu.autotest.element中的接口
76 |
 
77 |
ENTER - 接口 中的静态变量xuxu.autotest.AndroidKeyCode
78 |
 
79 |
80 | A B C D E F G H I K L M P Q R S T U V W X 
81 | 82 |
83 | 84 | 85 | 86 | 87 | 97 |
98 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | H - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

H

70 |
71 |
HOME - 接口 中的静态变量xuxu.autotest.AndroidKeyCode
72 |
 
73 |
74 | A B C D E F G H I K L M P Q R S T U V W X 
75 | 76 |
77 | 78 | 79 | 80 | 81 | 91 |
92 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index-files/index-9.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | I - 索引 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I K L M P Q R S T U V W X  67 | 68 | 69 |

I

70 |
71 |
ImageUtils - xuxu.autotest.utils中的类
72 |
 
73 |
ImageUtils() - 类 的构造器xuxu.autotest.utils.ImageUtils
74 |
 
75 |
installApp(String) - 类 中的方法xuxu.autotest.AdbDevice
76 |
77 |
安装应用
78 |
79 |
isInstalled(String) - 类 中的方法xuxu.autotest.AdbDevice
80 |
81 |
判断应用是否已经安装
82 |
83 |
84 | A B C D E F G H I K L M P Q R S T U V W X 
85 | 86 |
87 | 88 | 89 | 90 | 91 | 101 |
102 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 生成的文档 (无标题) 8 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | <noscript> 62 | <div>您的浏览器已禁用 JavaScript。</div> 63 | </noscript> 64 | <h2>框架预警</h2> 65 | <p>请使用框架功能查看此文档。如果看到此消息, 则表明您使用的是不支持框架的 Web 客户机。链接到<a href="overview-summary.html">非框架版本</a>。</p> 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 概览列表 8 | 9 | 10 | 11 | 12 | 13 |
14 |

程序包

15 | 20 |
21 |

 

22 | 23 | 24 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/overview-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 概览 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 |
程序包 
程序包说明
xuxu.autotest 
xuxu.autotest.element 
xuxu.autotest.utils 
88 |
89 | 90 |
91 | 92 | 93 | 94 | 95 | 105 |
106 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/package-list: -------------------------------------------------------------------------------- 1 | xuxu.autotest 2 | xuxu.autotest.element 3 | xuxu.autotest.utils 4 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/resources/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gb112211/Adb-For-Test/0b850dab28bc39777617ec7efd90b168502d2d3e/java/AdbForTest/doc/resources/background.gif -------------------------------------------------------------------------------- /java/AdbForTest/doc/resources/tab.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gb112211/Adb-For-Test/0b850dab28bc39777617ec7efd90b168502d2d3e/java/AdbForTest/doc/resources/tab.gif -------------------------------------------------------------------------------- /java/AdbForTest/doc/resources/titlebar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gb112211/Adb-For-Test/0b850dab28bc39777617ec7efd90b168502d2d3e/java/AdbForTest/doc/resources/titlebar.gif -------------------------------------------------------------------------------- /java/AdbForTest/doc/resources/titlebar_end.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gb112211/Adb-For-Test/0b850dab28bc39777617ec7efd90b168502d2d3e/java/AdbForTest/doc/resources/titlebar_end.gif -------------------------------------------------------------------------------- /java/AdbForTest/doc/serialized-form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 序列化表格 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

序列化表格

68 |
69 |
70 | 82 |
83 | 84 |
85 | 86 | 87 | 88 | 89 | 99 |
100 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/class-use/AdbDevice.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 类 xuxu.autotest.AdbDevice的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

类 xuxu.autotest.AdbDevice
的使用

68 |
69 |
没有xuxu.autotest.AdbDevice的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/class-use/AndroidKeyCode.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 接口 xuxu.autotest.AndroidKeyCode的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

接口 xuxu.autotest.AndroidKeyCode
的使用

68 |
69 |
没有xuxu.autotest.AndroidKeyCode的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/class-use/TestException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 类 xuxu.autotest.TestException的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

类 xuxu.autotest.TestException
的使用

68 |
69 |
没有xuxu.autotest.TestException的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/element/class-use/ElementAttribs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 接口 xuxu.autotest.element.ElementAttribs的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

接口 xuxu.autotest.element.ElementAttribs
的使用

68 |
69 |
没有xuxu.autotest.element.ElementAttribs的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/element/class-use/Position.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 类 xuxu.autotest.element.Position的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

类 xuxu.autotest.element.Position
的使用

68 |
69 |
没有xuxu.autotest.element.Position的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/element/class-use/UiDump.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 类 xuxu.autotest.element.UiDump的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

类 xuxu.autotest.element.UiDump
的使用

68 |
69 |
70 | 109 |
110 | 111 |
112 | 113 | 114 | 115 | 116 | 126 |
127 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/element/class-use/UiDumpService.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 类 xuxu.autotest.element.UiDumpService的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

类 xuxu.autotest.element.UiDumpService
的使用

68 |
69 |
没有xuxu.autotest.element.UiDumpService的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/element/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xuxu.autotest.element 8 | 9 | 10 | 11 | 12 |

xuxu.autotest.element

13 |
14 |

接口

15 | 18 |

19 | 25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/element/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xuxu.autotest.element 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

程序包 xuxu.autotest.element

68 |
69 |
70 |
    71 |
  • 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 |
    接口概要 
    接口说明
    ElementAttribs 
    85 |
  • 86 |
  • 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 |
    类概要 
    说明
    Element 
    Position 
    UiDump 
    UiDumpService 
    112 |
  • 113 |
114 |
115 | 116 |
117 | 118 | 119 | 120 | 121 | 131 |
132 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/element/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xuxu.autotest.element 类分层结构 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

程序包xuxu.autotest.element的分层结构

68 | 程序包分层结构: 69 | 72 |
73 |
74 |

类分层结构

75 |
    76 |
  • java.lang.Object 77 |
      78 |
    • org.xml.sax.helpers.DefaultHandler (implements org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler) 79 | 82 |
    • 83 |
    • xuxu.autotest.element.Element
    • 84 |
    • xuxu.autotest.element.Position
    • 85 |
    • xuxu.autotest.element.UiDump
    • 86 |
    87 |
  • 88 |
89 |

接口分层结构

90 | 93 |
94 | 95 |
96 | 97 | 98 | 99 | 100 | 110 |
111 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xuxu.autotest 8 | 9 | 10 | 11 | 12 |

xuxu.autotest

13 |
14 |

接口

15 | 18 |

19 | 23 |

异常错误

24 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xuxu.autotest 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

程序包 xuxu.autotest

68 |
69 |
70 |
    71 |
  • 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 |
    接口概要 
    接口说明
    AndroidKeyCode 
    85 |
  • 86 |
  • 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 |
    类概要 
    说明
    AdbDevice 
    XuImage 
    104 |
  • 105 |
  • 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 |
    异常错误概要 
    异常错误说明
    TestException 
    119 |
  • 120 |
121 |
122 | 123 |
124 | 125 | 126 | 127 | 128 | 138 |
139 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xuxu.autotest 类分层结构 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

程序包xuxu.autotest的分层结构

68 | 程序包分层结构: 69 | 72 |
73 |
74 |

类分层结构

75 |
    76 |
  • java.lang.Object 77 |
      78 |
    • xuxu.autotest.AdbDevice
    • 79 |
    • java.lang.Throwable (implements java.io.Serializable) 80 |
        81 |
      • java.lang.Exception 82 |
          83 |
        • java.lang.RuntimeException 84 | 87 |
        • 88 |
        89 |
      • 90 |
      91 |
    • 92 |
    • xuxu.autotest.XuImage
    • 93 |
    94 |
  • 95 |
96 |

接口分层结构

97 | 100 |
101 | 102 |
103 | 104 | 105 | 106 | 107 | 117 |
118 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 程序包 xuxu.autotest的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

程序包 xuxu.autotest
的使用

68 |
69 |
70 | 102 |
103 | 104 |
105 | 106 | 107 | 108 | 109 | 119 |
120 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/utils/class-use/DataUtils.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 类 xuxu.autotest.utils.DataUtils的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

类 xuxu.autotest.utils.DataUtils
的使用

68 |
69 |
没有xuxu.autotest.utils.DataUtils的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/utils/class-use/ImageUtils.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 类 xuxu.autotest.utils.ImageUtils的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

类 xuxu.autotest.utils.ImageUtils
的使用

68 |
69 |
没有xuxu.autotest.utils.ImageUtils的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/utils/class-use/ReUtils.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 类 xuxu.autotest.utils.ReUtils的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

类 xuxu.autotest.utils.ReUtils
的使用

68 |
69 |
没有xuxu.autotest.utils.ReUtils的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/utils/class-use/ShellUtils.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 类 xuxu.autotest.utils.ShellUtils的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

类 xuxu.autotest.utils.ShellUtils
的使用

68 |
69 |
没有xuxu.autotest.utils.ShellUtils的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/utils/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xuxu.autotest.utils 8 | 9 | 10 | 11 | 12 |

xuxu.autotest.utils

13 |
14 |

15 | 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/utils/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xuxu.autotest.utils 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

程序包 xuxu.autotest.utils

68 |
69 |
70 |
    71 |
  • 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 |
    类概要 
    说明
    DataUtils 
    ImageUtils 
    ReUtils 
    ShellUtils 
    97 |
  • 98 |
99 |
100 | 101 |
102 | 103 | 104 | 105 | 106 | 116 |
117 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/utils/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xuxu.autotest.utils 类分层结构 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

程序包xuxu.autotest.utils的分层结构

68 | 程序包分层结构: 69 | 72 |
73 |
74 |

类分层结构

75 |
    76 |
  • java.lang.Object 77 | 83 |
  • 84 |
85 |
86 | 87 |
88 | 89 | 90 | 91 | 92 | 102 |
103 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /java/AdbForTest/doc/xuxu/autotest/utils/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 程序包 xuxu.autotest.utils的使用 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

程序包 xuxu.autotest.utils
的使用

68 |
69 |
没有xuxu.autotest.utils的用法
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/AndroidKeyCode.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest; 2 | 3 | public interface AndroidKeyCode { 4 | int POWER = 26; 5 | int BACK = 4; 6 | int HOME = 3; 7 | int MENU = 82; 8 | int VOLUME_UP = 24; 9 | int VOLUME_DOWN = 25; 10 | int SPACE = 62; 11 | int BACKSPACE = 67; 12 | int ENTER = 66; 13 | int MOVE_HOME = 122; 14 | int MOVE_END = 123; 15 | } 16 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/TestException.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest; 2 | 3 | @SuppressWarnings("serial") 4 | public class TestException extends RuntimeException { 5 | public TestException(String s) { 6 | super(s); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/XuImage.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileNotFoundException; 6 | import java.io.FileOutputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | import xuxu.autotest.utils.DataUtils; 12 | import xuxu.autotest.utils.ImageUtils; 13 | import xuxu.autotest.utils.ShellUtils; 14 | 15 | public class XuImage { 16 | private String tempFile = System.getProperty("java.io.tmpdir"); 17 | private String temp = new File(tempFile + "screenshot").getAbsolutePath(); 18 | 19 | private static XuImage image = null; 20 | 21 | public static XuImage getXuImage() { 22 | if (image == null) { 23 | image = new XuImage(); 24 | } 25 | 26 | return image; 27 | } 28 | 29 | private XuImage() { 30 | File dumpFile = new File(temp); 31 | if (!dumpFile.exists()) { 32 | dumpFile.mkdir(); 33 | } 34 | } 35 | 36 | /** 37 | * 截取屏幕 38 | */ 39 | public XuImage screenShot() { 40 | ShellUtils.getShellOut(ShellUtils 41 | .shell("screencap -p /data/local/tmp/temp.png")); 42 | ShellUtils.getShellOut(ShellUtils.cmd("pull /data/local/tmp/temp.png " 43 | + temp)); 44 | ShellUtils.shell("rm /data/local/tmp/temp.png"); 45 | return this; 46 | } 47 | 48 | /** 49 | * 截取指定矩形区域的图片 50 | * 51 | * @param uper_left_x 52 | * 矩形区域的左上角x坐标 53 | * @param uper_left_y 54 | * 矩形区域的左上角y坐标 55 | * @param low_right_x 56 | * 矩形区域的右下角x坐标 57 | * @param low_right_y 58 | * 矩形区域的右下角y坐标 59 | */ 60 | public XuImage getSubImage(int uper_left_x, int uper_left_y, int low_right_x, 61 | int low_right_y) { 62 | InputStream input = null; 63 | OutputStream out = null; 64 | try { 65 | input = new FileInputStream(new File(temp + "/temp.png").getAbsolutePath()); 66 | out = new FileOutputStream(new File(temp + "/sub_temp.png").getAbsolutePath()); 67 | ImageUtils.cutImage(input, out, "png", uper_left_x, uper_left_y, 68 | low_right_x - uper_left_x, low_right_y - uper_left_y); 69 | } catch (FileNotFoundException e) { 70 | e.printStackTrace(); 71 | } catch (IOException e) { 72 | e.printStackTrace(); 73 | } 74 | try { 75 | input.close(); 76 | out.close(); 77 | } catch (IOException e) { 78 | e.printStackTrace(); 79 | } 80 | 81 | File tmp = new File(new File(temp + "/temp.png").getAbsolutePath()); 82 | if (tmp.exists()) { 83 | tmp.delete(); 84 | } 85 | 86 | File sub_temp = new File(new File(temp + "/sub_temp.png").getAbsolutePath()); 87 | if (sub_temp.exists()) { 88 | sub_temp.renameTo(tmp); 89 | } 90 | 91 | return this; 92 | } 93 | 94 | /** 95 | * 将截屏文件与目标图片进行对比 96 | * 97 | * @param targetImagePath 98 | * 目标图片存储路径 99 | * @return 图片相同,返回true,否则返回false 100 | */ 101 | public boolean sameAs(String targetImagePath) { 102 | boolean result = false; 103 | try { 104 | result = ImageUtils.sameAs(targetImagePath, new File(temp + "/temp.png").getAbsolutePath(), 1.0); 105 | } catch (FileNotFoundException e) { 106 | e.printStackTrace(); 107 | } catch (IOException e) { 108 | e.printStackTrace(); 109 | } 110 | 111 | return result; 112 | } 113 | 114 | /** 115 | * 将截屏文件写入本地,以当前系统时间戳命名,格式为PNG 116 | * 117 | * @param path 118 | * 存储路径 119 | */ 120 | public void writeToFile(String path) { 121 | String oldPath = new File(temp + "/temp.png").getAbsolutePath(); 122 | copyFile(oldPath, new File(path + "/" + DataUtils.getCurrentSystemTime() 123 | + ".png").getAbsolutePath()); 124 | } 125 | 126 | private void copyFile(String oldPath, String newPath) { 127 | try { 128 | int byteRead = 0; 129 | File oldfile = new File(oldPath); 130 | if (oldfile.exists()) { 131 | InputStream inStream = new FileInputStream(oldPath); 132 | FileOutputStream fs = new FileOutputStream(newPath); 133 | byte[] buffer = new byte[1024 * 5]; 134 | while ((byteRead = inStream.read(buffer)) != -1) { 135 | fs.write(buffer, 0, byteRead); 136 | } 137 | inStream.close(); 138 | fs.close(); 139 | } 140 | } catch (IOException e) { 141 | e.printStackTrace(); 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/element/Element.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest.element; 2 | 3 | //坐标 4 | public class Element { 5 | private int x; 6 | private int y; 7 | 8 | public int getX() { 9 | return x; 10 | } 11 | 12 | public void setX(int x) { 13 | this.x = x; 14 | } 15 | 16 | public int getY() { 17 | return y; 18 | } 19 | 20 | public void setY(int y) { 21 | this.y = y; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/element/ElementAttribs.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest.element; 2 | 3 | public interface ElementAttribs { 4 | int TEXT = 0; 5 | int RESOURCE_ID = 1; 6 | int CLASS = 2; 7 | int CHECKED = 3; 8 | int CHECKABLE = 4; 9 | int CONTENTDESC = 5; 10 | int CLICKABLE = 6; 11 | int BOUNDS = 7; 12 | } 13 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/element/UiDump.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest.element; 2 | 3 | //存储解析xml文件后得到的属性值ֵ 4 | public class UiDump { 5 | private String text; 6 | private String resourceId; 7 | private String className; 8 | private String contentDesc; 9 | private String checkable; 10 | private String checked; 11 | private String clickable; 12 | private String bounds; 13 | 14 | public String getClassName() { 15 | return className; 16 | } 17 | 18 | public void setClassName(String className) { 19 | this.className = className; 20 | } 21 | 22 | public String getBounds() { 23 | return bounds; 24 | } 25 | 26 | public void setBounds(String bounds) { 27 | this.bounds = bounds; 28 | } 29 | 30 | public String getText() { 31 | return text; 32 | } 33 | 34 | public void setText(String text) { 35 | this.text = text; 36 | } 37 | 38 | public String getResourceId() { 39 | return resourceId; 40 | } 41 | 42 | public void setResourceId(String resourceId) { 43 | this.resourceId = resourceId; 44 | } 45 | 46 | public String getContentDesc() { 47 | return contentDesc; 48 | } 49 | 50 | public void setContentDesc(String contentDesc) { 51 | this.contentDesc = contentDesc; 52 | } 53 | 54 | public String getCheckable() { 55 | return checkable; 56 | } 57 | 58 | public void setCheckable(String checkable) { 59 | this.checkable = checkable; 60 | } 61 | 62 | public String getChecked() { 63 | return checked; 64 | } 65 | 66 | public void setChecked(String checked) { 67 | this.checked = checked; 68 | } 69 | 70 | public String getClickable() { 71 | return clickable; 72 | } 73 | 74 | public void setClickable(String clickable) { 75 | this.clickable = clickable; 76 | } 77 | 78 | @Override 79 | public String toString() { 80 | return "UiDump [text=" + text + ", resourceId=" + resourceId 81 | + ", className=" + className + ", packageName=" 82 | + ", contentDesc=" + contentDesc + ", checkable=" + checkable 83 | + ", checked=" + checked + ", clickable=" + clickable 84 | + ", bounds=" + bounds + "]"; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/element/UiDumpService.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest.element; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.parsers.SAXParser; 10 | import javax.xml.parsers.SAXParserFactory; 11 | 12 | import org.xml.sax.Attributes; 13 | import org.xml.sax.SAXException; 14 | import org.xml.sax.helpers.DefaultHandler; 15 | 16 | //解析uidump.xml文件 17 | public class UiDumpService extends DefaultHandler { 18 | private List dumps = null; 19 | private UiDump dump = null; 20 | 21 | public List getDumps(InputStream xml) { 22 | 23 | SAXParserFactory factory = SAXParserFactory.newInstance(); 24 | SAXParser parser = null; 25 | try { 26 | parser = factory.newSAXParser(); 27 | } catch (ParserConfigurationException e) { 28 | e.printStackTrace(); 29 | } catch (SAXException e) { 30 | e.printStackTrace(); 31 | } 32 | UiDumpService handler = new UiDumpService(); 33 | try { 34 | parser.parse(xml, handler); 35 | } catch (SAXException e) { 36 | e.printStackTrace(); 37 | } catch (IOException e) { 38 | e.printStackTrace(); 39 | } 40 | 41 | return handler.getDumps(); 42 | } 43 | 44 | private List getDumps() { 45 | return dumps; 46 | } 47 | 48 | @Override 49 | public void startDocument() throws SAXException { 50 | dumps = new ArrayList(); 51 | } 52 | 53 | @Override 54 | public void startElement(String uri, String localName, String qName, 55 | Attributes attributes) throws SAXException { 56 | if ("node".equals(qName)) { 57 | dump = new UiDump(); 58 | dump.setText(attributes.getValue("text")); 59 | dump.setResourceId(attributes.getValue("resource-id")); 60 | dump.setClassName(attributes.getValue("class")); 61 | dump.setContentDesc(attributes.getValue("content-desc")); 62 | dump.setCheckable(attributes.getValue("checkable")); 63 | dump.setChecked(attributes.getValue("checked")); 64 | dump.setClickable(attributes.getValue("clickable")); 65 | dump.setBounds(attributes.getValue("bounds")); 66 | 67 | dumps.add(dump); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/utils/DataUtils.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest.utils; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Calendar; 5 | import java.util.Date; 6 | 7 | public class DataUtils { 8 | 9 | public static String getCurrentSystemTime() { 10 | //设置日期格式 11 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); 12 | // new Date()为获取当前系统时间 13 | String time = dateFormat.format(new Date()); 14 | 15 | return time; 16 | } 17 | 18 | public static String getCalendar() { 19 | 20 | Calendar calendar = Calendar.getInstance(); 21 | int year = calendar.get(Calendar.YEAR); 22 | int month = calendar.get(Calendar.MONTH) + 1; 23 | int day = calendar.get(Calendar.DATE); 24 | int hour = calendar.get(Calendar.HOUR); 25 | int minute = calendar.get(Calendar.MINUTE); 26 | int second = calendar.get(Calendar.SECOND); 27 | String time = year + "-" + month + "-" + day + "-" + hour + "-" 28 | + minute + "-" + second; 29 | 30 | return time; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/utils/ImageUtils.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest.utils; 2 | 3 | import java.awt.Rectangle; 4 | import java.awt.image.BufferedImage; 5 | import java.io.*; 6 | import java.util.Iterator; 7 | 8 | import javax.imageio.ImageIO; 9 | import javax.imageio.ImageReadParam; 10 | import javax.imageio.ImageReader; 11 | import javax.imageio.stream.ImageInputStream; 12 | 13 | public class ImageUtils { 14 | public static void cutJPG(InputStream input, OutputStream out, int x, 15 | int y, int width, int height) throws IOException { 16 | ImageInputStream imageStream = null; 17 | try { 18 | Iterator readers = ImageIO 19 | .getImageReadersByFormatName("jpg"); 20 | ImageReader reader = readers.next(); 21 | imageStream = ImageIO.createImageInputStream(input); 22 | reader.setInput(imageStream, true); 23 | ImageReadParam param = reader.getDefaultReadParam(); 24 | 25 | // System.out.println(reader.getWidth(0)); 26 | // System.out.println(reader.getHeight(0)); 27 | Rectangle rect = new Rectangle(x, y, width, height); 28 | param.setSourceRegion(rect); 29 | BufferedImage bi = reader.read(0, param); 30 | ImageIO.write(bi, "jpg", out); 31 | } finally { 32 | imageStream.close(); 33 | } 34 | } 35 | 36 | public static void cutPNG(InputStream input, OutputStream out, int x, 37 | int y, int width, int height) throws IOException { 38 | ImageInputStream imageStream = null; 39 | try { 40 | Iterator readers = ImageIO 41 | .getImageReadersByFormatName("png"); 42 | ImageReader reader = readers.next(); 43 | imageStream = ImageIO.createImageInputStream(input); 44 | reader.setInput(imageStream, true); 45 | ImageReadParam param = reader.getDefaultReadParam(); 46 | 47 | // System.out.println(reader.getWidth(0)); 48 | // System.out.println(reader.getHeight(0)); 49 | 50 | Rectangle rect = new Rectangle(x, y, width, height); 51 | param.setSourceRegion(rect); 52 | BufferedImage bi = reader.read(0, param); 53 | ImageIO.write(bi, "png", out); 54 | } finally { 55 | imageStream.close(); 56 | } 57 | } 58 | 59 | public static void cutImage(InputStream input, OutputStream out, 60 | String type, int x, int y, int width, int height) 61 | throws IOException { 62 | ImageInputStream imageStream = null; 63 | try { 64 | String imageType = (null == type || "".equals(type)) ? "jpg" : type; 65 | Iterator readers = ImageIO 66 | .getImageReadersByFormatName(imageType); 67 | ImageReader reader = readers.next(); 68 | imageStream = ImageIO.createImageInputStream(input); 69 | reader.setInput(imageStream, true); 70 | ImageReadParam param = reader.getDefaultReadParam(); 71 | Rectangle rect = new Rectangle(x, y, width, height); 72 | param.setSourceRegion(rect); 73 | BufferedImage bi = reader.read(0, param); 74 | ImageIO.write(bi, imageType, out); 75 | } finally { 76 | imageStream.close(); 77 | } 78 | } 79 | 80 | public static boolean sameAs(String targetImagePath, String myImagePath, 81 | double percent) throws FileNotFoundException, IOException { 82 | BufferedImage otherImage = ImageIO.read(new FileInputStream( 83 | targetImagePath)); 84 | BufferedImage myImage = ImageIO.read(new FileInputStream( 85 | myImagePath)); 86 | 87 | if (otherImage.getWidth() != myImage.getWidth()) { 88 | return false; 89 | } 90 | if (otherImage.getHeight() != myImage.getHeight()) { 91 | return false; 92 | } 93 | 94 | // int[] otherPixel = new int[1]; 95 | // int[] myPixel = new int[1]; 96 | 97 | int width = myImage.getWidth(); 98 | int height = myImage.getHeight(); 99 | 100 | int numDiffPixels = 0; 101 | 102 | for (int y = 0; y < height; y++) { 103 | for (int x = 0; x < width; x++) { 104 | if (myImage.getRGB(x, y) != otherImage.getRGB(x, y)) { 105 | numDiffPixels++; 106 | } 107 | } 108 | } 109 | double numberPixels = (height * width); 110 | double diffPercent = numDiffPixels / numberPixels; 111 | return percent <= 1.0 - diffPercent; 112 | } 113 | } -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/utils/MonkeyScriptUtils.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest.utils; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.io.FileOutputStream; 6 | import java.io.IOException; 7 | 8 | public class MonkeyScriptUtils { 9 | private static String tempFile = System.getProperty("java.io.tmpdir"); 10 | 11 | public static void writeScript(String param) { 12 | File file = null; 13 | try { 14 | file = createFile(); 15 | } catch (IOException e) { 16 | e.printStackTrace(); 17 | } 18 | 19 | StringBuffer sb = new StringBuffer(); 20 | sb.append("count= 1\n").append("speed= 1.0\n").append("start data >>\n").append(param); 21 | FileOutputStream out = null; 22 | try { 23 | out = new FileOutputStream(file); 24 | out.write(sb.toString().getBytes("utf-8")); 25 | } catch (FileNotFoundException e) { 26 | e.printStackTrace(); 27 | } catch (IOException e) { 28 | e.printStackTrace(); 29 | } finally { 30 | try { 31 | out.close(); 32 | } catch (IOException e) { 33 | e.printStackTrace(); 34 | } 35 | } 36 | 37 | ShellUtils.cmd("push " + file.getAbsolutePath() + " /data/local/tmp"); 38 | } 39 | 40 | private static File createFile() throws IOException { 41 | File file = new File(tempFile + "/monkey.txt"); 42 | if (file.exists()) { 43 | file.delete(); 44 | file.createNewFile(); 45 | } else { 46 | file.createNewFile(); 47 | } 48 | 49 | return file; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/utils/ReUtils.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.regex.Matcher; 5 | import java.util.regex.Pattern; 6 | 7 | public class ReUtils { 8 | public static ArrayList matchString(Pattern pattern, String str) { 9 | ArrayList result = new ArrayList(); 10 | Matcher mc = pattern.matcher(str); 11 | 12 | while (mc.find()) { 13 | result.add(mc.group()); 14 | } 15 | 16 | return result; 17 | } 18 | 19 | public static ArrayList matchInteger(Pattern pattern, String str) { 20 | ArrayList result = new ArrayList(); 21 | Matcher mc = pattern.matcher(str); 22 | 23 | while (mc.find()) { 24 | result.add(new Integer(mc.group().trim())); 25 | } 26 | 27 | return result; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java/AdbForTest/src/xuxu/autotest/utils/ShellUtils.java: -------------------------------------------------------------------------------- 1 | package xuxu.autotest.utils; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.BufferedReader; 5 | import java.io.IOException; 6 | import java.io.InputStreamReader; 7 | 8 | public class ShellUtils { 9 | public static Process cmd(String command) { 10 | //mac请使用adb的绝对路径 11 | return process("adb " + command); 12 | } 13 | 14 | public static Process shell(String command) { 15 | //mac请使用adb的绝对路径 16 | return process("adb shell " + command); 17 | // return process(command); 18 | } 19 | 20 | public static BufferedReader shellOut(Process ps) { 21 | BufferedInputStream in = new BufferedInputStream(ps.getInputStream()); 22 | BufferedReader br = new BufferedReader(new InputStreamReader(in)); 23 | 24 | return br; 25 | } 26 | 27 | public static String getShellOut(Process ps) { 28 | StringBuilder sb = new StringBuilder(); 29 | BufferedReader br = shellOut(ps); 30 | String line; 31 | 32 | try { 33 | while ((line = br.readLine()) != null) { 34 | // sb.append(line); 35 | sb.append(line + System.getProperty("line.separator")); 36 | } 37 | } catch (IOException e) { 38 | e.printStackTrace(); 39 | } 40 | 41 | try { 42 | br.close(); 43 | } catch (IOException e) { 44 | e.printStackTrace(); 45 | } 46 | 47 | return sb.toString().trim(); 48 | } 49 | 50 | private static Process process(String command) { 51 | Process ps = null; 52 | try { 53 | ps = Runtime.getRuntime().exec(command); 54 | } catch (IOException e) { 55 | e.printStackTrace(); 56 | } 57 | 58 | return ps; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /java/jar/Adb-For-Test-2015-12-24.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gb112211/Adb-For-Test/0b850dab28bc39777617ec7efd90b168502d2d3e/java/jar/Adb-For-Test-2015-12-24.jar -------------------------------------------------------------------------------- /java/jar/Adb-For-Test-source-2015-12-24.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gb112211/Adb-For-Test/0b850dab28bc39777617ec7efd90b168502d2d3e/java/jar/Adb-For-Test-source-2015-12-24.jar -------------------------------------------------------------------------------- /python/adbUtils/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | __author__ = "xuxu" 3 | -------------------------------------------------------------------------------- /python/adbUtils/utils/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | __author__ = "xuxu" -------------------------------------------------------------------------------- /python/adbUtils/utils/imageUtils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | 4 | ''' 5 | Created on 2015年4月28日 6 | 7 | @author: xuxu 8 | ''' 9 | 10 | #图片处理,需要PIL库 11 | 12 | import tempfile 13 | import os 14 | import shutil 15 | from PIL import Image 16 | 17 | from adbUtils import ADB 18 | 19 | PATH = lambda p: os.path.abspath(p) 20 | 21 | class ImageUtils(object): 22 | 23 | def __init__(self, device_id=""): 24 | """ 25 | 初始化,获取系统临时文件存放目录 26 | """ 27 | self.utils = ADB(device_id) 28 | self.tempFile = tempfile.gettempdir() 29 | 30 | def screenShot(self): 31 | """ 32 | 截取设备屏幕 33 | """ 34 | self.utils.shell("screencap -p /data/local/tmp/temp.png").wait() 35 | self.utils.adb("pull /data/local/tmp/iuniTemp.png %s" %self.tempFile).wait() 36 | 37 | return self 38 | 39 | def writeToFile(self, dirPath, imageName, form = "png"): 40 | """ 41 | 将截屏文件写到本地 42 | usage: screenShot().writeToFile("d:\\screen", "image") 43 | """ 44 | if not os.path.isdir(dirPath): 45 | os.makedirs(dirPath) 46 | shutil.copyfile(PATH("%s/temp.png" %self.tempFile), PATH("%s/%s.%s" %(dirPath, imageName, form))) 47 | self.utils.shell("rm /data/local/tmp/temp.png") 48 | 49 | def loadImage(self, imageName): 50 | """ 51 | 加载本地图片 52 | usage: lodImage("d:\\screen\\image.png") 53 | """ 54 | if os.path.isfile(imageName): 55 | load = Image.open(imageName) 56 | return load 57 | else: 58 | print "image is not exist" 59 | 60 | def subImage(self, box): 61 | """ 62 | 截取指定像素区域的图片 63 | usage: box = (100, 100, 600, 600) 64 | screenShot().subImage(box) 65 | """ 66 | image = Image.open(PATH("%s/temp.png" %self.tempFile)) 67 | newImage = image.crop(box) 68 | newImage.save(PATH("%s/temp.png" %self.tempFile)) 69 | 70 | return self 71 | 72 | #http://testerhome.com/topics/202 73 | def sameAs(self,loadImage): 74 | """ 75 | 比较两张截图的相似度,完全相似返回True 76 | usage: load = loadImage("d:\\screen\\image.png") 77 | screen().subImage(100, 100, 400, 400).sameAs(load) 78 | """ 79 | import math 80 | import operator 81 | 82 | image1 = Image.open(PATH("%s/temp.png" %self.tempFile)) 83 | image2 = loadImage 84 | 85 | 86 | histogram1 = image1.histogram() 87 | histogram2 = image2.histogram() 88 | 89 | differ = math.sqrt(reduce(operator.add, list(map(lambda a,b: (a-b)**2, \ 90 | histogram1, histogram2)))/len(histogram1)) 91 | if differ == 0: 92 | return True 93 | else: 94 | return False -------------------------------------------------------------------------------- /python/adbUtils/utils/keycode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __author__ = "xuxu" 4 | 5 | POWER = 26 6 | BACK = 4 7 | HOME = 3 8 | MENU = 82 9 | VOLUME_UP= 24 10 | VOLUME_DOWN = 25 11 | SPACE = 62 12 | BACKSPACE = 67 13 | ENTER = 66 14 | MOVE_HOME = 122 15 | MOVE_END = 123 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /python/adbUtils/utils/logUtils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import time 5 | 6 | __author__ = "xuxu" 7 | 8 | PATH = lambda p: os.path.abspath(p) 9 | 10 | class Log(object): 11 | 12 | def __init__(self, logPath, fileName): 13 | self.path = logPath 14 | self.fileName = fileName 15 | 16 | if not os.path.isdir(self.path): 17 | os.makedirs(self.path) 18 | 19 | self.logFile = file(PATH("%s/%s" %(self.pathself.fileName)), "a") 20 | 21 | def info(self, info): 22 | 23 | timestamp = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) 24 | self.logFile.write("INFO : %s %s\n" %(timestamp, str(info))) 25 | self.logFile.flush() 26 | 27 | def debug(self,debugInfo): 28 | 29 | timestamp = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) 30 | self.logFile.write("DEBUG: %s %s\n" %(timestamp, str(debugInfo))) 31 | self.logFile.flush() 32 | 33 | def error(self, errorInfo): 34 | 35 | timestamp = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) 36 | self.logFile.write("ERROR: %s %s\n" %(timestamp, str(errorInfo))) 37 | self.logFile.flush() 38 | 39 | def close(self): 40 | self.logFile.close() 41 | -------------------------------------------------------------------------------- /python/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from distutils.core import setup 4 | 5 | setup( 6 | name='AdbForTest', 7 | version='20180517', 8 | packages=['adbUtils', 'adbUtils.utils'], 9 | url='https://github.com/gb112211/Adb-For-Test', 10 | license='1.0', 11 | author='xuxu', 12 | author_email='274925460@qq.com', 13 | description='' 14 | ) 15 | --------------------------------------------------------------------------------