1. android压力测试工具有哪些,各有什么特点。有文档更好,兄弟我想研究下。
最近在Android程序测试过程中接触到了自动化测试方法,对其中的一些工具、方法和框架做了一些简单的整理,其中包括android测试框架、CTS、Monkey、Monkeyrunner其它test tool等等。因接触时间很短,很多地方有不足之处,希望能和大家多多交流和指点在这里简单对monkey做简单的介绍吧。
一、 什么是Monkey
Monkey是Android中的一个命令行工具,可以运行在模拟器里或实际设备中。它向系统发送伪随机的用户事件流(如按键输入、触摸屏输入、手势输入等),实现对正在开发的应用程序进行压力测试。Monkey测试是一种为了测试软件的稳定性、健壮性的快速有效的方法。
二、 Monkey的特征
1、测试的对象仅为应用程序包,有一定的局限性。
2、 Monky测试使用的事件流数据流是随机的,不能进行自定义。
3、可对MonkeyTest的对象,事件数量,类型,频率等进行设置。
三、Monkey的基本用法
基本语法如下:
$ adb shell monkey [options]
如果不指定options,Monkey将以无反馈模式启动,并把事件任意发送到安装在目标环境中的全部包。下面是一个更为典型的命令行示例,它启动指定的应用程序,并向其发送1500个伪随机事件:
$ adb shell monkey -p your.package.name -v 1500
$ monkey -p(package的意思) 指定文件名 -v(测试的次数和频率) number(次数)
四、Monkey测试的一个实例
通过这个实例,我们能理解Monkey测试的步骤以及如何知道哪些应用程序能够用Monkey进行测试。
Windows下(注:2—4步是为了查看我们可以测试哪些应用程序包,可省略):
1、 通过eclipse启动一个Android的emulator
2、 在命令行中输入:adb devices查看设备连接情况
C:\Documents and Settings\Administrator>adb devices
List of devices attached
emulator-5554 device
3、 在有设备连接的前提下,在命令行中输入:adb shell 进入shell界面
C:\Documents and Settings\Administrator>adb shell
#
4、 查看data/data文件夹下的应用程序包。注:我们能测试的应用程序包都在这个目录下面
C:\Documents and Settings\Administrator>adb shell
# ls data/data
ls data/data
com.google.android.btrouter
com.android.providers.telephony
com.android.mms
com.android.providers.downloads
com.android.deskclock
com.android.email
com.android.providers.media
com.android.settings
jp.co.omronsoft.openwnn
com.android.providers.userdictionary
com.android.quicksearchbox
com.android.protips
com.android.browser
com.android.launcher
com.android.term
com.android.speechrecorder
com.android.server.vpn
com.android.defcontainer
com.svox.pico
com.android.customlocale
com.android.development
com.android.soundrecorder
com.android.providers.drm
com.android.spare_parts
com.android.providers.downloads.ui
com.android.fallback
com.android.providers.applications
com.android.netspeed
com.android.wallpaper.livepicker
android.tts
com.android.htmlviewer
com.android.music
com.android.certinstaller
com.android.inputmethod.pinyin
com.android.providers.subscribedfeeds
com.android.inputmethod.latin
com.android.gallery
com.android.systemui
com.android.contacts
com.android.phone
com.android.sdksetup
com.android.calculator2
com.android.packageinstaller
com.android.camera
com.android.providers.settings
com.thestore.main
com.android.providers.contacts
5、 以com.android.camera作为对象进行MonkeyTest
#monkey -p com.android.camera -v 500
其中-p表示对象包 –v 表示事件数量
运行过程中,Emulator中的应用程序在不断地切换画面。
按照选定的不同级别的反馈信息,在Monkey中还可以看到其执行过程报告和生成的事件。
注:具体参数的设定可参考:
http://developer.android.com/guide/developing/tools/monkey.html
五、关于Monkey测试的停止条件
Monkey Test执行过程中在下列三种情况下会自动停止:
1、如果限定了Monkey运行在一个或几个特定的包上,那么它会监测试图转到其它包的操作,并对其进行阻止。
2、如果应用程序崩溃或接收到任何失控异常,Monkey将停止并报错。
3、如果应用程序产生了应用程序不响应(application not responding)的错误,Monkey将会停止并报错。
通过多次并且不同设定下的Monkey测试才算它是一个稳定性足够的程序。
2. 怎样安装插件android-dpi-calculator
DPI表示分辨率,指每英寸长度上的点数.DPI又可细分为水平分辨率和垂直分辨率;修改/system/build.prop文件,修改ro.sf.lcd_density的值,默认是ro.sf.lcd_density=320。修改后保存退出,重启。安卓手机的屏幕分辨率如今也已然达到了这2K的程度,通过修改这手机的dpi可以控制这程序在屏幕上显示的数量,而且字体也会有一定的变化,有兴趣的的用户可以试一试。
3. 难道就没有好用的安卓计算器软件了吗
好用的安卓计算器有许多,如:
1.科学计算器
科学计算器是一款体积小巧、功能十分简洁的科学计算器,它支持多行输入,用户可输入完整计算公式进行运算。它可以用于科学计算,包括不同进制数的转换。它的界面设计十分人性化,采用与物理科学计算器几乎相同的界面,帮助用户快速进入运算。
4. 为什么Android系统应用更新不是让新apk替换进入/system分区
这里涉及到两个问题:odex和第三方制作的Gapps刷机包
买来一个android设备,没有root前都是这样子的:
只要不是内地的android设备基本都会搭载google提供的一系列android手机的应用,大家会叫它Gapps,GMS什么的。这一批应用包含了表面的从gmail到youtube到play service到背后的公共用途的软件包,以及很多framework和本地代码动态运行库及其它内容。
当然其中大部分可执行代码都以dex这种可以由dalvik这个java虚拟机执行的的形式存在,具体的说,是以odex的形式存在。
dalvik在运行dex之前,需要做一系列验证,确保dex里头的代码是符合规范,是能安全执行的,dalvik做完检查后,将dex做一些处理(比如调整,加校验位等),就变成了odex。实际上在dalvik里头运行的是odex。
所以,正式发售的设备的内置应用程序,都是以***.apk加上同名的***.odex存在的。
因为这种机制,把一对apk/odex放到另一台不同(具体)型号的设备里是没法运行的。
而google不允许包括CM在内的第三方rom里内置Gapps。Gapps是收费的私有软件。
所以,目前想到的办法是借助smali等开源工具做deodex,将odex转化成可以通用的dex。这样重新打包了Gapps后,才能作为刷机包塞到别的设备中
-----------------------------------
google会不会对gapps进行升级?
显然是的,一部分的升级会通过play store进行,比如更新play store本身,装一个google play service(这个apk实际上是一个供第三方应用程序的API合集,有了它才能在第三方应用中使用google maps的矢量地图,通过google+登陆等项目)
另外一部分则要通过设备的OTA做,因为这个更新实在太大了,同一个手机,从android4.0升级到android4.1时,可能每一个Gapps的文件都需要替换,而且android安装应用程序的机制说到底只能改变apk文件,但它动不了framework,library,所以这些东西的更新需要借助OTA等通过bootloader许可直接修改system分区的手段
在第三方打包好的gapps里就能发现,gapps有很多很多的版本
我觉得刷gapps的原则是,首先gapps要适配设备当前android的大版本,给4.1用的gapps就不应该刷到4.0系统里,使用intel处理器的尤其要注意,这个gapps是不是给x86设备的,Z24x0/27x0只能有限度地翻译arm代码,把arm设备的gapps给x86设备用,可能会导致系统根本无法启动;然后越新打包出来的gapps问题可能会越少。
5. 安卓计算器 怎么看历史记录
1,可以指定activity的名字来启动.
比如在android2.1中,可以通过一下代码启动:
Intent intent = new Intent();
intent.setClassName("com.android.calculator2", "com.android.calculator2.Calculator");
startActivity(intent);
2,通过Logcat,马上就能知道class name,关键是如何指定初始值和如何获取计算结果
6. Android Studio 修改包名 com.example.calculator----->com.melon.calculator
1. 第一步点击如图1所示的“show Options menu"
图1
2.第二步点击如图2所示”Compact Empty Middle Packages" ,去掉前面的钩
图2
3.第三步这时候你会发现你的包名由图3变成了图4的模样
图3
图4
4.第四步就可以进行一一修改了,选中想要修改的包名部分目录,Shift + F6 ,在弹出框选择Rename Package,稍等一会,可以看到包名已经发生了变化。
5.修改完以后,最后一步,需要手动修改工程 build.gradle文件中的applicationId改为跟你的包名一致即可。
6.把AndroidManifest.xml里的包名换成刚换的包名。
7. android中怎么实现计算器
用代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvResult"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:height="50dp"
android:text="@string/tvResult"
/>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/btnBackspace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="150dp"
android:layout_marginLeft="10dp"
android:text="@string/btnbackspace"/>
<Button
android:id="@+id/btnCE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="150dp"
android:text="@string/btnCE"/>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:width="75dp"
android:text="@string/btn7"/>
<Button
android:id="@+id/btn8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn8"/>
<Button
android:id="@+id/btn9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn9"/>
<Button
android:id="@+id/btnDiv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnDiv"/>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:width="75dp"
android:text="@string/btn4"/>
<Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn5"/>
<Button
android:id="@+id/btn6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn6"/>
<Button
android:id="@+id/btnMul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnMul"/>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:width="75dp"
android:text="@string/btn1"/>
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn2"/>
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn3"/>
<Button
android:id="@+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnAdd"/>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:width="75dp"
android:text="@string/btn0"/>
<Button
android:id="@+id/btnC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnC"/>
<Button
android:id="@+id/btnEqu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnEqu"/>
<Button
android:id="@+id/btnSub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnSub"/>
</LinearLayout>
</LinearLayout>
——————————————————————————————————————————————
8. android 怎么调用系统自带计算器
我以前也遇到这个问题
但是只能用这个方法去调用计算器,高版本的系统会秒退,原因是要在
androidmanifest里增加个权限
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
Intent mIntent = new Intent();
mIntent.setClassName("com.android.calculator2","com.android.calculator2.Calculator");
startActivity(mIntent);
9. 如何查看android计算器的历史记录
1,可以指定activity的名字来启动.
比如在android2.1中,可以通过一下代码启动:
Intent intent = new Intent();
intent.setClassName("com.android.calculator2", "com.android.calculator2.Calculator");
startActivity(intent);
2,通过Logcat,马上就能知道class name,关键是如何指定初始值和如何获取计算结果
10. 用android制作计算器,布局和实现写好,但是点击Button按钮,却不在edittext编辑框
监听按钮的点击,将该按钮代表的内容,比如数字5设置给文本框,setText即可,但是问题来了,第二次setText会覆盖上次的,其实还有个方法append追加显示字符串