-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove atx-agent (#959) and useless libs
* remove atx-agent from code * remove filelocks and others
- Loading branch information
1 parent
0da31f9
commit a063811
Showing
32 changed files
with
1,018 additions
and
1,707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,117 @@ | ||
# 2.x到3.x升级说明 | ||
|
||
## 变更内容 | ||
## 变更内容简介 | ||
|
||
- 移除atx-agent,常驻服务移除,改为运行时启动手机内的uiautomator服务 | ||
- 直接通过atx-agent地址连接的方法不再支持,connect函数目前只支持本地的USB设备或adb connect状态的设备 | ||
- 环境变量 ANDROID_DEVICE_IP 不再支持,如果需要使用环境变量传递序列号可以使用 ANDROID_SERIAL | ||
- 版本管理从pbr改为poetry,同时降低依赖库的数量 | ||
- Python依赖调整为最低3.8 | ||
- 增加更多的单测 | ||
- 日志使用标准库logging, 默认不输出任何内容,除非手动开启 | ||
- minicap,minitouch不再默认安装 | ||
- atx-agent[armeabi]直接打包到lib里面去,避免外网下载依赖 | ||
|
||
## 移除的功能 | ||
- current_app函数移除 | ||
- `d.xpath("...").wait()`从原有的返回 XMLElement|None,改为返回 bool | ||
- 日志库清理 | ||
- 移除 logzero依赖 | ||
- 移除 property u2.logger | ||
- 移除 property u2.xpath.XPath.logger | ||
- 移除 property d.watcher.debug | ||
- 移除 d.settings["xpath_debug"] | ||
|
||
- 移除 class AdbUI | ||
- 移除 function XPath.apply_watch_from_yaml | ||
- 移除 module uiautomator2.ext.xpath | ||
- 移除 connect_usb函数中的init参数移除,这个参数目前没什么用了 | ||
|
||
# 手动开启日志方法 | ||
开启Lib库日志的方法 | ||
|
||
```python | ||
from uiautomator2 import enable_pretty_logging | ||
enable_pretty_logging() | ||
``` | ||
- ~~atx-agent[armeabi]直接打包到lib里面去,避免外网下载依赖~~ | ||
|
||
|
||
## New | ||
- Add function enable_pretty_logging | ||
- Add class AdbShellError, HierarchyEmptyError, HTTPError | ||
|
||
## Breaking changes (移除的功能) | ||
|
||
### Lib removes | ||
- Remove logzero | ||
- Remove filelocks | ||
- Remove progress | ||
- Remove packaging | ||
- Remove Pillow | ||
|
||
### Module removes | ||
- Remove module uiautomator2.ext.xpath | ||
|
||
### Class removes | ||
- Remove class AdbUI | ||
- Remove class Session, 这个本来就是个傀儡类型 | ||
- Remove class GatewayError | ||
- Remove class ServerError, UiautomatorQuitError, RequestError, UiaError, JsonRpcError, NullObjectExceptionError, NullPointerExceptionError, StaleObjectExceptionError | ||
|
||
### Property removes | ||
- Remove property u2.logger | ||
- Remove property u2.xpath.XPath.logger | ||
- Remove property d.watcher.debug | ||
- Remove property: address, 原来是用于获取atx-agent的URL地址 | ||
- Remove property: alive, 原来用于检测atx-agent的存活状态 | ||
- Remove property: uiautomator, 原来用法是d.uiautomator.stop() | ||
- Remove property: widget, 原来也不怎么用 | ||
- Remove property: http, 原来是这样用的d.http.get("/device_info") | ||
- Remove d.settings["xpath_debug"] | ||
|
||
### Function removes | ||
- Remove function current_app, use app_current instead | ||
- Remove function XPath.apply_watch_from_yaml | ||
- Remove function healcheck, 原来是未来恢复uiautomator服务用的 | ||
- Remove function service(name: str) -> Service, 原本是用于做atx-agent的服务管理 | ||
- Remove function session, 该函数依赖atx-agent,这个函数本来就是为了兼顾appium的用法,后来发现也用不到 | ||
- Remove function app_icon() -> Image, 该函数依赖atx-agent | ||
- Remove function connect_wifi() -> Device, 该函数依赖atx-agent | ||
- Remove function connect_adb_wifi(str) -> Device, 直接用connect就行了 | ||
- Remove function set_new_command_timeout(timeout: int), 用不着了 | ||
- Remove function device_info(), 函数依赖atx-agent | ||
- Remove function open_identify(), 打开一个比较明显的界面,这个函数出了点毛病,先下掉了 | ||
|
||
### Command remove | ||
- Remove "uiautomator2 healthcheck" | ||
- Remove "uiautomator2 identify" | ||
|
||
或者 | ||
## Function changes | ||
### connect_usb | ||
- 2.x connect_usb(serial, init: bool) | ||
- 3.x connect_usb(serial) | ||
|
||
### shell | ||
- 2.x shell(cmdargs, stream: bool, timeout) | ||
- 3.x shell(cmdargs, timeout) | ||
|
||
### push | ||
- 2.x push(src, dst, mode, show_process: bool) | ||
- 3.x push(src, dst, mode) | ||
|
||
### xpath | ||
- 2.x `d.xpath("...").wait() -> XMLElement|None` | ||
- 3.x `d.xpath("...").wait() -> bool` | ||
|
||
### reset_uiautomator | ||
- 2.x reset_uiautomator(self, reason="unknown", depth=0) | ||
- 3.x reset_uiautomator() | ||
|
||
### app_info | ||
2.x Response | ||
|
||
```json | ||
{ | ||
"mainActivity": "com.github.uiautomator.MainActivity", | ||
"label": "ATX", | ||
"versionName": "1.1.7", | ||
"versionCode": 1001007, | ||
"size":1760809 | ||
} | ||
``` | ||
logger = logging.getLogger("uiautomator2") | ||
# 修改logger | ||
|
||
3.x Response | ||
|
||
```json | ||
{ | ||
"versionName": "1.1.7", | ||
"versionCode": 1001007, | ||
} | ||
``` | ||
|
||
### session | ||
- 2.x sess = d.session("com.netease.cloudmusic", attach=True, strict=True) | ||
- 3.x sess = d.session("com.netease.cloudmusic", attach=True) | ||
|
||
It seems the strict is useless, so I delete it. | ||
|
||
### push | ||
- 2.x push(src, dst, mode, show_process:bool=False) | ||
- 3.x push(src, dst, mode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,56 @@ | ||
# coding: utf-8 | ||
# | ||
|
||
|
||
def test_session(sess): | ||
sess.wlan_ip | ||
sess.watcher | ||
sess.jsonrpc | ||
sess.open_identify | ||
sess.shell | ||
sess.set_new_command_timeout | ||
sess.settings | ||
sess.xpath | ||
|
||
|
||
def test_session_app(sess, package_name): | ||
sess.app_start(package_name) | ||
assert sess.app_current()['package'] == package_name | ||
|
||
sess.app_wait(package_name) | ||
assert package_name in sess.app_list() | ||
assert package_name in sess.app_list_running() | ||
|
||
assert sess.app_info(package_name)['packageName'] == package_name | ||
|
||
def test_session_window_size(sess): | ||
assert isinstance(sess.window_size(), tuple) | ||
import pytest | ||
import uiautomator2 as u2 | ||
from uiautomator2.exceptions import SessionBrokenError | ||
|
||
def test_session_function_exists(dev: u2.Device): | ||
dev.wlan_ip | ||
dev.watcher | ||
dev.jsonrpc | ||
dev.shell | ||
dev.settings | ||
dev.xpath | ||
|
||
|
||
def test_app_mixin(dev: u2.Device, package_name: str): | ||
assert package_name in dev.app_list() | ||
dev.app_stop(package_name) | ||
assert package_name not in dev.app_list_running() | ||
dev.app_start(package_name) | ||
assert package_name in dev.app_list_running() | ||
|
||
demo_pid = dev.app_wait(package_name) | ||
current_info = dev.app_current() | ||
assert demo_pid == current_info['pid'] | ||
assert current_info['package'] == package_name | ||
|
||
dev.app_start(package_name, stop=True) | ||
assert demo_pid != dev.app_wait(package_name) | ||
|
||
|
||
def test_session_app(dev: u2.Device, package_name): | ||
dev.app_start(package_name) | ||
assert dev.app_current()['package'] == package_name | ||
|
||
dev.app_wait(package_name) | ||
assert package_name in dev.app_list() | ||
assert package_name in dev.app_list_running() | ||
|
||
with dev.session("io.appium.android.apis") as sess: | ||
sess(text="App").click() | ||
assert sess.running() is True | ||
dev.app_stop("io.appium.android.apis") | ||
assert sess.running() is False | ||
with pytest.raises(SessionBrokenError): | ||
sess(text="App").click() | ||
|
||
with dev.session("io.appium.android.apis") as sess: | ||
sess(text="App").click() | ||
assert sess.running() is True | ||
|
||
|
||
def test_session_window_size(dev: u2.Device): | ||
assert isinstance(dev.window_size(), tuple) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.