当前位置:   article > 正文

android自动测试_atd112;

atd112;

为了自动测试拨打电话功能,自动化脚本需要使用相关的接口。

 

方法之一:AT command

 

1) adb shell

2) enter AT command mode ( platform specific )

3) atd112;                            // 拨打112

4) ath                                   // 断开MO call

 

 

方法之二:Android am command

 

1)adb shell

2)  am start -a android.intent.action.CALL -d tel:112                    // 输入112号码

3)input keyevent 66                                                                    // 开始拨号

4)   input keyevent 6                                                                      // 断开

 

综合考虑,如果需要针对modem方面的操作, AT 命令比较方便。

如果需要对application processor方面的应用进行操作,  android am 命令比较合适。

 

===================================================================

am 命令

  1. usage: am [subcommand] [options]
  2. usage: am start [-D] [-W] [-P <FILE>] [--start-profiler <FILE>]
  3. [--R COUNT] [-S] [--opengl-trace]
  4. [--user <USER_ID> | current] <INTENT>
  5. am startservice [--user <USER_ID> | current] <INTENT>
  6. am force-stop [--user <USER_ID> | all | current] <PACKAGE>
  7. am kill [--user <USER_ID> | all | current] <PACKAGE>
  8. am kill-all
  9. am broadcast [--user <USER_ID> | all | current] <INTENT>
  10. am instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]
  11. [--user <USER_ID> | current]
  12. [--no-window-animation] <COMPONENT>
  13. am profile start [--user <USER_ID> current] <PROCESS> <FILE>
  14. am profile stop [--user <USER_ID> current] [<PROCESS>]
  15. am dumpheap [--user <USER_ID> current] [-n] <PROCESS> <FILE>
  16. am set-debug-app [-w] [--persistent] <PACKAGE>
  17. am clear-debug-app
  18. am monitor [--gdb <port>]
  19. am screen-compat [on|off] <PACKAGE>
  20. am display-size [reset|WxH]
  21. am display-density [reset|DENSITY]
  22. am to-uri [INTENT]
  23. am to-intent-uri [INTENT]
  24. am switch-user <USER_ID>
  25. am stop-user <USER_ID>


 am 参数说明

  1. am start: start an Activity. Options are:
  2. -D: enable debugging
  3. -W: wait for launch to complete
  4. --start-profiler <FILE>: start profiler and send results to <FILE>
  5. -P <FILE>: like above, but profiling stops when app goes idle
  6. -R: repeat the activity launch <COUNT> times. Prior to each repeat,
  7. the top activity will be finished.
  8. -S: force stop the target app before starting the activity
  9. --opengl-trace: enable tracing of OpenGL functions
  10. --user <USER_ID> | current: Specify which user to run as; if not
  11. specified then run as the current user.
  12. am startservice: start a Service. Options are:
  13. --user <USER_ID> | current: Specify which user to run as; if not
  14. specified then run as the current user.
  15. am force-stop: force stop everything associated with <PACKAGE>.
  16. --user <USER_ID> | all | current: Specify user to force stop;
  17. all users if not specified.
  18. am kill: Kill all processes associated with <PACKAGE>. Only kills.
  19. processes that are safe to kill -- that is, will not impact the user
  20. experience.
  21. --user <USER_ID> | all | current: Specify user whose processes to kill;
  22. all users if not specified.
  23. am kill-all: Kill all background processes.
  24. am broadcast: send a broadcast Intent. Options are:
  25. --user <USER_ID> | all | current: Specify which user to send to; if not
  26. specified then send to all users.
  27. am instrument: start an Instrumentation. Typically this target <COMPONENT>
  28. is the form <TEST_PACKAGE>/<RUNNER_CLASS>. Options are:
  29. -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT). Use with
  30. [-e perf true] to generate raw output for performance measurements.
  31. -e <NAME> <VALUE>: set argument <NAME> to <VALUE>. For test runners a
  32. common form is [-e <testrunner_flag> <value>[,<value>...]].
  33. -p <FILE>: write profiling data to <FILE>
  34. -w: wait for instrumentation to finish before returning. Required for
  35. test runners.
  36. --user <USER_ID> | current: Specify user instrumentation runs in;
  37. current user if not specified.
  38. --no-window-animation: turn off window animations will running.
  39. am profile: start and stop profiler on a process. The given <PROCESS> argument
  40. may be either a process name or pid. Options are:
  41. --user <USER_ID> | current: When supplying a process name,
  42. specify user of process to profile; uses current user if not specified.
  43. am dumpheap: dump the heap of a process. The given <PROCESS> argument may
  44. be either a process name or pid. Options are:
  45. -n: dump native heap instead of managed heap
  46. --user <USER_ID> | current: When supplying a process name,
  47. specify user of process to dump; uses current user if not specified.
  48. am set-debug-app: set application <PACKAGE> to debug. Options are:
  49. -w: wait for debugger when application starts
  50. --persistent: retain this value
  51. am clear-debug-app: clear the previously set-debug-app.
  52. am bug-report: request bug report generation; will launch UI
  53. when done to select where it should be delivered.
  54. am monitor: start monitoring for crashes or ANRs.
  55. --gdb: start gdbserv on the given port at crash/ANR
  56. am screen-compat: control screen compatibility mode of <PACKAGE>.
  57. am display-size: override display size.
  58. am display-density: override display density.
  59. am to-uri: print the given Intent specification as a URI.
  60. am to-intent-uri: print the given Intent specification as an intent: URI.
  61. am switch-user: switch to put USER_ID in the foreground, starting
  62. execution of that user if it is currently stopped.
  63. am stop-user: stop execution of USER_ID, not allowing it to run any
  64. code until a later explicit switch to it.

 

input 命令

  1. usage: input ...
  2. input text <string>
  3. input keyevent <key code number or name>
  4. input [touchscreen|touchpad] tap <x> <y>
  5. input [touchscreen|touchpad] swipe <x1> <y1> <x2> <y2>
  6. input trackball press
  7. input trackball roll <dx> <dy>


Android KeyEvent 输入Android keyevent 输入

  1. case 0x0a: case 0x8a: system("input keyevent 3");break;//Home
  2. case 0x0b: case 0x8b: system("input keyevent 82");break;//menu
  3. case 0x1c: case 0x9c: system("input keyevent 19");break;//up
  4. case 0x1d: case 0x9d: system("input keyevent 20");break;//down
  5. case 0x1e: case 0x9e: system("input keyevent 23");break;//OK
  6. case 0x1f: case 0x9f: system("input keyevent 21");break;//left
  7. case 0x20: case 0xa0: system("input keyevent 22");break;//right
  8. case 0x21: case 0xa1: system("input keyevent 67");break;//Back
  9. case 0x22: case 0xa2: system("input keyevent 4");break;//Exit
  10. case 0x23: case 0xa3: /*system("input keyevent 6");*/break;//i
  11. case 0x28: case 0xa8: /*system("input keyevent 28");*/break;//A-select
  12. case 0x29: case 0xa9: /*system("input keyevent 66");*/break;//B - Enter
  13. case 0x2a: case 0xaa: /*system("input keyevent ");*/break;//white
  14. case 0x2b: case 0xab: /*system("input keyevent 26");*/break;//green - Power
  15. case 0x2c: case 0xac: /*system("input keyevent ");*/break;//yellow
  16. case 0x2d: case 0xad: /*system("input keyevent 1");*/break;//red
  17. case 0x2e: case 0xae: system("input keyevent 24");break;//volume up
  18. case 0x2f: case 0xaf: system("input keyevent 25");break;//volume down
  19. case 0x00: case 0x80: system("input keyevent 7");break;//0
  20. case 0x01: case 0x81: system("am start -n com.cooliris.media/.Gallery");break;//1
  21. case 0x02: case 0x82: system("am start -n com.android.browser/.BrowserActivity");break;//2
  22. case 0x03: case 0x83: system("am start -n com.android.settings/.WirelessSettings");break;//3
  23. case 0x04: case 0x84: /*system("input keyevent 11");*/break;//4
  24. case 0x05: case 0x85: /*system("input keyevent 12");*/break;//5
  25. case 0x06: case 0x86: /*system("input keyevent 13");*/break;//6
  26. case 0x07: case 0x87: /*system("input keyevent 14");*/break;//7
  27. case 0x08: case 0x88: /*system("input keyevent 15");*/break;//8
  28. case 0x09: case 0x89: /*system("input keyevent 16");*/break;//9


 

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/287674
推荐阅读
相关标签
  

闽ICP备14008679号