fixed GUI update issue on successive transfers
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify progress callback is working
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(0, "src")
|
||||
|
||||
from adb_manager import ADBManager
|
||||
import time
|
||||
|
||||
|
||||
def test_progress_callback():
|
||||
"""Test the progress callback functionality."""
|
||||
print("Testing progress callback...")
|
||||
|
||||
# Track progress updates
|
||||
progress_updates = []
|
||||
|
||||
def progress_callback(percentage):
|
||||
progress_updates.append(percentage)
|
||||
print(f"Progress update: {percentage}%")
|
||||
|
||||
def status_callback(message):
|
||||
print(f"Status: {message}")
|
||||
|
||||
# Create ADB manager and set callbacks
|
||||
adb = ADBManager()
|
||||
adb.set_progress_callback(progress_callback)
|
||||
adb.set_status_callback(status_callback)
|
||||
|
||||
# Test manual progress updates
|
||||
print("\nTesting manual progress updates:")
|
||||
for i in range(0, 101, 25):
|
||||
adb._update_progress(i)
|
||||
time.sleep(0.1)
|
||||
|
||||
print(f"\nProgress updates received: {progress_updates}")
|
||||
print(f"Total updates: {len(progress_updates)}")
|
||||
|
||||
# Test progress parsing
|
||||
print("\nTesting progress parsing:")
|
||||
test_lines = [
|
||||
"Pulling: /sdcard/DCIM/Camera/IMG_20250815_123456.jpg... (25%)",
|
||||
"/sdcard/Documents/file.txt: 1 file pulled. (50%)",
|
||||
"Pulling: /sdcard/Music/song.mp3... (75%)",
|
||||
"3 files pulled. (100%)",
|
||||
"No progress info here",
|
||||
"",
|
||||
]
|
||||
|
||||
for line in test_lines:
|
||||
progress = adb.parse_progress(line)
|
||||
print(f"Line: {repr(line[:50])} -> Progress: {progress}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_progress_callback()
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Debug successive transfers to understand progress bar issue
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
sys.path.insert(0, "src")
|
||||
|
||||
from adb_manager import ADBManager
|
||||
|
||||
|
||||
def test_successive_transfers():
|
||||
"""Test multiple transfers to debug progress issues."""
|
||||
print("Testing successive transfer callbacks...")
|
||||
|
||||
# Track progress updates for each transfer
|
||||
transfer1_progress = []
|
||||
transfer2_progress = []
|
||||
current_transfer = 1
|
||||
|
||||
def progress_callback(percentage):
|
||||
if current_transfer == 1:
|
||||
transfer1_progress.append(percentage)
|
||||
print(f"Transfer 1 - Progress: {percentage}%")
|
||||
else:
|
||||
transfer2_progress.append(percentage)
|
||||
print(f"Transfer 2 - Progress: {percentage}%")
|
||||
|
||||
def status_callback(message):
|
||||
print(f"Transfer {current_transfer} - Status: {message}")
|
||||
|
||||
# Create ADB manager and set callbacks
|
||||
adb = ADBManager()
|
||||
adb.set_progress_callback(progress_callback)
|
||||
adb.set_status_callback(status_callback)
|
||||
|
||||
# Test first transfer simulation
|
||||
print("\n=== FIRST TRANSFER ===")
|
||||
current_transfer = 1
|
||||
print("Simulating first transfer...")
|
||||
adb._update_progress(0)
|
||||
time.sleep(0.5)
|
||||
adb._update_progress(25)
|
||||
time.sleep(0.5)
|
||||
adb._update_progress(50)
|
||||
time.sleep(0.5)
|
||||
adb._update_progress(75)
|
||||
time.sleep(0.5)
|
||||
adb._update_progress(100)
|
||||
|
||||
print(f"First transfer progress updates: {transfer1_progress}")
|
||||
|
||||
# Test second transfer simulation
|
||||
print("\n=== SECOND TRANSFER ===")
|
||||
current_transfer = 2
|
||||
print("Simulating second transfer...")
|
||||
adb._update_progress(0)
|
||||
time.sleep(0.5)
|
||||
adb._update_progress(30)
|
||||
time.sleep(0.5)
|
||||
adb._update_progress(60)
|
||||
time.sleep(0.5)
|
||||
adb._update_progress(90)
|
||||
time.sleep(0.5)
|
||||
adb._update_progress(100)
|
||||
|
||||
print(f"Second transfer progress updates: {transfer2_progress}")
|
||||
|
||||
# Check if callbacks are still working
|
||||
print(f"\nCallback function still set: {adb.progress_callback is not None}")
|
||||
print(f"Status callback still set: {adb.status_callback is not None}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_successive_transfers()
|
||||
Reference in New Issue
Block a user