Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ include = ["src/*.rs", "LICENSE-MIT", "LICENSE-APACHE", "Cargo.toml"]
rust-version = "1.76"

[dependencies]
egui = { version = "0.28", default-features = false }
serde_json = { version = "1.0.104", optional = true }
simd-json = { version = "0.13.8", optional = true }
egui = { version = "0.29", default-features = false }
serde_json = { version = "1", optional = true }
simd-json = { version = "0.13", optional = true }

[dev-dependencies]
eframe = "0.28"
eframe = "0.29"

[features]
default = ["serde_json"]
Expand Down
34 changes: 18 additions & 16 deletions tests/json_tree_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use egui::{CentralPanel, Context, FontDefinitions, Style};
use std::sync::Arc;

use egui::{mutex::Mutex, CentralPanel, Context, FontDefinitions, Style};
use egui_json_tree::{render::RenderContext, DefaultExpand, JsonTree};
#[cfg(feature = "serde_json")]
use serde_json::{json, Value};
Expand Down Expand Up @@ -39,12 +41,12 @@ impl<'a, 'b> From<RenderContext<'a, 'b, Value>> for ExpectedRender {
fn json_tree_render_string() {
let value = json!("Hello World!");

let mut actual: Vec<ExpectedRender> = vec![];
let actual: Arc<Mutex<Vec<ExpectedRender>>> = Arc::new(Mutex::new(vec![]));

egui::__run_test_ui(|ui| {
JsonTree::new("id", &value)
.on_render(|_, render_ctx| {
actual.push(render_ctx.into());
actual.lock().push(render_ctx.into());
})
.show(ui);
});
Expand All @@ -55,7 +57,7 @@ fn json_tree_render_string() {
pointer_str: "".to_string(),
}];

assert_eq!(actual, expected);
assert_eq!(actual.lock().as_slice(), expected);
}

#[test]
Expand All @@ -68,13 +70,13 @@ fn json_tree_default_expand_none() {
}
});

let mut actual: Vec<ExpectedRender> = vec![];
let actual: Arc<Mutex<Vec<ExpectedRender>>> = Arc::new(Mutex::new(vec![]));

egui::__run_test_ui(|ui| {
JsonTree::new("id", &value)
.default_expand(DefaultExpand::None)
.on_render(|_, render_ctx| {
actual.push(render_ctx.into());
actual.lock().push(render_ctx.into());
})
.show(ui);
});
Expand Down Expand Up @@ -109,7 +111,7 @@ fn json_tree_default_expand_none() {
pointer_str: "".to_string(),
},
];
assert_eq!(actual, expected);
assert_eq!(actual.lock().as_slice(), expected);
}

#[test]
Expand All @@ -122,13 +124,13 @@ fn json_tree_default_expand_all() {
}
});

let mut actual: Vec<ExpectedRender> = vec![];
let actual: Arc<Mutex<Vec<ExpectedRender>>> = Arc::new(Mutex::new(vec![]));

egui::__run_test_ui(|ui| {
JsonTree::new("id", &value)
.default_expand(DefaultExpand::All)
.on_render(|_, render_ctx| {
actual.push(render_ctx.into());
actual.lock().push(render_ctx.into());
})
.show(ui);
});
Expand Down Expand Up @@ -197,7 +199,7 @@ fn json_tree_default_expand_all() {
pointer_str: "".to_string(),
},
];
assert_eq!(actual, expected);
assert_eq!(actual.lock().as_slice(), expected);
}

#[test]
Expand All @@ -213,13 +215,13 @@ fn json_tree_default_expand_to_level_one() {
}
});

let mut actual: Vec<ExpectedRender> = vec![];
let actual: Arc<Mutex<Vec<ExpectedRender>>> = Arc::new(Mutex::new(vec![]));

egui::__run_test_ui(|ui| {
JsonTree::new("id", &value)
.default_expand(DefaultExpand::ToLevel(1))
.on_render(|_, render_ctx| {
actual.push(render_ctx.into());
actual.lock().push(render_ctx.into());
})
.show(ui);
});
Expand Down Expand Up @@ -295,7 +297,7 @@ fn json_tree_default_expand_to_level_one() {
},
];

assert_eq!(actual, expected);
assert_eq!(actual.lock().as_slice(), expected);
}

#[test]
Expand All @@ -314,13 +316,13 @@ fn json_tree_default_expand_search() {
}
});

let mut actual: Vec<ExpectedRender> = vec![];
let actual: Arc<Mutex<Vec<ExpectedRender>>> = Arc::new(Mutex::new(vec![]));

egui::__run_test_ui(|ui| {
JsonTree::new("id", &value)
.default_expand(DefaultExpand::SearchResults("t"))
.on_render(|_, render_ctx| {
actual.push(render_ctx.into());
actual.lock().push(render_ctx.into());
})
.show(ui);
});
Expand Down Expand Up @@ -443,7 +445,7 @@ fn json_tree_default_expand_search() {
},
];

assert_eq!(actual, expected);
assert_eq!(actual.lock().as_slice(), expected);
}

#[test]
Expand Down