TUT/tests/test_simple_image.cpp
m1ngsama b6150bcab0 feat: Add async image loading with progressive rendering
Phase 10 - Complete async image downloading system

HttpClient enhancements:
- Add ImageDownloadTask structure for async binary downloads
- Implement separate curl multi handle for concurrent image downloads
- Add methods: add_image_download, poll_image_downloads, get_completed_images
- Support configurable concurrency (default: 3 parallel downloads)
- Cancel all images support

Browser improvements:
- Replace synchronous load_images() with async queue_images()
- Progressive rendering - images appear as they download
- Non-blocking UI during image downloads
- Real-time progress display with spinner
- Esc key cancels image loading
- Maintains LRU image cache compatibility

Performance benefits:
- 3x faster image loading (3 concurrent downloads)
- UI remains responsive during downloads
- Users can scroll/navigate while images load
- Gradual page appearance improves perceived performance

Tests:
- test_async_images: Full async download test suite
- test_image_minimal: Minimal async workflow test
- test_simple_image: Basic queueing test

Technical details:
- Dedicated curl multi handle for images (independent of page loading)
- Queue-based download management (pending → loading → completed)
- Progressive relayout as images complete
- Preserves 10-minute LRU image cache
2025-12-28 13:37:54 +08:00

23 lines
629 B
C++

#include "../src/http_client.h"
#include <iostream>
int main() {
std::cout << "Testing basic image download...\n";
try {
HttpClient client;
std::cout << "Client created\n";
client.add_image_download("https://httpbin.org/image/png", nullptr);
std::cout << "Image queued\n";
std::cout << "Pending: " << client.get_pending_image_count() << "\n";
std::cout << "Client will be destroyed\n";
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << "\n";
return 1;
}
std::cout << "Test completed successfully\n";
return 0;
}