package Modules;
import Config.button;
import Config.module_config;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import uiautomatorrpc.UiDevice;
import uiautomatorrpc.UiObject;
import uiautomatorrpc.UiSelector;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* Created by qiumin on 2015/8/14.
*/
public class module {
private HashMap<String, button> buttons;
private module_config config;
public Logger logger= LogManager.getLogger(this.getClass());
private final Marker MARKER = MarkerManager.getMarker("MODULE");
public UiDevice device=UiDevice.getInstance();
public Marker get_mark(){return MARKER;}
public void set_map(){
this.buttons=config.set_map();
}
public void set_cfg(module_config cfg) throws Exception{
this.config=cfg;
set_map();
}
public String get_pkg2_cfg(){return config.get_pkg2();}
public String get_pkg_cfg(){return config.get_pkg();}
public String get_apk_name(){return config.get_apk_name();}
public String get_attr(String name){
return this.config.get_attr(name);
}
public module_config.method_sel get_sel(String name){return this.config.get_sel(name);}
public button get_button(String name) throws Exception{
if(buttons.containsKey(name)) {
//logger.debug(MARKER,"'{}' is exist in config map.",name);
return buttons.get(name);
}else{
logger.error(MARKER,"The '{}' is not in config map.",name);
throw new Exception();
}
}
public void print_cfg(){
config.print_cfg();
}
public void open_apk() throws Exception{
boolean find=false;
logger.info(MARKER,"apk name is '{}'",config.name);
try {
find = scroll_find(config.name, false);
find = new UiObject(new UiSelector().text(config.name)).exist();
logger.info("find is {}",find);
if(!find){
for(int i=0;i<15;i++){
device.swipe(585, 360, 180, 360, 20);
find = new UiObject(new UiSelector().text(config.name)).exist();
if(find){
logger.info("finally find apk,click it");
click_button(new UiObject(new UiSelector().text(config.name)));
this.clicks("D1");
return;
}
logger.info("open-apk : {}",i);
}
}else {
logger.info("Click open apk");
click_button(new UiObject(new UiSelector().text(config.name)));
}
}catch (Exception e){
logger.error(MARKER," can't find '{}' .",config.name);
throw e;
} catch (Throwable e) {
e.printStackTrace();
logger.error(MARKER," ~ can't find '{}' .",config.name);
}
}
public void check_if_terminated() throws Exception{
clicks("D5");
String real_pkg=get_current_pkg();
if(real_pkg.contains(config.pkg)){
logger.info(MARKER, "The package name is correct. this apk is running correctly.");
}else {
logger.error(MARKER,"The package name is not correct (real({}) vs expect({})), this apk is not running correctly.",real_pkg,config.pkg);
throw new Exception();
}
}
public void clicks(String btns_in) throws Exception{
String [] btns=btns_in.split("\\|");
logger.debug(Arrays.toString(btns));
for(String btn : btns){
if(btn.contains("D")){
String a=btn.replace("D","");
int n=Integer.parseInt(a);
Thread.sleep(1000*n);
logger.info(MARKER,"Wait for "+n+" seconds.");
}
else if(btn.equals("HOME")){
press_home();
}
else if(btn.equals("BACK")){
press_back();
}
else if(btn.equals("CALL")){
press_call();
}
else if(btn.equals("CAMERA")){
press_camera();
}
else if(btn.equals("NOTIFY")){
open_notification();
}
else if(btn.equals("WAKE")){
wakup();
}
else{
click_button(btn);
}
}
}
public void click_button(String name) throws Exception{
button btn=get_button(name);
UiObject click_obj=button_to_uiobject(btn);
boolean b=button_exist(click_obj);
if(b) {
try {
click_obj.click();
logger.info(MARKER, "Try to click the button '{}' ", name);
// if (!a) {
// throw new Exception();
// }
} catch (Throwable throwable) {
logger.error(MARKER, "Click button '{}'failed.", name);
throw new Exception(throwable);
}
}else{
logger.error(MARKER,"'{}' is configed,but not exist..",name);
throw new Exception();
}
}
public void click_button(button btn) throws Exception{
UiObject click_obj=button_to_uiobject(btn);
boolean b=button_exist(click_obj);
if(b) {
try {
click_obj.click();
logger.info(MARKER, "Try to click the button '{}' ", btn.attribute);
// if (!a) {
// throw new Exception();
// }
} catch (Throwable throwable) {
logger.error(MARKER, "Click button '{}'failed.", btn.attribute);
throw new Exception(throwable);
}
}else{
logger.error(MARKER,"'{}' is configed,but not exist..",btn.attribute);
throw new Exception();
}
}
public void click_button(UiObject obj) throws Exception{
boolean b=button_exist(obj);
if(b) {
try {
obj.click();
logger.info(MARKER, "Try to click a UiObject.");
// if (!a) {
// throw new Exception();
// }
} catch (Throwable throwable) {
logger.error(MARKER, "Click a UiObject Failed.");
throw new Exception(throwable);
}
}else{
logger.error(MARKER,"This uiobject is not exist.");
throw new Exception();
}
}
public void write_button(String name,String text) throws Exception{
button btn=get_button(name);
UiObject write_obj=button_to_uiobject(btn);
boolean b=button_exist(write_obj);
if(b) {
try {
boolean a = write_obj.setText(text);
logger.info(MARKER, "Try to write '" + text + "' in button :" + name);
if (!a) {
throw new Exception();
}
} catch (Throwable throwable) {
logger.error(MARKER, "Write in button '" + name + "'failed.");
throw new Exception(throwable);
}
}else{
logger.error(MARKER,"'{}' is configed,but not exist..",name);
throw new Exception();
}
}
public void write_button(button btn,String text) throws Exception{
UiObject write_obj=button_to_uiobject(btn);
boolean b=button_exist(write_obj);
if(b) {
try {
boolean a = write_obj.setText(text);
logger.info(MARKER, "Try to write '{}' in button : '{}'", text, btn.attribute);
if (!a) {
throw new Exception();
}
} catch (Throwable throwable) {
logger.error(MARKER, "Write in button '{}'failed.", btn.attribute);
throw new Exception(throwable);
}
}else{
logger.error(MA
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
软件开发设计:PHP、QT、应用软件开发、系统软件开发、移动应用开发、网站开发C++、Java、python、web、C#等语言的项目开发与学习资料 硬件与设备:单片机、EDA、proteus、RTOS、包括计算机硬件、服务器、网络设备、存储设备、移动设备等 操作系统:LInux、IOS、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 网络与通信:数据传输、信号处理、网络协议、网络与通信硬件、网络安全网络与通信是一个非常广泛的领域,它涉及到计算机科学、电子工程、数学等多个学科的知识。 云计算与大数据:数据集、包括云计算平台、大数据分析、人工智能、机器学习等,云计算是一种基于互联网的计算方式,通过这种方式,共享的软硬件资源和信息可以按需提供给计算机和其他设备。
资源推荐
资源详情
资源评论
收起资源包目录
基于Uiautomator的Android系统测试工具.zip (365个子文件)
${sys 0B
module.class 37KB
base_phone.class 35KB
module.class 35KB
UiSelector.class 12KB
UiSelector.class 12KB
test1.class 11KB
test.class 10KB
base_testcase.class 9KB
UiDevice.class 9KB
base_testcase.class 8KB
UiDevice.class 8KB
Configs.class 8KB
Calculator.class 7KB
base_phone.class 7KB
Configs.class 7KB
Calculate.class 6KB
UiObject.class 6KB
UiObject.class 6KB
Phone_cfg.class 5KB
Phone_cfg.class 5KB
Phone_L676.class 4KB
Call.class 4KB
Messaging_cfg.class 4KB
Messaging_cfg.class 4KB
Call.class 4KB
JsonRpcService.class 4KB
JsonRpcService.class 4KB
module_config.class 4KB
Email_cfg.class 4KB
Email_cfg.class 4KB
module_config.class 3KB
Calculator_cfg.class 3KB
Calculator_cfg.class 3KB
Example.class 3KB
Example.class 3KB
Calendar_cfg.class 3KB
Calendar_cfg.class 3KB
Music_cfg.class 3KB
Music_cfg.class 3KB
Recorder_cfg.class 2KB
Recorder_cfg.class 2KB
Files_cfg.class 2KB
Files_cfg.class 2KB
Contacts_cfg.class 2KB
Contacts_cfg.class 2KB
Call_cfg.class 2KB
Call_cfg.class 2KB
Browser_cfg.class 2KB
Browser_cfg.class 2KB
AdbOperation.class 2KB
Clock_cfg.class 2KB
Clock_cfg.class 2KB
AdbOperation.class 2KB
button.class 2KB
Downloads_cfg.class 2KB
Downloads_cfg.class 2KB
button.class 2KB
Gallery_cfg.class 1KB
Gallery_cfg.class 1KB
JsonRpcServerThread.class 1KB
case06_creditcardbanner.class 1KB
JsonRpcServerThread.class 1KB
case07_creditcardtop5.class 1KB
case02_company_report.class 1KB
case03_person_report.class 1KB
MTBF_case01_contact.class 1KB
case01_download.class 1KB
case04_dishonest.class 1KB
case05_enforce.class 1KB
case08_login.class 1KB
MTBF_case32_camera10.class 1KB
MTBF_case23_camera1.class 1KB
MTBF_case26_camera4.class 1KB
MTBF_case25_camera3.class 1KB
MTBF_case27_camera5.class 1KB
MTBF_case29_camera7.class 1KB
MTBF_case28_camera6.class 1KB
MTBF_case31_camera9.class 1KB
MTBF_case30_camera8.class 1KB
MTBF_case20_recorder.class 1KB
MTBF_case24_camera2.class 1KB
MTBF_case09_email3.class 1KB
MTBF_case33_calculator.class 1KB
MTBF_case10_email4.class 1KB
MTBF_case08_email2.class 1KB
MTBF_case14_browser4.class 1KB
MTBF_case16_browser6.class 1KB
MTBF_case13_browser3.class 1KB
MTBF_case17_browser7.class 1KB
MTBF_case15_browser5.class 1KB
MTBF_case12_browser2.class 1KB
MTBF_case07_email1.class 1KB
MTBF_case18_calendar.class 1KB
MTBF_case22_files.class 1KB
MTBF_case11_browser1.class 1KB
MTBF_case19_clock.class 1KB
MTBF_case21_music.class 1KB
MTBF_case04_sms2.class 1KB
MTBF_case06_mms2.class 1KB
共 365 条
- 1
- 2
- 3
- 4
资源评论
妄北y
- 粉丝: 2w+
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 货箱底板焊接工艺分析.pdf
- 三菱FX3U 3轴控制 fx3u PLC,3轴控制,以太网扩展模块,用于与主站PLC通讯,梯形图编程(非结构化编程),程序3千多步 资料包含: 1.PLC程序 2.触摸屏程序(威纶) 3.CAD图纸
- 机车车辆碰撞仿真焊接关系模拟方法.pdf
- 机器人点焊在汽车座椅骨架焊接的应用.pdf
- 机动车辆零部件的表面焊接 - .pdf
- 机器人在压力机机身自动焊接中的应用 - .pdf
- 机器人在其他焊接方法方面的应用注意点 - .pdf
- 机械式双金属复合管焊接过程数值模拟.pdf
- 机械振动焊接对残余应力的影响及机理分析.pdf
- java网上购物系统源代码.zip
- 基地焊接焊轨质量控制关键环节探索.pdf
- 基于3σ法的压力容器焊接质量控制系统的研究.pdf
- 基于ADAMS的电容器引线焊接机送丝机构运动学分析.pdf
- 基于Android系统的焊接应用软件设计 - .pdf
- 基于ANSYS的焊接箱形梁裂纹断裂分析.pdf
- 基于ANSYS的大型焊接卷筒稳定性分析.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功