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追加顯示字元串