blob: d0c329e3ccfc1f4cfd1ed84f944c50e390d1ce1c (
plain)
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
|
use binaryninja::background_task::*;
use binaryninja::headless::Session;
use rstest::*;
#[fixture]
#[once]
fn session() -> Session {
Session::new().expect("Failed to initialize session")
}
#[rstest]
fn test_background_task_registered(_session: &Session) {
let task_progress = "test registered";
let task = BackgroundTask::new(task_progress, false);
BackgroundTask::running_tasks()
.iter()
.find(|t| t.progress_text().as_str() == task_progress)
.expect("Task not running");
task.finish();
let still_running = BackgroundTask::running_tasks()
.iter()
.find(|t| t.progress_text().as_str() == task_progress)
.is_some();
assert!(!still_running, "Task still running");
}
#[rstest]
fn test_background_task_cancellable(_session: &Session) {
let task_progress = "test cancellable";
let task = BackgroundTask::new(task_progress, false);
BackgroundTask::running_tasks()
.iter()
.find(|t| t.progress_text().as_str() == task_progress)
.expect("Task not running");
task.cancel();
assert!(task.is_cancelled());
task.finish();
}
#[rstest]
fn test_background_task_progress(_session: &Session) {
let task = BackgroundTask::new("test progress", false);
let first_progress = task.progress_text().to_string();
assert_eq!(first_progress, "test progress");
task.set_progress_text("new progress");
let second_progress = task.progress_text().to_string();
assert_eq!(second_progress, "new progress");
task.finish();
}
|