- 1、本文档共18页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Robotium实现滑动解锁
1. 测试滑动解锁功能,比较的简单,方法如下;2. 首先根据屏幕坐标,画出9个圆圈区域的中心位置;3. 1-9区域位置相对于滑动解锁View的区域位置是;位置1 : x = 1/6, y = 1/6位置2 : x = 3/6, y = 1/6位置3 : x = 5/6, y = 1/6位置4 : x = 1/6, y = 3/6位置5 : x = 3/6, y = 3/6位置6 : x = 5/6, y = 3/6位置7 : x = 1/6, y = 5/6位置8 : x = 3/6, y = 5/6位置9 : x = 5/6, y = 5/6上面讲了这么多了,来实现一个具体例子吧4. ?要实现下图的滑动解锁,就让我们来写代码;5. 创建一个viewFetcher类,具体使用函数,?touchLock(String viewID, int ... step )?package com.example.abc.test;import java.util.ArrayList;import com.robotium.solo.*;import android.app.Activity;import android.app.Instrumentation;import android.os.SystemClock;import android.util.Log;import android.view.MotionEvent;import android.view.View;import android.view.ViewGroup;import android.widget.EditText;import android.widget.NumberPicker;public class ViewFetcher {? Solo solo; private final Instrumentation inst;? public ViewFetcher(Solo solo, Instrumentation inst) { this.solo = solo; this.inst = inst; }? public View getChildView(View view, int id, String viewClass) { View view1 = null; ArrayListView viewList = new ArrayListView(); if(view != null) {? ViewGroup viewGroup = (ViewGroup) view; for(int i = 0; i viewGroup.getChildCount(); i++) {? final View child = viewGroup.getChildAt(i); String temp = child.getClass().getName().toString();? temp = temp.substring(temp.lastIndexOf(.) +1, temp.length()); if(temp.equals(viewClass)) { viewList.add(child); }? }? if(idviewList.size()-1) { return view1; } else { view1 = viewList.get(id); } } return view1; }? public View getViewById(String id) {? View view = null;? if( id == ) { return view; } try { Activity act = solo.getCurrentActivity();// 获取当前Activity int id1 = act.getResources().getIdentifier(id, id, solo.getCurrentActivity().getPackageName());// 获取id view = solo.getView(id1);// 得到View } catch (Exception ex) { Log.e(Exception, ex.getMessage()); } return view;? }? public boolean clickById(String id) { View view = getViewById(id);? if( view == null) { return false; }? solo.clickOnView(view); return true; } public View getChildViewByID(
您可能关注的文档
最近下载
- 2025自考00155中级财务会计试卷及答案解释.docx VIP
- 一种利用小分子诱导多能干细胞向心肌细胞分化的方法.pdf VIP
- BS EN 1644-1-1997 Test methovens. 国外国际规范.pdf VIP
- 机械原理第七版.pdf VIP
- 2024年高二化学学业水平测试题.doc VIP
- 在线网课学习课堂《人工智能与生物特征识别(北理 )》单元测试考核答案.pdf VIP
- 病人化疗后的心理护理.pptx VIP
- 外研版九年级英语上册全册同步练习题及参考答案.pdf VIP
- 电子科技大学20春《计算机网络基础》期末考试试卷及答案.docx VIP
- 干熄焦考试题库及答案.pdf VIP
文档评论(0)