• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python uiautomator.AutomatorServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中uiautomator.AutomatorServer的典型用法代码示例。如果您正苦于以下问题:Python AutomatorServer类的具体用法?Python AutomatorServer怎么用?Python AutomatorServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AutomatorServer类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_start_ping

 def test_start_ping(self):
     with patch("uiautomator.JsonRPCClient") as JsonRPCClient:
         JsonRPCClient.return_value.ping.return_value = "pong"
         server = AutomatorServer()
         server.adb = MagicMock()
         server.adb.forward.return_value = 0
         self.assertEqual(server.ping(), "pong")
开发者ID:Infinity2013,项目名称:ux-script,代码行数:7,代码来源:test_server.py


示例2: test_push

 def test_push(self):
     jars = ["bundle.jar", "uiautomator-stub.jar"]
     server = AutomatorServer()
     server.adb = MagicMock()
     self.assertEqual(set(server.push()), set(jars))
     for args in server.adb.cmd.call_args_list:
         self.assertEqual(args[0][0], "push")
         self.assertEqual(args[0][2], "/data/local/tmp/")
开发者ID:Infinity2013,项目名称:ux-script,代码行数:8,代码来源:test_server.py


示例3: test_auto_start

 def test_auto_start(self):
     with patch("uiautomator.JsonRPCClient") as JsonRPCClient:
         JsonRPCClient.ping.return_value = None
         server = AutomatorServer()
         server.start = MagicMock()
         server.stop = MagicMock()
         server.jsonrpc
         server.start.assert_called_once_with()
开发者ID:Top-Q,项目名称:uiautomator,代码行数:8,代码来源:test_server.py


示例4: test_download_and_push_download

 def test_download_and_push_download(self, adb):
     jars = ["bundle.jar", "uiautomator-stub.jar"]
     with patch("os.path.exists") as exists,\
          patch("os.mkdir") as mkdir,\
          patch("%s.open" % open.__class__.__module__, mock_open(), create=True) as m_open:
         server = AutomatorServer()
         exists.return_value = False
         self.assertEqual(set(server.download_and_push()), set(jars))
         self.assertEqual(len(m_open.call_args_list), len(jars))
开发者ID:EthanGuo,项目名称:uiautomator,代码行数:9,代码来源:test_server.py


示例5: test_download_and_push

 def test_download_and_push(self, adb):
     jars = ["bundle.jar", "uiautomator-stub.jar"]
     with patch("os.path.exists") as exists:
         server = AutomatorServer()
         exists.return_value = True
         self.assertEqual(set(server.download_and_push()), set(jars))
         for args in adb.cmd.call_args_list:
             self.assertEqual(args[0][0], "push")
             self.assertEqual(args[0][2], "/data/local/tmp/")
开发者ID:EthanGuo,项目名称:uiautomator,代码行数:9,代码来源:test_server.py


示例6: test_start_forward_error

 def test_start_forward_error(self):
     server = AutomatorServer()
     server.download_and_push = MagicMock()
     server.download_and_push.return_value = ["bundle.jar", "uiautomator-stub.jar"]
     with patch("uiautomator.adb") as adb:
         adb.forward.return_value = 1
         with patch.dict('os.environ', {'LOCAL_PORT': '9000', 'DEVICE_PORT': '9000'}):
             with self.assertRaises(IOError):
                 server.start()
             adb.forward.assert_called_once_with(9000, 9000)
开发者ID:EthanGuo,项目名称:uiautomator,代码行数:10,代码来源:test_server.py


示例7: test_screenshot

    def test_screenshot(self):
        server = AutomatorServer()
        server.sdk_version = MagicMock()
        server.sdk_version.return_value = 17
        self.assertEqual(server.screenshot(), None)

        server.sdk_version.return_value = 18
        self.urlopen.return_value.read = MagicMock()
        self.urlopen.return_value.read.return_value = b"123456"
        self.assertEqual(server.screenshot(), b"123456")
        self.assertEqual(server.screenshot("/tmp/test.txt"), "/tmp/test.txt")
开发者ID:Andy-hpliu,项目名称:uiautomator,代码行数:11,代码来源:test_server.py


示例8: test_auto_start

 def test_auto_start(self):
     with patch.dict('os.environ', {'LOCAL_PORT': '9000', 'DEVICE_PORT': '9000'}):
         with patch("uiautomator.JsonRPCClient") as JsonRPCClient:
             JsonRPCClient.ping.return_value = None
             server = AutomatorServer()
             server.start = MagicMock()
             server.jsonrpc
             JsonRPCClient.assert_called_once_with(server.rpc_uri)
             server.start.assert_called_once_with()
             server.jsonrpc  # second call will retrieve the stored obj
             JsonRPCClient.assert_called_once_with(server.rpc_uri)
开发者ID:EthanGuo,项目名称:uiautomator,代码行数:11,代码来源:test_server.py


示例9: test_start_success

 def test_start_success(self):
     server = AutomatorServer()
     server.download_and_push = MagicMock()
     server.download_and_push.return_value = ["bundle.jar", "uiautomator-stub.jar"]
     server.ping = MagicMock()
     server.ping.return_value = "pong"
     with patch("uiautomator.adb") as adb:
         adb.forward.return_value = 0
         with patch.dict('os.environ', {'LOCAL_PORT': '9000', 'DEVICE_PORT': '9000'}):
             server.start()
             adb.cmd.assert_valled_onec_with('shell', 'uiautomator', 'runtest', 'bundle.jar', 'uiautomator-stub.jar', '-c', 'com.github.uiautomatorstub.Stub')
             adb.forward.assert_called_once_with(9000, 9000)
开发者ID:EthanGuo,项目名称:uiautomator,代码行数:12,代码来源:test_server.py


示例10: test_stop_started_server

    def test_stop_started_server(self, adb):
        serial = "76HDGKDN783HD6D"
        server = AutomatorServer()
        server.uiautomator_process = process = MagicMock()
        process.poll.return_value = None
        server.stop()
        process.wait.assert_called_once_with()

        server.uiautomator_process = process = MagicMock()
        process.poll.return_value = None
        self.urlopen.side_effect = IOError("error")
        server.stop()
        process.kill.assert_called_once_with()
开发者ID:EthanGuo,项目名称:uiautomator,代码行数:13,代码来源:test_server.py


示例11: test_stop

 def test_stop(self):
     results = [
         b"USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME\n\rsystem    372   126   635596 104808 ffffffff 00000000 S uiautomator",
         b"USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME\r\nsystem    372   126   635596 104808 ffffffff 00000000 S uiautomator",
         b"USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME\nsystem    372   126   635596 104808 ffffffff 00000000 S uiautomator",
         b"USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME\rsystem    372   126   635596 104808 ffffffff 00000000 S uiautomator"
     ]
     for r in results:
         server = AutomatorServer()
         server.adb = MagicMock()
         server.adb.cmd.return_value.communicate.return_value = (r, "")
         server.stop()
         self.assertEqual(server.adb.cmd.call_args_list,
                          [call("shell", "ps", "-C", "uiautomator"), call("shell", "kill", "-9", "372")])
开发者ID:Infinity2013,项目名称:ux-script,代码行数:14,代码来源:test_server.py


示例12: test_auto_start

 def test_auto_start(self):
     try:
         import requests
     except ImportError:
         raise
     with patch("uiautomator.JsonRPCMethod") as JsonRPCMethod:
         # returns = [urllib2.URLError("error"), "ok"]
         returns = [requests.exceptions.ConnectionError("error"), "ok"]
         
         def side_effect():
             result = returns.pop(0)
             if isinstance(result, Exception):
                 raise result
             return result
         JsonRPCMethod.return_value.side_effect = side_effect
         server = AutomatorServer()
         server.start = MagicMock()
         server.stop = MagicMock()
         self.assertEqual("ok", server.jsonrpc.any_method())
         server.start.assert_called_once_with(timeout=30)
     with patch("uiautomator.JsonRPCMethod") as JsonRPCMethod:
         returns = [requests.exceptions.ConnectionError("error"), "ok"]
         # returns = [JsonRPCError(-32000-1, "error msg"), "ok"]
         
         def side_effect():
             result = returns.pop(0)
             if isinstance(result, Exception):
                 raise result
             return result
         JsonRPCMethod.return_value.side_effect = side_effect
         server = AutomatorServer()
         server.start = MagicMock()
         server.stop = MagicMock()
         self.assertEqual("ok", server.jsonrpc.any_method())
         server.start.assert_called_once_with(timeout=30)
     with patch("uiautomator.JsonRPCMethod") as JsonRPCMethod:
         JsonRPCMethod.return_value.side_effect = JsonRPCError(-32000-2, "error msg")
         server = AutomatorServer()
         server.start = MagicMock()
         server.stop = MagicMock()
         with self.assertRaises(JsonRPCError):
             server.jsonrpc.any_method()
开发者ID:openatx,项目名称:atx-uiautomator,代码行数:42,代码来源:skip_test_server.py


示例13: test_start_success

 def test_start_success(self):
     server = AutomatorServer()
     server.push = MagicMock()
     server.push.return_value = ["bundle.jar", "uiautomator-stub.jar"]
     server.ping = MagicMock()
     server.ping.return_value = "pong"
     server.adb = MagicMock()
     server.start()
     server.adb.cmd.assert_valled_onec_with('shell', 'uiautomator', 'runtest', 'bundle.jar', 'uiautomator-stub.jar', '-c', 'com.github.uiautomatorstub.Stub')
开发者ID:Infinity2013,项目名称:ux-script,代码行数:9,代码来源:test_server.py


示例14: test_start_error

 def test_start_error(self):
     server = AutomatorServer()
     server.push = MagicMock()
     server.push.return_value = ["bundle.jar", "uiautomator-stub.jar"]
     server.ping = MagicMock()
     server.ping.return_value = None
     server.adb = MagicMock()
     with patch("time.sleep"):
         with self.assertRaises(IOError):
             server.start()
开发者ID:Infinity2013,项目名称:ux-script,代码行数:10,代码来源:test_server.py


示例15: test_start_ping_none

 def test_start_ping_none(self):
     with patch.dict('os.environ', {'LOCAL_PORT': '9000', 'DEVICE_PORT': '9000'}):
         with patch("uiautomator.JsonRPCClient") as JsonRPCClient:
             JsonRPCClient.return_value.ping.side_effect = Exception("error")
             server = AutomatorServer()
             self.assertEqual(server.ping(), None)
开发者ID:EthanGuo,项目名称:uiautomator,代码行数:6,代码来源:test_server.py


示例16: test_start_ping

 def test_start_ping(self):
     with patch.dict('os.environ', {'LOCAL_PORT': '9000', 'DEVICE_PORT': '9000'}):
         with patch("uiautomator.JsonRPCClient") as JsonRPCClient:
             JsonRPCClient.return_value.ping.return_value = "pong"
             server = AutomatorServer()
             self.assertEqual(server.ping(), "pong")
开发者ID:EthanGuo,项目名称:uiautomator,代码行数:6,代码来源:test_server.py


示例17: test_start_ping_none

 def test_start_ping_none(self):
     with patch("uiautomator.JsonRPCClient") as JsonRPCClient:
         JsonRPCClient.return_value.ping.side_effect = Exception("error")
         server = AutomatorServer()
         self.assertEqual(server.ping(), None)
开发者ID:Infinity2013,项目名称:ux-script,代码行数:5,代码来源:test_server.py



注:本文中的uiautomator.AutomatorServer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python uiautomator.Device类代码示例发布时间:2022-05-27
下一篇:
Python uiautomator.Adb类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap