-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_device_wait.py
More file actions
executable file
·193 lines (167 loc) · 6.43 KB
/
test_device_wait.py
File metadata and controls
executable file
·193 lines (167 loc) · 6.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/env python3
"""
Test script that waits for device authorization and then runs full tests
"""
import time
import subprocess
from windscribe_ip_changer import WindscribeIPChanger
def wait_for_device_authorization(adb_path, max_wait=60):
"""Wait for device to be authorized"""
print("Waiting for device authorization...")
print("Please accept the USB debugging prompt on your Android device.")
print("(Check 'Always allow from this computer' to avoid this in the future)\n")
start_time = time.time()
while time.time() - start_time < max_wait:
try:
result = subprocess.run(
[adb_path, "devices"],
capture_output=True,
text=True
)
if result.returncode == 0:
lines = result.stdout.strip().split("\n")
for line in lines[1:]:
if line.strip():
parts = line.split()
if len(parts) >= 2:
device_id = parts[0]
status = parts[1]
if status.lower() == "device":
print(f"✓ Device {device_id} is now authorized!")
return device_id
elif status.lower() == "unauthorized":
print(".", end="", flush=True)
time.sleep(2)
break
except:
pass
print(f"\n✗ Device not authorized within {max_wait} seconds")
return None
def run_full_test(device_id=None):
"""Run comprehensive tests on the device"""
print("\n" + "=" * 60)
print("Running Full Device Tests")
print("=" * 60)
changer = WindscribeIPChanger(device_id=device_id)
# Test 1: Device connection
print("\n[1/6] Testing device connection...")
if not changer.check_adb_connection():
print("✗ Device connection failed")
return False
print("✓ Device connected")
device_name = changer.get_connected_device()
print(f" Device ID: {device_name}")
# Test 2: Screen detection
print("\n[2/6] Testing screen size detection...")
try:
screen_width, screen_height = changer._get_screen_size()
print(f"✓ Screen size: {screen_width}x{screen_height}")
print(f" Center coordinates: ({screen_width // 2}, {screen_height // 2})")
except Exception as e:
print(f"✗ Screen detection failed: {e}")
return False
# Test 3: Windscribe detection
print("\n[3/6] Testing Windscribe installation...")
if not changer.check_windscribe_installed():
print("✗ Windscribe not found!")
print(" Please install Windscribe app from Google Play Store")
return False
print("✓ Windscribe found")
package = changer.get_windscribe_package_name()
if package:
print(f" Package: {package}")
print(" Type: Android App (UI automation enabled)")
else:
print(" Type: CLI")
# Test 4: Current status
print("\n[4/6] Checking current Windscribe status...")
status = changer.get_windscribe_status()
if status:
print(f" Status: {status}")
else:
print(" Status: Not connected")
ip = changer.get_current_ip()
if ip:
print(f" Current IP: {ip}")
else:
print(" IP: Could not determine")
# Test 5: UI automation capabilities
print("\n[5/6] Testing UI automation capabilities...")
if package:
print("✓ UI automation methods available:")
print(" - Screen size detection: ✓")
print(" - Tap simulation: ✓")
print(" - Text input: ✓")
print(" - Swipe simulation: ✓")
# Test a tap
screen_width, screen_height = changer._get_screen_size()
center_x = screen_width // 2
center_y = screen_height // 2
print(f"\n Testing tap at ({center_x}, {center_y})...")
if changer._tap(center_x, center_y):
print(" ✓ Tap command executed successfully")
else:
print(" ⚠ Tap command may have failed")
else:
print(" UI automation: Not needed (CLI mode)")
# Test 6: Connection flow (optional)
print("\n[6/6] Connection flow test (optional)...")
print(" This will test the full UI automation flow.")
print(" Note: This will interact with the Windscribe app on your device.")
response = input(" Proceed with connection test? (y/N): ").strip().lower()
if response == 'y':
print("\n Testing disconnect...")
changer.disconnect_windscribe()
time.sleep(2)
print("\n Testing connect to 'us-east'...")
if changer.connect_windscribe("us-east"):
print(" ✓ Connection completed")
time.sleep(3)
status = changer.get_windscribe_status()
ip = changer.get_current_ip()
print(f" Final Status: {status}")
print(f" Final IP: {ip}")
else:
print(" ✗ Connection failed")
else:
print(" Skipped by user")
print("\n" + "=" * 60)
print("✓ All tests completed!")
print("=" * 60)
return True
def main():
print("=" * 60)
print("Windscribe IP Changer - Device Testing")
print("=" * 60)
# Check ADB
changer = WindscribeIPChanger()
if not changer.adb_path:
print("✗ ADB not found!")
print("Please install ADB: sudo pacman -S android-tools")
return
print(f"✓ ADB found: {changer.adb_path}\n")
# Check for devices
devices = changer.list_devices()
if not devices:
# Check for unauthorized devices
result = subprocess.run(
[changer.adb_path, "devices"],
capture_output=True,
text=True
)
if "unauthorized" in result.stdout:
device_id = wait_for_device_authorization(changer.adb_path)
if not device_id:
print("\n✗ Cannot proceed without authorized device")
return
else:
print("✗ No devices connected!")
print("Please connect your Android device via USB")
return
else:
device_id = devices[0]["device_id"]
print(f"✓ Device found: {device_id}\n")
# Run full test
run_full_test(device_id)
if __name__ == "__main__":
main()