add context window monitor
Writes the current context window to logs/current_context_window (uses a symlink to a session ID). This PR was unfortunately generated by a different LLM and did a ton of superficial reformating, it's actually a fairly small and benign change, but I don't want to roll back everything. Hope that's ok.
This commit is contained in:
@@ -3,29 +3,35 @@ use g3_computer_control::*;
|
||||
#[tokio::test]
|
||||
async fn test_screenshot() {
|
||||
let controller = create_controller().expect("Failed to create controller");
|
||||
|
||||
|
||||
// Test that screenshot without window_id fails with appropriate error
|
||||
let path = "/tmp/test_screenshot.png";
|
||||
let result = controller.take_screenshot(path, None, None).await;
|
||||
assert!(result.is_err(), "Expected error when window_id is not provided");
|
||||
|
||||
assert!(
|
||||
result.is_err(),
|
||||
"Expected error when window_id is not provided"
|
||||
);
|
||||
|
||||
let error_msg = result.unwrap_err().to_string();
|
||||
assert!(error_msg.contains("window_id is required"),
|
||||
"Expected error message about window_id being required, got: {}", error_msg);
|
||||
assert!(
|
||||
error_msg.contains("window_id is required"),
|
||||
"Expected error message about window_id being required, got: {}",
|
||||
error_msg
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_screenshot_with_window() {
|
||||
let controller = create_controller().expect("Failed to create controller");
|
||||
|
||||
|
||||
// Take screenshot of Finder (should always be available on macOS)
|
||||
let path = "/tmp/test_screenshot_finder.png";
|
||||
let result = controller.take_screenshot(path, None, Some("Finder")).await;
|
||||
|
||||
|
||||
// This test may fail if Finder is not running, so we just check it doesn't panic
|
||||
// and returns a proper Result
|
||||
let _ = result; // Don't assert success since Finder might not be visible
|
||||
|
||||
|
||||
// Clean up
|
||||
let _ = std::fs::remove_file(path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user