发布新日志

  • 连接VPN后就不能上网怎么办?

    2010-08-09 16:12:42

    转自:http://hi.baidu.com/foxman0330/blog/item/f64704dcd9b3f8df8c10290b.html
    一般情况下,连接VPN后,你会发现本地就不能再上网了.如何改变这种让人不爽的状况呢?教你一个方法:1.双击打开VPN的连接图标 ,点属性;

    2.再选网络选项卡下面的tcp/ip,

    3.点属性出现下面的对话框:

    4.点高级;

    5.默认的情况下,这边有一个小勾,去掉就行了,这样你连接VPN后,照样可以上网.


  • Android 模拟器之 Market 安装

    2010-07-14 10:57:21

    转载:http://blog.23corner.com/2010/06/16/%E7%AA%AE%E4%BA%BA-android-%E9%96%8B%E7%99%BC%E8%80%85%E6%B8%AC%E8%A9%A6-donut-%E7%89%88%E6%9C%AC-market-%E5%95%8F%E9%A1%8C%E7%9A%84%E6%96%B9%E6%B3%95/

    Android 開發者最頭痛的莫過於程式在 Market 上找不到, 偏偏這問題又無法在自個兒的開發手機上重現, 再加上 Programmer 都很窮 (?) 沒法把出問題的手機通通買回來測, 最後只好忍痛放棄那些殷殷企盼的使用者. 當然網路上有不少這類問題的解法, 痛過一次之後身體就會牢牢記住那些地雷, 似乎往後也沒有厚著臉皮到處借錢買手機的必要. 俗話說工欲善其事, 必先利其器, 如果有便宜又好用的方法可以測試自己的程式, 那再好不過. 小的在這邊提供一個很簡單又便宜的方法讓開發者可以反覆的測, 直到網路斷線為止.

    1. 由於最常出問題的是 Donut 版本 (1.6) 與 QVGA, 所以請先在電腦上安裝 1.6 SDK, 並建立一個 QVGA 的 avd.
    2. 接著到 HTC Developer 網站抓 Android Dev Phone 1 的 1.6 System Image (目前的檔名是 signed-dream_devphone_userdebug-img-14721.zip)
    3. 解開下載的 image 將 system.img 放在 avd 目錄下. Windows 使用者可以在 C:\Documents and Settings\<user>\.android\ 找到你所建立的 avd 目錄, Mac 使用者則可在 ~/.android/avd 找到.
    4. 最後啟動 Emulator, 開機後輸入 Google 帳號相關資料, 即可快樂使用 Donut 的 Market.
    1.5 也可以用類似的方法, 至於 2.0 之後 ? 我再找找.. :-

    在2.1上的安装方法

    1.5, 1.6 之前的版本可以參考上一篇文章, 這邊提供 2.1 的方法, 其實只要 GMS 有修改, 使用方式都會不太一樣, 不過原理大同小異. :-)

    要在 Emulator 上跑 Android Market 有幾點要注意:

    1. 首先要有相對映版本的 Google Android Mobile Service, 通常網路上可以找得到 (GoogleBits-sdk7)
    2. Emulator 的 default partition size 似乎是 66MB, 但是後來的版本 system.img 都超過這個 size, 導致開啟後用 df 查看 free space 都是 0. 所以在啟動 emulator 時, 得加上 -partition-size 96 產生 free space 塞檔案.
    3. Emulator 不會啟動 Google check in service, 少了它便無法登錄 Google 帳號, 所以得先啟動 emulator, 透過 adb pull /system/build.prop 將設定檔案取回, 將 ro.config.nocheckin=yes 這行移除, 再依照後面提到的步驟放回去.

    做好前述步驟, 便可開始進行下一階段工作.

    1. 切換至 avd 的目錄, 將 <sdk_dir>/platforms/android-7/images/system.img 複製過來, 印象中不這麼做資料無法寫入, 而且萬一做錯了得重新 Download 一份 SDK 才能救回, 所以保險起見還是分開使用.
    2. 啟動 Emulator, 別忘了加上 -partition-size 96 這個參數.
    3. 此時可以開啟 ddms 觀察是否啟動完全 (log 停止不再吐出來) 接著執行 adb remount 讓 system partition 可以寫入資料.
    4. 將先前修改的 build.prop 塞回去: adb push build.prop /system/
    5. 解開 Googlebits 那包壓縮檔, 將 system 目錄下列檔案塞入 Emulator 裡
    6. adb push etc/permissions/com.google.android.datamessaging.xml /system/etc/permissions/
      adb push etc/permissions/com.google.android.gtalkservice.xml /system/etc/permissions/
      adb push framework/com.google.android.gtalkservice.jar /system/framework/
      adb push app/EnhancedGoogleSearchProvider.apk  /system/app
      adb push app/GoogleCheckin.apk /system/app
      adb push app/GoogleApps.apk  /system/app
      adb push app/gtalkservice.apk  /system/app
      adb push app/SetupWizard.apk  /system/app
      adb push app/Vending.apk  /system/app
      adb push app/TalkProvider.apk  /system/app
    7. 將 SdkSetup.apk (adb shell rm /system/app/SdkSetup.apk)移除, 這樣重開後就會直接執行 SetupWizard
    8. 關閉 Emulator.
    9. 刪除 cache.img 與 userdata-qemu.img (如果你的avd是通过SDK创建的,C:\Documents and Settings\<user>\.android\ 找到你所建立的 avd 目錄; 如果是通过命令行的行式创建的,找到创建avd时的路径<avd_dir>)
    10. 重新啟動 Emulator, 大功告成 !

    啟動後會出現 SetupWizard, 登入 Google 帳號後即可使用 Android Market ! :D

    2010-06-17 Updated: 2.2 的作法似乎更簡單, 首先可以從 MoDaCo 的論壇上找一下 Froyo 的 ROM, 接下來步驟同前述, 第 5 步裡面塞的 apk 換成 GoogleServicesFramework.apk 與 Vending.apk 即可 ! 看來 dependency 沒這麼複雜囉..



  • 如何保存Sikuli执行结果

    2010-05-12 14:58:43

    目前在进行基于ANDROID手机平台的软件进行测试,原来以为没有可以自动化的工具,后来公司的CTO推荐了一款软件Sikuli(http://sikuli.org/index.shtml),这款软件可以借助ANDROID模拟器来完成自动化的测试.

    1. 具体的使用步骤请参见: http://sikuli.org/documentation.shtml
    2. 使用SIKULI的一些技巧请参见:引用自http://foolab.spaces.live.com/blog/cns!AF96E3E01D4605AA!222.entry

    一些特别注意事项

    1. 为了提高有效性 你应该尽量使用find进行处理
        在使用find时可以使用setAutoWaitTimeout进行超时设置,之后根据返回结果
        进行错误处理
    2. 在选取图像时应该尽量包含能够更容易区分其它相似区域的图像部分
       
    3. 为了进一步提高查找精确性可以先查找某个大的区域,在查找其子区域如:
        item = find(img).inside().find(img)
    4. 为了进行选择查找,可以使用图像集合操作 如:
        set=[img1,img2,…]
        for item in set:
         if find(item):
          break
    5. 可以使用jython支持的大部分库,记得在最前面添加导入,如使用操作xml
        from xml.dom import minidom
        xmldoc = minidom.parse(filename)
    6. 测试时为了中断后续操作记住使用 Ctrl + Shift + C
    7. 在使用Key 类成员时记得使用”+”连接,不要混淆KEY_ALT…等使用”,”分割
        不然将导致程序中断
    8. 在window下可以使用Sikuli-IDE.bat name.skl 命令行方式运行脚本
    9. 保存目录下存在很多不使用的png文件等所有设计完成可以使用另存其它文件名,这样将只保存有效的文件。
    10. 在window 下采用  type(Key.F4,KEY_ALT) 关键当前窗口是个不错的选择
    11. 你可以首先查找特定醒目项,之后根据信息构造新的Match对象,偏移一定距离定位新的位置 如:
       item = find(img)
       click(Match(item.getX(),item.getY(),10,20,1.0))

    3. 我们一直使用SIKULI IDE 来执行测试, 使用IDE执行测试的弊端是测试结果没有办法保存下来,下次执行就会把上次的执行结果覆盖掉, 如何将测试的结果保存下来呢?
    事前准备: SIKULI IDE安装好.
    (1)方案一:在测试脚本中加入print语句来导出except
    参见:https://answers.launchpad.net/sikuli/+question/107729

    In the IDE:
    you can use print to get some information:

    print find(img) # gives some info on the match object

    or more general
    m = find(img); print find.region # save match in m and print it using the last match saved in find.region

    you can say:

    print "checkpoint charly: ", m # prints a text and the match

    .... many possibilities, that can be extended, by all the things that can be done with python.

    When saving the script. as an .skl (executable) running it from commandline, your prints will go to sysout that can be piped to a file to save the run.


    (2)方案二:使用PYTHON的UNITTEST来运行测试,并将结果保存下来.
    参见:https://answers.launchpad.net/sikuli/+question/100436

    Running tests using Python's unittest

    The following method works on Mac and Windows.

    1) Write a real unit test using PyUnit.

    import sys
    import unittest
    setAutoWaitTimeout(5000)

    class MyTests(unittest.TestCase):
       def setUp(self):
          switchApp("/Applications/Safari.app")
          # @todo: do similar for IE on Windows

       def tearDown(self):
          pass

       def testNewTab(self):
          type("t", KEY_META)
          type("https://answers.launchpad.net/sikuli/+question/99979\n")
          m = find("sikuli-logo.png")
          assert(m is not None and m.getScore() > 0.9)

    suite = unittest.TestLoader().loadTestsFromTestCase(MyTests)
    unittest.TextTestRunner(verbosity=2).run(suite)

    2) Save your unit test as a Python script. in a folder with a matching name and .sikuli suffix (e.g., mytest.sikuli/mytest.py).

    3) Download the cross-platform, command line tool version of Sikuli from http://groups.csail.mit.edu/uid/sikuli/download.shtml.(目前这个地址没有下载command line tool的链接了,你可以从我的附件中下载)

    4) Extract the contents of the command line tool zip.

    On Windows:

    4) Download the Windows IDE version of Sikuli.

    5) Extract the Lib/ folder from the sikuli-ide-full.jar.

    6) Move the Lib/ folder into the same directory as the sikuli-script.jar from the command line tool version of Sikuli.

    7) Execute your test script. like so (assuming cygwin):

    export PATH=$PATH:./win32
    java -Dpython.path=Lib/ -jar sikuli-script.jar mytest.sikuli 2> test-output.log

    8) The test-output.log contains the results of the unit test run while stdout shows the sikuli logging info.

    On Mac:

    4) Download the Mac IDE version of Sikuli.

    5) Extract the Lib/ folder from the Sikuli.app/Contents/Resources/Java/sikuli-script.jar.

    6) Move the Lib/ folder into the same directory as the sikuli-script.jar from the command line tool version of Sikuli.

    7) Execute your test script. like so:

    java -d32 -Dpython.path=Lib/ -jar sikuli-script.jar mytest.sikuli 2> test-output.log

    8) The test-output.log contains the results of the unit test run while stdout shows the sikuli logging info.


     但上述的方法我始终没有运行成功,因为系统总是报以下错误:
    java.io.IOException: Unable to find library META-INF/lib/VDictProxy.dll on classpath
        at com.wapmx.nativeutils.jniloader.DefaultJniExtractor.extractResource(DefaultJniExtractor.java:95)
        at com.wapmx.nativeutils.jniloader.DefaultJniExtractor.extractJni(DefaultJniExtractor.java:81)
        at com.wapmx.nativeutils.jniloader.NativeLoader.loadLibrary(NativeLoader.java:43)
        at edu.mit.csail.uid.VDictProxy.<clinit>(VDictProxy.java:18)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.python.core.SyspathJavaLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.python.core.Py.findClassEx(Unknown Source)
        at org.python.core.SysPackageManager.findClass(Unknown Source)
        at org.python.core.PackageManager.findClass(Unknown Source)
        at org.python.core.SysPackageManager.findClass(Unknown Source)
        at org.python.core.PyJavaPackage.__findattr__(Unknown Source)
        at org.python.core.imp.importFromAs(Unknown Source)
        at org.python.core.imp.importFrom(Unknown Source)
        at python.edu.mit.csail.uid.Sikuli$py.f$0(D:\Testtools\sikuli\sikuli-script\sikuli-script.jar\Lib/python/edu/mit/csail/uid/Sikuli.py:11)
        at python.edu.mit.csail.uid.Sikuli$py.call_function(D:\Testtools\sikuli\sikuli-script\sikuli-script.jar\Lib/python/edu/mit/csail/uid/Sikuli.py)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyCode.call(Unknown Source)
        at org.python.core.imp.createFromCode(Unknown Source)
        at org.python.core.imp.createFromSource(Unknown Source)
        at org.python.core.ZipFileImporter$ZipFileLoader.load_module(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.python.core.PyReflectedFunction.__call__(Unknown Source)
        at org.python.core.PyMethod.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.imp.loadFromLoader(Unknown Source)
        at org.python.core.imp.find_module(Unknown Source)
        at org.python.core.PyModule.impAttr(Unknown Source)
        at org.python.core.imp.import_next(Unknown Source)
        at org.python.core.imp.import_logic(Unknown Source)
        at org.python.core.imp.import_name(Unknown Source)
        at org.python.core.imp.importName(Unknown Source)
        at org.python.core.ImportFunction.load(Unknown Source)
        at org.python.core.ImportFunction.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.__builtin__.__import__(Unknown Source)
        at org.python.core.imp.importAll(Unknown Source)
        at org.python.pycode._pyx0.f$0(<string>:1)
        at org.python.pycode._pyx0.call_function(<string>)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyCode.call(Unknown Source)
        at org.python.core.Py.runCode(Unknown Source)
        at org.python.core.Py.exec(Unknown Source)
        at org.python.util.PythonInterpreter.exec(Unknown Source)
        at edu.mit.csail.uid.ScriptRunner.runPython(ScriptRunner.java:29)
        at edu.mit.csail.uid.SikuliScript.main(SikuliScript.java:754)
    java.io.IOException: Unable to find library META-INF/lib/ScreenMatchProxy.dll on classpath
        at com.wapmx.nativeutils.jniloader.DefaultJniExtractor.extractResource(DefaultJniExtractor.java:95)
        at com.wapmx.nativeutils.jniloader.DefaultJniExtractor.extractJni(DefaultJniExtractor.java:81)
        at com.wapmx.nativeutils.jniloader.NativeLoader.loadLibrary(NativeLoader.java:43)
        at edu.mit.csail.uid.ScreenMatchProxy.<clinit>(ScreenMatchProxy.java:11)
        at edu.mit.csail.uid.SikuliScript.<init>(SikuliScript.java:105)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.python.core.PyReflectedConstructor.__call__(Unknown Source)
        at org.python.core.PyJavaInstance.__init__(Unknown Source)
        at org.python.core.PyJavaClass.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at python.edu.mit.csail.uid.Sikuli$py.f$0(D:\Testtools\sikuli\sikuli-script\sikuli-script.jar\Lib/python/edu/mit/csail/uid/Sikuli.py:15)
        at python.edu.mit.csail.uid.Sikuli$py.call_function(D:\Testtools\sikuli\sikuli-script\sikuli-script.jar\Lib/python/edu/mit/csail/uid/Sikuli.py)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyCode.call(Unknown Source)
        at org.python.core.imp.createFromCode(Unknown Source)
        at org.python.core.imp.createFromSource(Unknown Source)
        at org.python.core.ZipFileImporter$ZipFileLoader.load_module(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.python.core.PyReflectedFunction.__call__(Unknown Source)
        at org.python.core.PyMethod.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.imp.loadFromLoader(Unknown Source)
        at org.python.core.imp.find_module(Unknown Source)
        at org.python.core.PyModule.impAttr(Unknown Source)
        at org.python.core.imp.import_next(Unknown Source)
        at org.python.core.imp.import_logic(Unknown Source)
        at org.python.core.imp.import_name(Unknown Source)
        at org.python.core.imp.importName(Unknown Source)
        at org.python.core.ImportFunction.load(Unknown Source)
        at org.python.core.ImportFunction.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.__builtin__.__import__(Unknown Source)
        at org.python.core.imp.importAll(Unknown Source)
        at org.python.pycode._pyx0.f$0(<string>:1)
        at org.python.pycode._pyx0.call_function(<string>)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyCode.call(Unknown Source)
        at org.python.core.Py.runCode(Unknown Source)
        at org.python.core.Py.exec(Unknown Source)
        at org.python.util.PythonInterpreter.exec(Unknown Source)
        at edu.mit.csail.uid.ScriptRunner.runPython(ScriptRunner.java:29)
        at edu.mit.csail.uid.SikuliScript.main(SikuliScript.java:754)
    java.io.IOException: Unable to find library META-INF/lib/Win32Util.dll on classpath
        at com.wapmx.nativeutils.jniloader.DefaultJniExtractor.extractResource(DefaultJniExtractor.java:95)
        at com.wapmx.nativeutils.jniloader.DefaultJniExtractor.extractJni(DefaultJniExtractor.java:81)
        at com.wapmx.nativeutils.jniloader.NativeLoader.loadLibrary(NativeLoader.java:43)
        at edu.mit.csail.uid.Win32Util.<clinit>(Win32Util.java:10)
        at edu.mit.csail.uid.SikuliScript.<init>(SikuliScript.java:111)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.python.core.PyReflectedConstructor.__call__(Unknown Source)
        at org.python.core.PyJavaInstance.__init__(Unknown Source)
        at org.python.core.PyJavaClass.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at python.edu.mit.csail.uid.Sikuli$py.f$0(D:\Testtools\sikuli\sikuli-script\sikuli-script.jar\Lib/python/edu/mit/csail/uid/Sikuli.py:15)
        at python.edu.mit.csail.uid.Sikuli$py.call_function(D:\Testtools\sikuli\sikuli-script\sikuli-script.jar\Lib/python/edu/mit/csail/uid/Sikuli.py)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyCode.call(Unknown Source)
        at org.python.core.imp.createFromCode(Unknown Source)
        at org.python.core.imp.createFromSource(Unknown Source)
        at org.python.core.ZipFileImporter$ZipFileLoader.load_module(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.python.core.PyReflectedFunction.__call__(Unknown Source)
        at org.python.core.PyMethod.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.imp.loadFromLoader(Unknown Source)
        at org.python.core.imp.find_module(Unknown Source)
        at org.python.core.PyModule.impAttr(Unknown Source)
        at org.python.core.imp.import_next(Unknown Source)
        at org.python.core.imp.import_logic(Unknown Source)
        at org.python.core.imp.import_name(Unknown Source)
        at org.python.core.imp.importName(Unknown Source)
        at org.python.core.ImportFunction.load(Unknown Source)
        at org.python.core.ImportFunction.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.__builtin__.__import__(Unknown Source)
        at org.python.core.imp.importAll(Unknown Source)
        at org.python.pycode._pyx0.f$0(<string>:1)
        at org.python.pycode._pyx0.call_function(<string>)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyCode.call(Unknown Source)
        at org.python.core.Py.runCode(Unknown Source)
        at org.python.core.Py.exec(Unknown Source)
        at org.python.util.PythonInterpreter.exec(Unknown Source)
        at edu.mit.csail.uid.ScriptRunner.runPython(ScriptRunner.java:29)
        at edu.mit.csail.uid.SikuliScript.main(SikuliScript.java:754)
    test_01_emailVal (main.callspark736) ... ERROR
    test_02_emailVal2 (main.callspark736) ... ERROR
    test_03_emailVal3 (main.callspark736) ... ERROR
    test_04_emailVal4 (main.callspark736) ... ERROR
    test_05_passwordVal (main.callspark736) ... ERROR
    test_06_passwordVal2 (main.callspark736) ... ERROR
    test_07_loginSuc (main.callspark736) ... ERROR
    test_08_loginFail (main.callspark736) ... ERROR
    test_09_loginFail2 (main.callspark736) ... ERROR
    test_10_duplication (main.callspark736) ... ERROR
    test_11_location (main.callspark736) ... ERROR
    test_12_about (main.callspark736) ... ERROR
    test_13_back (main.callspark736) ... ERROR
    test_14_LoginSearch (main.callspark736) ... ERROR
    test_15_AnoSearch (main.callspark736) ... ERROR
    test_16_profileLinked (main.callspark736) ... ERROR
    test_17_profileEdit (main.callspark736) ... ERROR
    test_18_searchIcon (main.callspark736) ... ERROR
    test_19_errorMes1 (main.callspark736) ... ERROR

    ======================================================================
    ERROR: test_01_emailVal (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "e:\project\callspark\callspark736.sikuli\callspark736.py", line 19, in setUp
        wait("callicon.png")
      File "D:\Testtools\sikuli\sikuli-script\sikuli-script.jar\Lib/python/edu/mit/csail/uid/Sikuli.py", line 293, in wait
    java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: edu.mit.csail.uid.ScreenMatchProxy.screenMatch(Ljava/lang/String;Ljava/lang/String;DI)[Ledu/mit/csail/uid/Match;

    ......
    ----------------------------------------------------------------------
    Ran 19 tests in 10.969s

    FAILED (errors=19)

     查了一下原因,是因为在COMMAND LINE TOOL中的sikuli-script.jar包/META-INF/lib文件夹中缺少了
    3个dll(
    VDictProxy.dll,Win32Util.dll,ScreenMatchProxy.dll)文件.
     尝试将
    sikuli-script.jar解压,然后将缺少的三个DLL文件拷贝到META-INF/lib文件夹中,然后重新生成sikuli-script.jar包, 然后再次按上述步骤来执行脚本,结果报找不到SIKULI-SCRIPT类错误.
     后续待研究..

    (3)方案三:使用command line命令来运行脚本.
    • 首先用SIKULI IDE 打开脚本,然后按以下格式进行调整

    import unittest
    setBundlePath("full path to your saved youNameIt.sikuli") # tells the Sikuli functions where to find the pictures(此处应特别注意,如果你不给出路径,在执行的过程中SIKULI会从临时文件夹中找图片,在执行过程中会报出无法LOAD图片的错误(can't lode file ***.png))
    class MyTests(unittest.TestCase):
       def setUp(self):
          switchApp("Safari")
          # on Windows: e.g. switchApp("google"), to switch to a running Chrome Browser

       def tearDown(self):
          pass

       def testNewTab(self):
          type("t", KEY_CMD) # Win: KEY_CTRL (KEY_META. gives Error)
          paste("https://answers.launchpad.net/sikuli/+question/100436") # this question ;-)
          type(Key.ENTER) # no errors with Key class in .skl
          m = find(<image>) # the captured Sikuli logo
          assert(m is not None and m.getScore() > 0.9)

    suite = unittest.

    TestLoader().loadTestsFromTestCase(MyTests)#注意MyTests需要替换成自己脚本的类名
    unittest.TextTestRunner(verbosity=2).run(suite)

    • 然后单击FILE-EXPORT Executable 命令导出.skl格式的文件.
    • 打开命令行窗口,并定位到SIKULI IDE的安装目录,然后执行以下命令来运行脚本和输出结果

    D:\Testtools\sikuli\sikuli-script> Sikuli-IDE.bat E:\MyTests.skl 2> E:\test-outlog.txt
    • 等整个测试执行完毕后,你可以从log文件中看到以下信息

    test_01_emailVal (main.callspark736) ... ERROR
    test_02_emailVal2 (main.callspark736) ... ERROR
    test_03_emailVal3 (main.callspark736) ... ERROR
    test_04_emailVal4 (main.callspark736) ... ERROR
    test_05_passwordVal (main.callspark736) ... ERROR
    test_06_passwordVal2 (main.callspark736) ... ERROR
    test_07_loginSuc (main.callspark736) ... ERROR
    test_08_loginFail (main.callspark736) ... ERROR
    test_09_loginFail2 (main.callspark736) ... ERROR
    test_10_duplication (main.callspark736) ... ERROR
    test_11_location (main.callspark736) ... ok
    test_12_about (main.callspark736) ... ERROR
    test_13_back (main.callspark736) ... ERROR
    test_14_LoginSearch (main.callspark736) ... ERROR
    test_15_AnoSearch (main.callspark736) ... ERROR
    test_16_profileLinked (main.callspark736) ... ERROR
    test_17_profileEdit (main.callspark736) ... ERROR
    test_18_searchIcon (main.callspark736) ... ERROR
    test_19_errorMes1 (main.callspark736) ... ERROR

    ======================================================================
    ERROR: test_01_emailVal (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 41, in test_01_emailVal
        assertExist(Pattern("email.png").similar(0.80))
    NameError: assertExist

    ======================================================================
    ERROR: test_02_emailVal2 (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 58, in test_02_emailVal2
        assertExist(Pattern("email.png").similar(0.80))
    NameError: assertExist

    ======================================================================
    ERROR: test_03_emailVal3 (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 77, in test_03_emailVal3
        assertExist(Pattern("email.png").similar(0.80))
    NameError: assertExist

    ======================================================================
    ERROR: test_04_emailVal4 (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 100, in test_04_emailVal4
        assertExist(Pattern("email.png").similar(0.80))
    NameError: assertExist

    ======================================================================
    ERROR: test_05_passwordVal (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 117, in test_05_passwordVal
        assertExist("passwordnotmatch.png")
    NameError: assertExist

    ======================================================================
    ERROR: test_06_passwordVal2 (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 134, in test_06_passwordVal2
        assertExist("passwordatleast6.png")
    NameError: assertExist

    ======================================================================
    ERROR: test_07_loginSuc (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 153, in test_07_loginSuc
        assertExist("logoutpal.png")
    NameError: assertExist

    ======================================================================
    ERROR: test_08_loginFail (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 162, in test_08_loginFail
        if find("emailnoword.png").inside().find("black.png"):
    AttributeError: 'NoneType' object has no attribute 'inside'

    ======================================================================
    ERROR: test_09_loginFail2 (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 182, in test_09_loginFail2
        if find("emailnoword.png").inside().find("black.png"):
    AttributeError: 'NoneType' object has no attribute 'inside'

    ======================================================================
    ERROR: test_10_duplication (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 210, in test_10_duplication
        assertExist("sameuser.png")
    NameError: assertExist

    ======================================================================
    ERROR: test_12_about (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 232, in test_12_about
        assertExist("aboutpal.png")
    NameError: assertExist

    ======================================================================
    ERROR: test_13_back (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 246, in test_13_back
        assertExist("searchtext.png")
    NameError: assertExist

    ======================================================================
    ERROR: test_14_LoginSearch (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 256, in test_14_LoginSearch
        if find("emailnoword.png").inside().find("black.png"):
    AttributeError: 'NoneType' object has no attribute 'inside'

    ======================================================================
    ERROR: test_15_AnoSearch (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 282, in test_15_AnoSearch
        assertExist("bing.png")
    NameError: assertExist

    ======================================================================
    ERROR: test_16_profileLinked (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 293, in test_16_profileLinked
        if find("emailnoword.png").inside().find("black.png"):
    AttributeError: 'NoneType' object has no attribute 'inside'

    ======================================================================
    ERROR: test_17_profileEdit (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 323, in test_17_profileEdit
        if find("emailnoword.png").inside().find("black.png"):
    AttributeError: 'NoneType' object has no attribute 'inside'

    ======================================================================
    ERROR: test_18_searchIcon (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 353, in test_18_searchIcon
        assertExist("searchtext.png")
    NameError: assertExist

    ======================================================================
    ERROR: test_19_errorMes1 (main.callspark736)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "D:\Program Files\Sikuli\sikuli-ide-full.jar\Lib/unittest.py", line 213, in __call__
      File "F:\temp\tmp-1723462100.sikuli\callspark737.sikuli\callspark737.py", line 363, in test_19_errorMes1
        assertExist("nosearcherr.png")
    NameError: assertExist

    ----------------------------------------------------------------------
    Ran 19 tests in 864.156s

    FAILED (errors=18)

  • 如何在两个模拟器之间互发短信和互通电话

    2010-05-05 13:54:10

    目前在测试ANDROID手机互发短信和互通电话的功能.

    原来一直以为ANDROID模拟器没有办法实现这2个功能,所以一直都是有真实的手机发送短信和互通电话的,所以我的电话费也是哗哗的往下掉.

    后来试着在网上搜索一下看看可否通过2个模拟器来实现互发短信和互通电话的功能,功夫不负有心人,还真被我找到了.

    1. 互通电话:
    (1) 先在一台机器上打开两个模拟器(没有试过在不同机器上,有时间再研究),两个模拟器有不同的端口号,端口号可以在模拟器上的右上角找到(默认的是5554,打开2个模拟器时,系统会自动找不同的端口号)

    (2) 打开打电话的程序,拔打端口号即可.
    2. 互发短信:
    (1) 同上
    (2)打开MESSAGE程序,在To输入端口号即可.

    3. 如图


  • 转载:向Android模拟器打电话和发短消息

    2010-05-04 18:30:51

    转自 http://www.13com.net/article/article.asp?articleid=1041

    在开发Android程序的时候,我们往往需要处理来电或者短消息,但是在开发过程中基本都是通过模拟器来进行调试,那么下面我们就介绍一下如何向模拟器打电话和发短信。

    首先在Eclipse中点击菜单Windows->Open perspective->DDMS进入DDMS视图:

    然后在DDMS视图的Emulator Control视窗中,Incoming number框内填入电话号码(随便填),选择Voice,然后点击Call按钮。

    模拟器上即可显示来自Incoming number的电话呼叫。

    然后在Emulator Tools中选择SMS,并填写短消息内容,然后点击Send按钮。

    相应的模拟器上就会收到来自Incoming number发送的该短消息。

    当然,如果觉得这个方法太麻烦,也可以用命令行的方式来完成上述操作,先通过命令行telnet localhost 5554,进入Android Console,然后就可以使用命令进行一些操作,拨打电话和发送短消息是使用gsm和sms命令。gsm和sms两个命令的参数如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    gsm
    allows you to change GSM-related settings, or to make a new inbound phone call

    available sub-commands:
        list             list current phone calls
        call             create inbound phone call
        busy             close waiting outbound call as busy
        hold             change the state of an oubtound call to 'held'
        accept           change the state of an outbound call to 'active'
        cancel           disconnect an inbound or outbound phone call
        data             modify data connection state
        voice            modify voice connection state
        status           display GSM status
    sms
    allows you to simulate an inbound SMS

    available sub-commands:
        send             send inbound SMS text message
        pdu              send inbound SMS PDU

    完成上述一个电话呼叫和短信的完整命令是:

    1
    2
    gsm call 13908888888
    sms send 13908888888 "this is a test sms!"
  • Selenium timeout

    2010-04-29 13:59:02

    在使用SELENIUM RC进行测试时,总是会发现在打开网页的过程中TIMEOUT 30000MS的错误提示.

    这是因为打开网页时有一个默认的超时限制,更改这个默认值的命令是:

    selenium.set_timeout("60000")

    这个值最好是放在SetUP方法中.

    Some comments:

    • You don't need a wait_for_page_to_load after an open, that will cause you timeouts because once the page is loaded after the opeen, it will start waiting again and the page will not be loading.
    • Most of the failures you get from selenium (timeouts, object not found) can be caught with try-except statements
    • You should set the timeout in your tests withing the test itself (using set_timeout), that way it doesn't depend on the way you start the server, it will always wait the time you wanted
  • Selenium timeout

    2010-04-29 13:59:02

    在使用SELENIUM RC进行测试时,总是会发现在打开网页的过程中TIMEOUT 30000MS的错误提示.

    这是因为打开网页时有一个默认的超时限制,更改这个默认值的命令是:

    selenium.set_timeout("60000")

    这个值最好是放在SetUP方法中.

    Some comments:

    • You don't need a wait_for_page_to_load after an open, that will cause you timeouts because once the page is loaded after the opeen, it will start waiting again and the page will not be loading.
    • Most of the failures you get from selenium (timeouts, object not found) can be caught with try-except statements
    • You should set the timeout in your tests withing the test itself (using set_timeout), that way it doesn't depend on the way you start the server, it will always wait the time you wanted
  • Selenium1.0.1+Firefox3.6+Unable to delete parent.lock file

    2010-04-21 19:25:53

    工具: selenium RC 1.0.1 + Junit
    被测试浏览器:Firefox3.6
    在执行脚本过程中遇到如下问题
    java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Unable to delete file F:\temp\customProfileDir62d458aab59f4972a95342789f4262b8\parent.lock
        at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:89)
        at firefox.Registerfailed.setUp(Registerfailed.java:14)
        at junit.framework.TestCase.runBare(TestCase.java:128)
        at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:120)
        at junit.framework.TestSuite.runTest(TestSuite.java:228)
        at junit.framework.TestSuite.run(TestSuite.java:223)
        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: Unable to delete file F:\temp\customProfileDir62d458aab59f4972a95342789f4262b8\parent.lock
        at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
        at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
        at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:262)
        at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:223)
        at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:81)
        ... 15 more

    分析问题:
     * 查看进程,有N个FIREFOX的进程在运行.
     * 查看了N次资料,好像是1.0.1与FIREFOX3.6不太兼容
    解决方案:
     * 下载最新的selenium 1.0.3可以实现也FIREFOX3.6的兼容
     * 第二种解决方案:这篇文档中的资料 (http://3lncr.wordpress.com/2010/03/04/selenium-rc-0-1-1-and-firefox-3-6-profile-issue/)

    3lncr's blog

    As simple as possible, but not any simpler…

    Firefox 3.6, Selenium 1.0.1 with selenium-rc-0.1.1 and “Lock file still present!” issue

    leave a comment »

    Have you just updated your shiny Firefox to version 3.6 and now you can’t make Selenium 1.0.1 (precisely: selenium-rc-0.1.1) working fine for you on this browser? Ooops… I got the same. :(

    Now, when you try to run one of your Selenium based UI tests on such a brand-new-and-up-to-date “combo” it just fails to start the browser and there is just some annoying exceptions in logs, similar to these:

    ERROR - Failed to start new browser session, shutdown browser and clear all session data java.lang.RuntimeException: Firefox refused shutdown while preparing a profile

    org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$
    FileLockRemainedException: Lock file still present! C:\DOCUME~1\{windows-username}\LOCALS~1\Temp\customProfileDir197b3da3c02244fb8407912c5e126b07\parent.lock

    Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: Unable to delete file C:\DOCUME~1\{windows-username}\LOCALS~1\Temp\customProfileDir197b3da3c02244fb8407912c5e126b07\parent.lock

    There is a cure. A bit hacky, but still worth to try, if you really need to use Firefox 3.6.

    So do some search through your project dependencies JARs and find selenium-server.jar item. Unzip it, find all (of 5) “install.rdf” files inside this JAR (they are under customProfileDirCUSTFF and customProfileDirCUSTFFCHROME subfolders), open them in some text editing tool (they are XML based configuration files) and replace the max version of agent (browser) application from line like this:

    <em:maxVersion>3.5.*</em:maxVersion>

    into this:

    <em:maxVersion>3.6.*</em:maxVersion>

    Or just download customized selenium-server.jar (pathed, as above, to Firefox 3.6.*) from this place.

    Note: If you are using Grails with Selenium plugin (selenium-rc-0.1.1), you can find selenium-server.jar in your project plugins folder (e.g. {user-home}\.grails\{grails-version}\projects\{project-name}\plugins\selenium-rc-0.1.1\lib\server)

    Where:
    {user-home} stands for user home folder, e.g. C:\DOCUME~1\johndoe or C:\Users\johndoe
    {grails-version} is Grails version, e.g. 1.1
    {project-name} is your Grails project name, e.g. test-project

    Done. It should work now!



  • 转载:Deleting Temporary Files Painlessly

    2010-04-21 09:48:50

       Deleting Temporary Files Painlessly

    http://www.hardwarehell.com/articles/bootclean.shtml

    See Addendum  for Windows XP, ME and 2000

    This article is not intended to be a DOS lesson or tutorial, but to show you a simple and painless way that I help keep my drive free from useless file clutter. There are other command variations to do this, however, this is what I have found to work best for me. This article assumes that you already have a basic knowledge of DOS commands, the autoexec.bat file and the consequences of typos and the incorrect use of wildcards.

    The temporary internet files folder, history folder and cookies folder contain a file called index.dat. Windows uses index.dat to keep a coded record of the files in the folder where it resides. Windows will NOT let you delete index.dat! If you delete the files in these folders through any Windows method, you are still left with the index.dat containing all the info you thought you just deleted. So much for deleting your tracks! This file can become completely bloated, not to mention corrupted, since it won't match the actual files in the folder. The index.dat file can only be deleted in DOS and are included in your cleanup using the DELTREE command.

    All modifications are done in the autoexec.bat file. This is my preference so that these files are deleted each time I boot. The autoexec.bat file is not required after Windows 3.1. If you do not have this file in the root directory of your C:\ drive, just create it in Notepad (make sure that the "Word Wrap" option is OFF) and save as autoexec.bat. The file could actually be saved as "whatever_you_want_to_name.bat" file, but would have to be ran manually and in DOS mode. (Not a DOS window)

    If I ever use Netscape, (far and few between) I have the cache files directed to my C:\Windows\Temporary Internet Files location rather than adding yet another directory to clean. If you use a Netscape browser, your cache files may be in the default location at: C:\Program Files\Netscape\users\username\cache (or whatever drive Netscape is installed) Just add another DELTREE line with the path where they can be found.

    Here is a copy of my autoexec.bat file with explanation of the commands below. The grayed out lines are what existed before I added the cleanup routine. (Yes, I know neither is necessary, but I have my own reasons) Make sure you change any paths where your files may be kept in different folders than mine and delete out any lines of folders you decide not to have cleaned up.


    "my" autoexec.bat File

    @ECHO OFF
    rem - By Windows Setup - c:\windows\command\mscdex.exe /D:aspicd0 /M:12 /L:I
    PATH=%PATH%;
    if exist c:\windows\smartdrv.exe c:\windows\smartdrv.exe 2048 16
    DELTREE /y c:\windows\history\*.* > NUL
    DELTREE /y c:\windows\tempor~1\*.* > NUL
    DELTREE /y c:\windows\temp\*.* > NUL
    DELTREE /y c:\windows\cookies\*.* > NUL
    DELTREE /y c:\windows\applic~1\micros~1\office\recent\*.* > NUL
    DELTREE /y c:\windows\ShellIconCache
    if exist del c:\windows\ff*.tmp
    if exist del c:\windows\system\advert.dll


    Explanations of autoexec.bat commands

    @ECHO OFF suppresses the "command" from displaying on the screen. Normally, when commands are executed from a batch file, they are displayed on the screen.  

    if exist is a conditional command that says if the file exists, load it. If it does not exist, no big deal, no error message and the command is ignored.

    smartdrv.exe is a standard disk cache used to speed things up. It's not needed for Windows, like the old days, but sure speeds things up in DOS. Parameters are the amount of memory in Kb to use.

    DELTREE allows you to delete a directory even if it contains files and subdirectories or has hidden, system or read-only attributes. 

    /Y Suppresses a prompt to confirm the deletion.

    *.*  delete all the files and subdirectories but leave the directory itself. This saves adding an additional command line to recreate the folder. 

    > NUL instruction disables output to the screen as your computer boots. Without it, error messages about "files not found" and a file by file line as each file is being deleted.. If a folder is already empty, you would also get an error message. If you would like to see exactly what is going on, just delete the > NUL part.

    ShellIconCache is a hidden file in the Windows directory that stores icon cache files. Just like the temporary internet files folder, it becomes very unproductive when the file gets too big. This file can become very bloated and corrupted. (example: black, odd looking icons) If it doesn't seem to work, try replacing ShellIconCache with shelli~1.

    if exist del c:\windows\ ff*.tmp deletes garbage files that Office leaves behind, if they exist.

    if exist del c:\windows\system\ advert.dll deletes the spyware file (advert.dll) that many demo programs install with their program. This file is always secretly loaded and running on your system. It reports ALL of your online activities back to the originator.

    NOTE: Some program installations that require a reboot, may be using the temp folder to store files needed to complete installation upon the reboot. (98lite is one) If so, just put a REM before the DELTREE /y c:\windows\temp\*.* > NUL line. After the installation, go back and remove the REM.

    See Addendum  for Windows XP, ME and 2000

    Also, we have a great thread going on the subject here. A lot is covered here that I keep seeing in the same emails again and again.


    Reader Andy, pointed out another line to add, that I hadn't since I have these files deleted on shutdown with a registry tweak. Thanks, Andy.

    DELTREE /y c:\windows\recent\*.* > NUL


    Reader Robert adds, "There is another [I think better] way to keep your Netscape cache clear, and speed up Netscape in the process. I set my disk cache to 0 bytes, and memory cache to 4096 kilobytes, and have been running like that for years."


    Reader Eric offers his method of removing index.dat files in Win9x.

    If you want a quick & easy way to keep your cookies, cache, & history files & those annoying MS index.dat files cleaned up here's a very simply way to do it. I created a RAMDrive using MS DOS RAMDrive.sys. Then I changed the pointers in the registery to point to the RAMDrive & saved cache, cookies, & history junk files there. Now everytime you reboot poof they are gone.

    Click on Start...Run...sysedit
    Select Config.sys

    Copy & paste the following into your config.sys

    <--------Begin copy here-------->

    DEVICE=C:\WINDOWS\HIMEM.SYS
    DEVICE=C:\WINDOWS\EMM386.EXE NOEMS
    DOS=HIGH,UMB
    DEVICEhigh=C:\WINDOWS\RAMdrive.sys 5120 /E

    <--------End copy here-------->

    You can change the 5120 to what ever amount of RAM you want to steal. I have 320M RAM so I took 5M. Under Internet Options You could also lower Amount of disk space used for Temp Internet Files to 1 or 2M.

    1024 1M RAM
    2048 2M RAM
    3072 3M RAM
    4096 4M RAM
    5120 5M RAM
    6144 6M RAM
    7168 7M RAM

    Reboot before editing the registery so you can now see your RAMDrive:
    Using regedit go to this Key & set the following:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

    Cache "Enter RAMDrive Letter" ex: F:
    Cookies "Enter RAMDrive Letter" ex: F:
    History "Enter RAMDrive Letter" ex: F:


    Reader Steve gives his method of index.dat cleanup on a network when your index.dat file is stored on the server when  you log out.

    I need to permanently disable index.dat file creation, because I'm in a NT network, and the index.dat files from my profile are stored on the server every time I log out, so deleting them at startup won't help keep them away from the server. So I use Hugh E. Morrison's tip on the ME/XE/2k addendum page and create dummy folders named index.dat.
    I'm using WIN95 OSR2 and IE 5.5 SP2 btw.. However the next time I start windows, the .dat files are back, inside the C:\WINDOWS\TEMP folder, and windows locks those too, so it probably uses them as well! They're even in the same folder structure, my TEMP folder has Cookies, History and Temporary Internet Files folders in them after that! Solution: I applied the same trick to those files (create more INDEX.DAT dummy folders in temp, every time in autoexec.bat after deleting the windows made index.dat files - could also have deleted TEMP completely and created a new one). 

    This time windows/IE gives up and scanning the hard drive for index.dat files reveals there are no more locations windows tries to put them.

    The lines I used (VERLAUF is used instead of HISTORY because I'm using a german version of windows):

    @echo off
    DELTREE /y c:\windows\ShellIconCache >nul
    DELTREE /y c:\win95\cookies\*.dat >nul
    DELTREE /y c:\win95\tempor~1\content.ie5\*.dat >nul
    DELTREE /y c:\win95\verlauf\*.dat >nul
    DELTREE /y c:\win95\verlauf\history.ie5\*.dat >nul
    DELTREE /y c:\win95\temp\cookies\*.dat >nul
    DELTREE /y c:\win95\temp\tempor~1\content.ie5\*.* >nul
    DELTREE /y c:\win95\temp\verlauf\*.dat >nul
    DELTREE /y c:\win95\temp\verlauf\history.ie5\*.* >nul

    DELTREE /y c:\win95\temp\*.tmp >nul

    MD c:\win95\cookies\index.dat >nul
    MD c:\win95\tempor~1\content.ie5\index.dat >nul
    MD c:\win95\verlauf\index.dat >nul
    MD c:\win95\verlauf\history.ie5\index.dat >nul
    MD c:\win95\temp\cookies\index.dat >nul
    MD c:\win95\temp\tempor~1\content.ie5\index.dat >nul
    MD c:\win95\temp\tempor~1\content.ie5\desktop.ini >nul
    MD c:\win95\temp\verlauf\index.dat >nul
    MD c:\win95\temp\verlauf\history.ie5\index.dat >nul
    MD c:\win95\temp\verlauf\history.ie5\desktop.ini >nul
  • 转载: 如何在Android emulator使用MARKET

    2010-04-11 17:04:20

    Android Market on Emulator (http://doll.javaeye.com/blog/605969)

    文章分类:移动开发 本文转载 原文是在一个外国网站上看到的 地址 http://tech-droid.blogspot.com/2009/11/android-market-on-emulator.html
    blogspot 是被天朝和谐了的网站

    1. 去http://developer.htc.com/adp.html这个网站上下载 System Image 镜像文件,我下载的是Android 1.6 的signed-dream_devphone_userdebug-img-14721.zip。

    2. 在你的Android开发环境 Eclipse中创建一个新的 AVD,SD Card Size 我写的是512M 你随便写多少表示下。

    3. 然后在你的电脑中找到.android这样的目录,该目录下有个avd 文件夹,找到你上一步为你的AVD取的名字那个文件夹。

    4. 解压在网上下载的 zip 文件,把 system.img 复制到 文件下面,重启 模拟器既可,然后你就可以在你的模拟器上登录Android Market搜索程序下载下来用,前提是你有Market 账号。


    5. 有图有真相


  • 导入联系人至Android 手机中.

    2010-04-11 09:30:42

    一、 把 *.csv 文件的打开方式选择为 记事本 打开,然后 保存为 *.txt 文件,

    二、 打开 windows 自带的 Outlook Express 软件,选择 联系人---打开通讯簿

    三、 在通讯簿中选择 文件---导入----其它通讯簿....----文本文件(以逗号分隔)----在 浏览处选择刚才保存好的 *.txt 文件,注意调整对应的号码等选项,可以打开 *.csv 文件参考对应的项。

    四、 导入完成后,在 编辑---全选 之后,用右键复制,在随意地方建新文件夹将之粘贴 进去,此时的文件就变成为 .vcf 格式了。

    五、 将。VCF格式的文件拷贝到你的SDCARD中。

    六、 在CONTACT APP中 Menu - Import/Export - 从SDCARD中导入。
  • 转载:How to create and use SDCard image for Android emulator

    2010-04-11 09:15:44

    http://penguin7.blog.51cto.com/966026/260263
    为了学习使用Android新的组件,先得为Android emulator虚拟一个SD卡。下面就把我的实验工作记录一下(本实验默认已经配置sdk目录下tools到环境变量目录中)。

    1. 使用mksdcard命令创建一个SD卡镜像(目前simulator支持8M~128G的SD卡。)
    例如创建一个名为sdcard2.img的128M(M需大写)SD卡镜像到~/android/sdcard/下,可以这样实现,
    $ mksdcard 128M ~/android/sdcard/sdcard2.img

    2. emulator挂载SD卡镜像

    emulator -avd Map1.5 -sdcard $SDCARD_LOC/sdcard2.img
    这里Map1.5是具有Google Map API 1.5 平台模拟器,同时为了方便我为SD卡镜像配置了登录shell的环境变量,通过cat命令就可以查看到
    $ cat ~/.bashrc

    # ~/.bashrc: executed by bash(1) for non-login shells.
    # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
    # for examples

    #Android SDCard Location variable
    SDCARD_LOC=/home/benjamin/android/sdcard/
    export PATH=$SDCARD_LOC:$PATH

    这样启动模拟器后,模拟器就不会抱怨没有SD卡了。

    3. 向emulator的SD卡镜像写入数据
    方法一:
    在/mnt目录下为SD卡建立一个挂载目录,
    $ mkdir -p /mnt/sdcard

    以loop设备方式将SD卡镜像挂载到刚才建立的那个目录下
    $ sudo mount -o loop /home/benjamin/android/sdcard/sdcard.img /mnt/sdcard/

    向SD卡镜像拷入一首mp3备用,
    $ sudo cp /home/benjamin/Music/I\ need\ to\ wake\ up-Melissa_Etheridge.mp3 /mnt/sdcard/
    查看一下,
    $ ls -l /mnt/sdcard/
    total 5009
    -rwxr-xr-x 1 root root 5128320 2010-01-07 22:16 I need to wake up-Melissa_Etheridge.mp3

    方法二(推荐):
    先启动模拟器并挂载SD Card
    $ emulator -avd android15 -sdcard $SDCARD_LOC/sdcard.img

    使用adb push 把要存储到SD卡镜像的文件压到模拟器SDCard的/sdcard目录下
    $ adb push ~/Music/I\ still\ believe.mp3 /sdcard
    显示:981 KB/s (5684529 bytes in 5.654s)表明传输成功。
    可以通过登录adb shell进一步查看详情
    $ adb shell
    # ls -l /sdcard
    ----rw-rw- system   system    5128320 2010-01-07 14:26 I need to wake up-Melissa_Etheridge.mp3
    ----rw-rw- system   system    5684529 2009-08-14 09:35 I still believe.mp3


    导入mp3后,如果要在模拟器中访问,还需要在模拟器中的Dev tools里面scan一下媒体文件,然后就先可以使用Android emulator自带Music程序查看传入的mp3了,


  • Android Virtual Devices 更改创建目录.

    2010-04-08 19:01:11

    转自:http://hewei1107.blog.163.com/blog/static/1275671372009910101747758/

    AVD quickview

    • You need to create an AVD to run any app in the Android emulator
    • Each AVD is a completely independent virtual device, with its own hardware options, system image, and data storage.
    • You create AVD configurations to model different device environments in the Android emulator.

    In this document

    1. Creating an AVD
      1. Listing targets
      2. Selecting a target
      3. Creating the AVD
      4. Setting hardware emulation options
      5. Default location of the AVD files
    2. Managing AVDs
      1. Moving an AVD
      2. Updating an AVD
      3. Deleting an AVD
    3. Command-line options

    See Also

    1. Android Emulator

    Android Virtual Devices (AVDs) are configurations of emulator options that let you better model an actual device.

    Each AVD is made up of:

    • A hardware profile.  You can set options to define the hardware features of the virtual device. For example, you can define whether the device has a camera, whether it uses a physical QWERTY keyboard or a dialing pad, how much memory it has, and so on.
    • A mapping to a system image.  You can define what version of the Android platform. will run on the virtual device. You can choose a version of the standard Android platform. or the system image packaged with an SDK add-on.
    • Other options.  You can specify the emulator skin you want to use with the AVD, which lets you control the screen dimensions, appearance, and so on. You can also specify the emulated SD card to use with the AVD.
    • A dedicated storage area on your development machine, in which is stored the device's user data (installed applications, settings, and so on) and emulated SD card.

    You can create as many AVDs as you need, based on the types of devices you want to model and the Android platforms and external libraries you want to run your application on.

    In addition to the options in an AVD configuration, you can also specify emulator command-line options at launch or by using the emulator console to change behaviors or characteristics at run time. For a complete reference of emulator options, please see the Emulatordocumentation.

    To create and manage AVDs, you use the android tool provided in the Android SDK. For more information about how to work with AVDs from inside your development environment, see Developing in Eclipse with ADT or Developing in Other IDEs, as appropriate for your environment.

    Creating an AVD

    The Android SDK does not include any preconfigured AVDs, so you need to create an AVD before you can run any application in the emulator (even the Hello World application).

    To create an AVD, you use the android tool, a command-line utility available in the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; "><sdk>/tools/</COde> directory. Managing AVDs is one of the two main function of the android tool (the other is creating and updating Android projects). Open a terminal window and change to the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; "><sdk>/tools/</COde>directory, if needed

    To create each AVD, you issue the command <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">android create avd</COde>, with options that specify a name for the new AVD and the system image you want to run on the emulator when the AVD is invoked. You can specify other options on the command line also, such as to create an emulated SD card for the new AVD, set the emulator skin to use, or set a custom location for the AVD's files.

    Here's the command-line usage for creating an AVD:

    android create avd -n <name> -t <targetID> [-<option> <value>] ...

    You can use any name you want for the AVD, but since you are likely to be creating multiple AVDs, you should choose a name that lets you recognize the general characteristics offered by the AVD.

    As shown in the usage above, you must use the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-t</COde> (or <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">--target</COde>) argument when creating a new AVD. The argument sets up a mapping between the AVD and the system image that you want to use whenever the AVD is invoked. You can specify any Android system image that is available in your local SDK — it can be the system image of a standard Android platform. version or that of any SDK add-on. Later, when applications use the AVD, they'll be running on the system that you specify in the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-t</COde> argument.

    To specify the system image to use, you refer to its target ID — an integer — as assigned by the android tool. The target ID is not derived from the system image name, version, or API Level, or other attribute, so you need to have the android tool list the available system images and the target ID of each, as described in the next section. You should do this before you run the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">android create avd</COde> command.

    Listing targets

    To generate a list of system image targets, use this command:

    android list targets

    The android tool scans the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; "><sdk>/platforms</COde> and <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; "><sdk>/add-ons</COde> directories looking for valid system images and then generates the list of targets. Here's an example of the command output:

    Available Android targets:id:1    Name: Android 1.1    Type: platform    API level: 2    Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-Pid:2    Name: Android 1.5    Type: platform    API level: 3    Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-Pid:3    Name: Google APIs    Type: add-on    Vendor: Google Inc.    Description: Android + Google APIs    Based on Android 1.5 (API level 3)    Libraries:    * com.google.android.maps (maps.jar)        API for Google Maps    Skins: HVGA (default), HVGA-L, QVGA-P, HVGA-P, QVGA-L

    Selecting a target

    Once you have generated the list of targets available, you can look at the characteristics of each system image — name, API Level, external libraries, and so on — and determine which target is appropriate for the new AVD.

    Keep these points in mind when you are selecting a system image target for your AVD:

    • The API Level of the target is important, because your application will not be able to run on a system image whose API Level is less than that required by your application, as specified in the<COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">minSdkVersion</COde> attribute of the application's manifest file. For more information about the relationship between system API Level and application <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">minSdkVersion</COde>, see Specifying Minimum System API Version.
    • Creating at least one AVD that uses a target whose API Level is greater than that required by your application is strongly encouraged, because it allows you to test the forward-compatibility of your application. Forward-compatibility testing ensures that, when users who have downloaded your application receive a system update, your application will continue to function normally.
    • If your application declares a <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">uses-library</COde> element in its manifest file, the application can only run on a system image in which that external library is present. If you want your application to run on the AVD you are creating, check the application's <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">uses-library</COde> element and select a system image target that includes that library.

    Creating the AVD

    When you've selected the target you want to use and made a note of its ID, use the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">android create avd</COde> command to create the AVD, supplying the target ID as the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-t</COde> argument. Here's an example that creates an AVD with name "my_android1.5" and target ID "2" (the standard Android 1.5 system image in the list above):

    android create avd -n my_android1.5 -t 2

    If the target you selected was a standard Android system image ("Type: platform"), the android tool next asks you whether you want to create a custom hardware profile.

    Android 1.5 is a basic Android platform.Do you wish to create a custom hardware profile [no]

    If you want to set custom hardware emulation options for the AVD, enter "yes" and set values as needed. If you want to use the default hardware emulation options for the AVD, just press the return key (the default is "no"). The android tool creates the AVD with name and system image mapping you requested, with the options you specified.

    If you are creating an AVD whose target is an SDK add-on, the android tool does not allow you to set hardware emulation options. It assumes that the provider of the add-on has set emulation options appropriately for the device that the add-on is modeling, and so prevents you from resetting the options.

    For a list of options you can use in the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">android create avd</COde> command, see the table in Command-line options for AVDs, at the bottom of this page.

    Setting hardware emulation options

    When are creating a new AVD that uses a standard Android system image ("Type: platform"), the android tool lets you set hardware emulation options for virtual device. The table below lists the options available and the default values, as well as the names of properties that store the emulated hardware options in the AVD's configuration file (the config.ini file in the AVD's local directory).

    Characteristic Description Property
    Device ram size The amount of physical RAM on the device, in megabytes. Default value is "96". hw.ramSize
    Touch-screen support Whether there is a touch screen or not on the device. Default value is "yes". hw.touchScreen
    Trackball support Whether there is a trackball on the device. Default value is "yes". hw.trackBall
    Keyboard support Whether the device has a QWERTY keyboard. Default value is "yes". hw.keyboard
    DPad support Whether the device has DPad keys. Default value is "yes". hw.dPad
    GSM modem support Whether there is a GSM modem in the device. Default value is "yes". hw.gsmModem
    Camera support Whether the device has a camera. Default value is "no". hw.camera
    Maximum horizontal camera pixels Default value is "640". hw.camera.maxHorizontalPixels
    Maximum vertical camera pixels Default value is "480". hw.camera.maxVerticalPixels
    GPS support Whether there is a GPS in the device. Default value is "yes". hw.gps
    Battery support Whether the device can run on a battery. Default value is "yes". hw.battery
    Accelerometer Whether there is an accelerometer in the device. Default value is "yes". hw.accelerometer
    Audio recording support Whether the device can record audio. Default value is "yes". hw.audioInput
    Audio playback support Whether the device can play audio. Default value is "yes". hw.audioOutput
    SD Card support Whether the device supports insertion/removal of virtual SD Cards. Default value is "yes". hw.sdCard
    Cache partition support Whether we use a /cache partition on the device. Default value is "yes". disk.cachePartition
    Cache partition size Default value is "66MB". disk.cachePartition.size

    Default location of the AVD files

    When you create an AVD, the android tool creates a dedicated directory for it on your development computer. The directory contains the AVD configuration file, the user data image and SD card image (if available), and any other files associated with the device. Note that the directory does not contain a system image — instead, the AVD configuration file contains a mapping to the system image, which it loads when the AVD is launched.

    The android tool also creates a <AVD name>.ini file for the AVD at the root of the .android/avd directory on your computer. The file specifies the location of the AVD directory and always remains at the root the .android directory.

    By default, the android tool creates the AVD directory inside <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">~/.android/avd/</COde> (on Linux/Mac), <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">C:\Documents and Settings\<user>\.android\</COde> on Windows XP, and<COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">C:\Users\<user>\.android\</COde> on Windows Vista. If you want to use a custom location for the AVD directory, you can do so by using the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-p <path></COde> option when you create the AVD:

    android create avd -n my_android1.5 -t 2 -p path/to/my/avd

    If the .android directory is hosted on a network drive, we recommend using the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-p</COde> option to place the AVD directory in another location. The AVD's .ini file remains in the .android directory on the network drive, regardless of the location of the AVD directory.

    Managing AVDs

    The sections below provide more information about how to manage AVDs once you've created them.

    Moving an AVD

    If you want to move or rename an AVD, you can do so using this command:

    android move avd -n <name> [-<option> <value>] ...

    The options for this command are listed in Command-line options for AVDs at the bottom of this page.

    Updating an AVD

    If, for any reason, the platform/add-on root folder has its name changed (maybe because the user has installed an update of the platform/add-on) then the AVD will not be able to load the system image that it is mapped to. In this case, the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">android list targets</COde> command will produce this output:

    The following Android Virtual Devices could not be loaded: Name: foo Path: <path>/.android/avd/foo.avd Error: Invalid value in image.sysdir. Run 'android update avd -n foo'

    To fix this error, use the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">android update avd</COde> command to recompute the path to the system images.

    Deleting an AVD

    You can use the android tool to delete an AVD. Here is the command usage:

    android delete avd -n <name>

    When you issue the command, the android tool looks for an AVD matching the specified name deletes the AVD's directory and files.

    Command-line options for AVDs

    The table below lists the command-line options you can use with the android tool.

    Action Option Description Comments
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">list avds</COde>   List all known AVDs, with name, path, target, and skin.  
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">create avd</COde> <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-n <name> or 

    </COde>

    The name for the AVD. Required
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-t <targetID></COde> Target ID of the system image to use with the new AVD. Required. To obtain a list of available targets, use <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">android list targets</COde>.
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-c <path></COde> or 

    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-c <size>[K|M]</COde>

    The path to the SD card image to use with this AVD or the size of a new SD card image to create for this AVD. Examples: <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-c path/to/sdcard</COde> or <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-c 1000M</COde>
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-f</COde> Force creation of the AVD By default, if the name of the AVD being created matches that of an existing AVD, the android tool will not create the new AVD or overwrite the existing AVD. If you specify the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-f</COde> option, however, the android tool will automatically overwrite any existing AVD that has the same name as the new AVD. The files and data of the existing AVD are deleted.
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-p <path></COde> Path to the location at which to create the directory for this AVD's files.  
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-s <name></COde> or 

    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-s <width>-<height></COde>

    The skin to use for this AVD, identified by name or dimensions. The android tool scans for a matching skin by name or dimension in the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">skins/</COde> directory of the target referenced in the <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-t <targetID></COde> argument. Example: <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-s HVGA-L</COde>
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">delete avd</COde> <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-n <name></COde> Delete the specified AVD. Required
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">move avd</COde> <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-n <name></COde> The name of the AVD to move. Required
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-p <path></COde> The path to the new location for the AVD.  
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">-r <new-name></COde> Rename the AVD.  
    <COde style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">update avds</COde>
  • Android: 如何使用ADB

    2010-04-06 15:14:13

    转自:http://rayleung.javaeye.com/blog/480908

    Android adb的使用略解

    文章分类:移动开发 关键字: android,adb

    安卓网的一个帖子,写得不错,记下来

    ADB全称Android Debug Bridge, 是android sdk里的一个工具, 用这个工具可以直接操作管理android模拟器或者真实的andriod设备(如G1手机).

    它的主要功能有:


    • 运行设备的shell(命令行)
    • 管理模拟器或设备的端口映射
    • 计算机和设备之间上传/下载文件
    • 将本地apk软件安装至模拟器或android设备



    ADB是一个 客户端-服务器端 程序, 其中客户端是你用来操作的电脑, 服务器端是android设备.

    先说安装方法, 电脑上需要安装客户端. 客户端包含在sdk里. 设备上不需要安装, 只需要在手机上打开选项settings-applications-development-USBdebugging.

    对于Mac和Linux用户, 下载好的sdk解压后, 可以放~或者任意目录. 然后修改~/.bash_profile文件, 设置运行环境指向sdk的tools目录.
    具体是打开~/.bash_profile文件(如果没有此文件也可以自行添加), 在里面加入一行:

    export PATH=${PATH}:<你的sdk目录>/tools

    然后就可以使用adb命令了.

    嫌安装麻烦的同学其实也可以省去上面安装步骤, 直接输入完整路径来使用命令
    对于windows xp用户, 需要先安装usb驱动  android_usb_windows.zip (1.33 MB) , 然后如果你只打算使用adb而不想下载整个sdk的话, 可以下载这个单独的adb工具包  adb_win.zip (571.56 KB) 下载后解压, 把里面 adb.exe 和 AdbWinApi.dll 两个文件放到系统盘的 windows/system32 文件夹里就可以了

     

    ADB常用的几个命令
    1. 查看设备

    • adb devices

    这个命令是查看当前连接的设备, 连接到计算机的android设备或者模拟器将会列出显示

    2. 安装软件

    • adb install <apk文件路径>

    这个命令将指定的apk文件安装到设备上

    3. 卸载软件

    • adb uninstall <软件名>
    • adb uninstall -k <软件名>

    如果加 -k 参数,为卸载软件但是保留配置和缓存文件.

    4. 登录设备shell

    • adb shell
    • adb shell <command命令>

    这个命令将登录设备的shell.
    后面加<command命令>将是直接运行设备命令, 相当于执行远程命令

    5. 从电脑上发送文件到设备

    • adb push <本地路径> <远程路径>

    用push命令可以把本机电脑上的文件或者文件夹复制到设备(手机)

    6. 从设备上下载文件到电脑

    • adb pull <远程路径> <本地路径>

    用pull命令可以把设备(手机)上的文件或者文件夹复制到本机电脑

    7. 显示帮助信息

    • adb help

    这个命令将显示帮助信息

  • Android vnc server 安装

    2010-04-06 14:38:22

    想通过PC来控制G1 phone(android), 在 MARKET找了半天,没有找到VNC server,只有VNC viewer,在网上搜索了一下,发现了一个叫做ANDROIDVNCSERVER的东东。以下是安装过程。
    转自:http://blog.csdn.net/stevenliyong/archive/2010/03/10/5365148.aspx
    名称:Android VNC Server on G1 (PC 远程控制 Android 手机) I found a vnc server for G1.

    1. Original vnc project

    http://code.google.com/p/android-vnc/

    This one could not be used on G1, because it need build a special keyboard driver into kernel

    2. Forked vnc server

    http://code.google.com/p/android-vnc-server/

    Forked from android-vnc project on google code.

    The original android-vnc need build a special keyboard driver into kernel. It's not necessary. Also the touch event support is added in this version.

    First download and install the binary

     http://code.google.com/p/android-vnc-server/downloads/list

    If you have adb on server:

    #adb push androidvncserver /data 
    #adb shell
    /data/androidvncserver
    Or you can just copy the downloaded file androidvncserver to the /sdcard, 
    Then umount the sdcard and launch the terminal from your G1, then type
    # su    <-  I have root access, I'm not sure whether the following steps work without root access.
    # cp /sdcard/androidvncserver /data/
    # chmod a+x /data/androidvncserver
    # /data/androidvncserver &
    And finally: 

    Run vnc viewer from hose PC.

    Here I use

    http://downloads.sourceforge.net/vnc...3.10-setup.exe 

    make sure the connection address with port 5901 : 192.168.0.101:5901

    Now, I can remote control my phone from host pc.

    在安装的过程上,遇到了以下问题, 在使用chmod命令时,总是提示,permission denied,在chmod 命令后添加了权限 777(即可执行又可读写的权限) 就可以了。

    另附图:通过 ADB启动VNC SERVER时的图

  • Android模拟器安装 with windows xp

    2010-03-04 15:12:55

    参见:

    http://androidandme.com/2009/10/news/how-to-install-android-sdk-and-play-with-android-2-0-in-the-emulator/

    Google has released the Android 2.0 SDK as of October 27th, 2009. We know how eager everyone has been to get their hands on Android 2.0, so we have decided to write up instructions so that anyone may download and install the SDK, then create and run an emulator instance.

    Note, the emulator is not intended to duplicate any particular device, so treat this more as a look at some of the core new features of Android 2.0 than an emulation of any current or future device. Also, things that require hardware features are not available in the emulator. No multi-touch in here guys (unless you manage to get two mice to work?).

    Enough of the talk, let’s get down to business.

    1)      Download appropriate file for your system from http://developer.android.com/sdk/index.html

    http://code.google.com/android/download.html

    2)      Extract to desired location

    3)      Run “SDK Setup.exe” (or the equivalent for your system)

    Launch sdksetup.ext

    Launch sdksetup.ext

    a.       If you receive an error message stating “Failed to fetch url…” then you will have to force the Setup program to use http in lieu of https.

    Got this error? Follow the steps.

    Got this error? Follow the steps.

    i.      Close the “Refresh Sources” window

    ii.      Cancel the “Choose Packages to Install” window

    iii.      Select “Settings” from the left side of the “Android SDK and AVD Manager” window

    iv.      Check the box labeled “Force https://… sources to be fetched using http://…”

    v.      Click “Save and Apply”

    vi.      Close and restart the SDK Setup program

    4)      Choose the packages that you wish install

    Select only the packages you need.

    Select only the packages you need.

    a.       If you are only interested in trying out the Android 2.0 Emulator

    i.      Reject everything except “SDK Platform. Android 2.0. API 5, revision 1” by selecting each item then selecting the Reject option

    b.      If you plan to develop Android applications and Games, you may wish to Accept All

    c.       Click “Install Selected”

    5)      Allow the selected packages to download and install then close the “Installing Archives” window

    6)      Create a new Android Virtual Device (AVD)

    These are the settings to emulate the Moto Droid.

    These are the settings to emulate the Moto Droid.

    a.       Select “Virtual Devices” from the left side of the “Android SDK and AVD Manager” window

    i.      Click “New”

    ii.      Enter a Name

    iii.      Choose a Target

    iv.      Enter a size for the emulated SD Card

    v.      Choose a Skin

    1.      To emulate current hardware such as the G1, MyTouch 3G, Hero, etc…

    a.       Leave the default value

    2.      To emulate the Motorola Droid

    a.       Choose WVGA 854

    3.      To emulate other devices

    a.       Choose anything else

    vi.      Click “Create AVD”

    7)      Start your newly created Virtual Device

    A successfully created AVD.

    A successfully created AVD.

    a.       Choose the Virtual Device from the list

    b.      Click “Start…”

    c.       Click “Launch”

    Just click launch.

    Just click launch.

    8)      Allow copious time for Emulator to start up

    First startup will take a few minutes.

    First startup will take a few minutes.

    9)      Enjoy!

    Android 2.0
  • Junit+verify

    2010-01-27 15:46:20

    想使用selenium RC做浏览器兼容性测试,使用了eclipse+junit+ant作为测试平台.
    在selenium中同时支持assert和verify两种断言模式.
    如果使用assert,当遇到错误时,test case不会再继续被执行下去; 而如果使用verify,当遇到错误时,test case仍会继续运行,直到完成.
    但在junit中创建测试代码时发现,junit不识别verify方法.
    从网上搜索了N多次,都没有找到彻底的解决方法,后来咨询了单位一个做开发人员,这个问题总得有眉目了.
    1. 首先不使用junit中的testcase类,而是使用com.thoughtworks.selenium.SeleneseTestCase.
    import com.thoughtworks.selenium.*;
    2.使用上述类就可以使用verify方法了,需要注意一点是:
    This class adds a number of "verify" commands, which are like "assert" commands, but they don't stop the test when they fail. Instead, verification errors are all thrown at once during tearDown.
    所以需要在teardown方法中,加后check verification的方法

    public void tearDown() throws Exception {
            selenium.stop();
            checkForVerificationErrors();
    }

    注意:        checkForVerificationErrors();和      selenium.stop();的位置不要反了啊. 如果反了,当遇到verificationerror的情况,这个测试就不能关闭不了.
    3.teardown()方法,使用junit默认定义teardown方法是如下
    protected void tearDown() throws Exception {
            selenium.stop();
            checkForVerificationErrors();
    }

    但junit总是报一个错误:
    Cannot reduce the visibility of the inherited method from SeleneseTestCase  
    原因是:
    因为接口定义的方法默认是public的,意思就是你没有任何访问修饰符的情况下,系统给接口的方法加上了一个public的访问修饰符。你Test实现了接口,并且实现了接口定义的方法,于是方法的访问修饰符只能比接口的访问修饰符高,但是类的默认访问修饰符是freidnly,降低了访问级别,所以会报错. 所以你Test实现的方法前面加上public就对了(具体不知道什么意思,咨询了一个开发人员后说的,哈哈,本人不懂代码哦.)

    后来将teardown()方法改成如下后,问题解决:
    public void tearDown() throws Exception {
            selenium.stop();
            checkForVerificationErrors();
    }




  • Selenium Grid + Selenium RC

    2010-01-15 13:52:32

    Reference URL:
    http://stackoverflow.com/questions/1944209/setup-for-ie6-and-multiple-browsers-in-selenium-grid
    http://selenium-grid.seleniumhq.org/faq.html

    Body:

    1. Installation:

    http://selenium-grid.seleniumhq.org/step_by_step_installation_instructions_for_windows.html

    2.Run the demo

    http://selenium-grid.seleniumhq.org/run_the_demo.html

    3.Running the Tests in Parallel on Multiple Machines

    Notes:
    • 在所有的机器(比如GRID机,RC机)上,都必须要安装ANT和SELENIUM GRID
    • 必须在GRID机上先启动 ant-hub,然后再在其它的机器上启动RC,这样在localhost:4444/console中,你才能看到available remote control的信息.
    • 如果在某台机器上想用某种浏览器(e.g.safari)进行测试,那在在这台机器上,必须将支持此浏览器的RC启动起来,格式如下:ant -Dport=5556 -Dhost=192.168.1.4 -DhubURL=http://192.168.1.70:4444 -Denvironment="Safari on Windows" launch-remote-control

    4.Running the Demo Using a Different Browser

    In the demo, firefox is the default browser, if you want to run the demo with the Safari web browser, you need to follow the below steps:
    • ant launch-hub
    • Launch a remote control(in the other machine or in the same machine) declaring that it provides the Safari environment: ant -Dport= -Dhost= -DhubURL= -Denvironment="*safari" launch-remote-control
    • Launch the other remote controls the same way:
    • ant -Denvironment="*safari" -Dport=5556 launch-remote-control
      ant -Denvironment="*safari" -Dport=5557 launch-remote-control
    • Launch the demo overriding the browser system property:
      • ant -Dbrowser="*safari" run-demo-in-parallel




  • Eclipse+Junit Test Suite Error --java.lang.Exception: No runnable methods

    2010-01-15 09:30:12

    使用Eclipse+(Junit4.x+Junit3.x 2个单位测试插件)做回归测试, 单个执行TESTCASE的时候都是可以成功的,但是将TESTCASE放在TESTSUITE中执行时,提示
    java.lang.Exception: No runnable methods
        at org.junit.internal.runners.TestClassMethodsRunner.testAborted(TestClassMethodsRunner.java:42)
        at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:33)
        at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
        at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
        at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

    以下是测试套件代码

    package Testsuite;

    import junit.framework.Test;
    import junit.framework.TestSuite;

    public class AllTests {

        public static Test suite() {
            TestSuite suite = new TestSuite("Test for Testsuite");
            //$JUnit-BEGIN$
            suite.addTestSuite(GoogleTest2.class);
            suite.addTestSuite(GoogleTest1.class);
            suite.addTestSuite(GoogleTest.class);
            //$JUnit-END$
            return suite;
        }

    }

    在网上查了一下,原因是因为我使用了Junit4.x进行单元测试,if you use the JUnit 4.4 core runner to execute a class, you must have "@Test" method in the class.

    有两种方法可以解决这个问题:

    (1)比较简单的方法: 使用Junit3.x, 右击TESTSUITE CLASS,选择RunAs-Run,在弹出的窗口中,Testrunner选择为Junit3,默认是Junit4.(本人才疏学浅,实在不是太懂JUNIT里面的道道,就采用了第一种方法)
    (2)修改TESTSUITE和TESTCASE测试代码,使其包含 the @Test annotation,修改后的代码
    import org.junit.runner.RunWith;
    import org.junit.runners.Suite;
    import org.junit.runners.Suite.SuiteClasses;


    @RunWith(value=Suite.class)
    @SuiteClasses(value={TestCase.class})
    public class AllTests {

    }

    import static org.junit.Assert.assertTrue;
    import org.junit.Test;

    public class TestCase  {
    @Test
       
    public void test1 {
            assertTrue
    (tmp.getTermin().equals(soll));(//注意以处要换成自己的测试代码,这只是一个例子)
       
    }
    }

    在以下这个网站上还找到其它可能引起No runnable method的原因:
    http://www.dantoomeysoftware.com/pencils-down/2009/04/03/junit-error-javalangexception-no-runnable-methods/

    This error is a catchall for anything else that might be wrong with your test class.  First make sure any of the below problems are not occurring. 

    Your unit test code is running JUnit4.  At least one test method must have the @Test annotation.  Otherwise this error occurs.

    If the class you are testing has @Required setters for Spring injections they must be set otherwise JUnit will mask the missing required exception as a no runnable methods exception.

    If you are initializing your mock objects outside of the @Begin method you will get this error.

    If you are attempting to mock the same class more than once you will get this error.




  • Eclipse+Junit test report

    2010-01-14 17:46:51

    转自 Generating a JUnit test report with eclipse

    clear instructions on how to use the built in functionality in eclipse to generate nice Junit reports in HTML using ant.

    Now that I have found a solution to this problem I will post it in hopes that it might help others:

    This approach is makes use of the eclipse2ant plug-in which is standard on Eclipse release 3.1M6 and higher (http://www.geocities.com/richard_hoefter/eclipse2ant/).
    (注释:如果使用的是3.1版本以上的ECLIPSE则不用考虑
    eclipse2ant插件问题)

    1) First generate an Ant build file for your project.
    In the Export page select "Ant Buildfiles" it is under General. Then select a project that contains your JUnit tests. The default JUnit output directory is appropriately named "junit".

    (注释:在你的workspace中相应的PROJECT目录下创建一个名为'junit'的文件夹,以便存放输出结果)

    2) Next resolve dependencies by making sure that the junit.jar is added to Ant's "Global Entries."
    Window->Preferences->Ant->Runtime->Global Entries and Add External JARs... Navigate to your "eclipse" directory (where eclipse is installed). It is under "plugins" directory and presently the junit.jar is in a directory named "org.junit_3.8.1". If this is missing then you will see error messages since junit is an optional Ant task.


    3) Run then right click on the Ant build file (by default build.xml) and Run As->Ant Build... This will display a list of targets. All of the launch configurations you have previously configured will have a corresponding target in your Ant build file. Select the desired target(s), and also select the "junitreport" target. Check the "Target execution order" text area to make sure the junitreport is run last.
    (注释:在TARTGET list中选择时,要选择需要执行的TESTCASE和JUNITREPORT)

    4) Access to junit output directory of your project from your workspace path, click on index.html you will see the test result in browser.



    Whenever you run a test case it will generate results and will be placed in the junit output directory. These results are formatted into an HTML report by the junitreport target and stored in the junit output directory. 
471/3123>
Open Toolbar