我正试图在设备暂时失去连接时测试我的应用的行为。
显然,我想自动完成此测试,而无需手动打开和关闭AIRPLANE MODE或启用/禁用数据访问。
我正在使用calabash-android连接到模拟器。 (无法在真实设备上运行以下命令,因为它们会引发权限问题.AIRPLANE_MODE是受保护的意图,因此只能由系统发送)
当我运行以下命令时:
adb shell settings put global airplane_mode_on 1
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
仿真器按预期切换到飞行模式,但此时发生了一些事情...... ADB失去了设备的可见性,因此calabash-android开始抱怨如下:
Connection refused - connect(2) (http://127.0.0.1:34778) (Errno::ECONNREFUSED)
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient/session.rb:803:in `initialize'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient/session.rb:803:in `new'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient/session.rb:803:in `create_socket'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient/session.rb:752:in `block in connect'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient/session.rb:751:in `connect'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient/session.rb:609:in `query'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient/session.rb:164:in `query'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient.rb:1083:in `do_get_block'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient.rb:887:in `block in do_request'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient.rb:981:in `protect_keep_alive_disconnected'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient.rb:886:in `do_request'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient.rb:774:in `request'
bundle/ruby/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient.rb:684:in `post'
bundle/ruby/1.9.1/gems/calabash-android-0.4.16/lib/calabash-android/operations.rb:334:in `make_http_request'
bundle/ruby/1.9.1/gems/calabash-android-0.4.16/lib/calabash-android/operations.rb:294:in `http'
bundle/ruby/1.9.1/gems/calabash-android-0.4.16/lib/calabash-android/operations.rb:556:in `shutdown_test_server'
bundle/ruby/1.9.1/gems/calabash-android-0.4.16/lib/calabash-android/operations.rb:97:in `shutdown_test_server'
/scratch/git/we7-Android/Main/features/support/app_life_cycle_hooks.rb:49:in `After'
有什么建议吗?请帮忙