test: 添加 Windows 测试脚本
- test_network.py: 网络功能测试 (IP/DNS/WiFi/流量) - test_system.py: 系统工具测试 (设备信息/电源/进程) - test_android_api.py: Android API 综合测试 (Intent/集合/文件/Base64/数学/日历) - 所有测试通过
This commit is contained in:
1 parent
b3d75f8cc2
commit
144b5ce45e
7 files changed
+311
No files matched your search
@@ -0,0 +1,73 @@
|
||||
"""
|
||||
网络测试脚本 - 基于 Android-pyApi
|
||||
模拟 Operit 的 network_test.js 功能
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from android_pyapi import (
|
||||
ConnectivityManager, NetworkInfo, Intent, Uri
|
||||
)
|
||||
from android_pyapi._windows_impl import WindowsNetwork
|
||||
|
||||
|
||||
def test_network():
|
||||
"""测试网络功能"""
|
||||
print("=" * 60)
|
||||
print("Android-pyApi 网络测试")
|
||||
print("=" * 60)
|
||||
|
||||
# 1. 获取 IP 地址
|
||||
print("\n[1] IP 地址:")
|
||||
ip = WindowsNetwork.get_ip_address()
|
||||
print(f" 本机 IP: {ip}")
|
||||
|
||||
# 2. 网络连通性
|
||||
print("\n[2] 网络连通性:")
|
||||
connected = WindowsNetwork.get_connectivity()
|
||||
print(f" 连接状态: {'已连接' if connected else '未连接'}")
|
||||
|
||||
# 3. WiFi 信息
|
||||
print("\n[3] WiFi 信息:")
|
||||
wifi = WindowsNetwork.get_wifi_info()
|
||||
print(f" SSID: {wifi.get('ssid', 'N/A') or 'N/A'}")
|
||||
print(f" 信号: {wifi.get('signal', 0)}%")
|
||||
print(f" 状态: {wifi.get('status', 'unknown')}")
|
||||
|
||||
# 4. DNS 服务器
|
||||
print("\n[4] DNS 服务器:")
|
||||
dns = WindowsNetwork.get_dns_servers()
|
||||
for d in dns[:3]:
|
||||
print(f" - {d}")
|
||||
|
||||
# 5. 默认网关
|
||||
print("\n[5] 默认网关:")
|
||||
gw = WindowsNetwork.get_gateway()
|
||||
print(f" 网关: {gw}")
|
||||
|
||||
# 6. MAC 地址
|
||||
print("\n[6] MAC 地址:")
|
||||
mac = WindowsNetwork.get_mac_address()
|
||||
print(f" MAC: {mac}")
|
||||
|
||||
# 7. 网络接口
|
||||
print("\n[7] 网络接口:")
|
||||
interfaces = WindowsNetwork.get_interfaces()
|
||||
for iface in interfaces[:5]:
|
||||
print(f" - {iface.get('ifname', 'N/A')}: {iface.get('operstate', 'N/A')}")
|
||||
|
||||
# 8. 流量统计
|
||||
print("\n[8] 流量统计:")
|
||||
traffic = WindowsNetwork.get_rx_tx_bytes()
|
||||
print(f" 接收: {traffic.get('rx_bytes', 0) / 1024 / 1024:.2f} MB")
|
||||
print(f" 发送: {traffic.get('tx_bytes', 0) / 1024 / 1024:.2f} MB")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("测试完成!")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_network()
|
||||
Reference in new issue
Block a user