use kuva::Theme;
use kuva::plot::scatter::ScatterPlot;
use kuva::plot::line::LinePlot;
use kuva::backend::svg::SvgBackend;
use kuva::render::render::render_scatter;
use kuva::render::render::render_line;
use kuva::render::layout::Layout;
#[test]
fn test_theme_dark() {
let plot = ScatterPlot::new()
.with_data(vec![(1.0, 2.0), (3.0, 4.0), (5.0, 6.0)])
.with_color("cyan")
.with_size(4.0);
let layout = Layout::new((0.0, 6.0), (0.0, 7.0))
.with_theme(Theme::dark())
.with_title("Dark Theme Scatter");
let scene = render_scatter(&plot, layout);
let svg = SvgBackend.render_scene(&scene);
std::fs::write("test_outputs/theme_dark.svg", &svg).unwrap();
assert!(svg.contains(r##"fill="#1e1e1e""##), "expected dark background");
assert!(svg.contains(r##"fill="#e0e0e0""##), "expected light text fill");
assert!(svg.contains(r##"stroke="#cccccc""##), "expected themed axis color");
assert!(!svg.contains(r#"stroke="red""#), "should not have red axis");
assert!(!svg.contains(r#"stroke="green""#), "should not have green axis");
}
#[test]
fn test_theme_minimal() {
let plot = LinePlot::new()
.with_data(vec![(0.0, 1.0), (1.0, 3.0), (2.0, 2.0), (3.0, 5.0)])
.with_color("steelblue");
let layout = Layout::new((0.0, 4.0), (0.0, 6.0))
.with_theme(Theme::minimal())
.with_title("Minimal Theme Line");
let scene = render_line(&plot, layout);
let svg = SvgBackend.render_scene(&scene);
std::fs::write("test_outputs/theme_minimal.svg", &svg).unwrap();
assert!(!svg.contains(r##"stroke="#e0e0e0""##), "should have no grid lines");
assert!(svg.contains(r#"font-family="serif""#), "expected serif font");
}
#[test]
fn test_theme_solarized() {
let plot = ScatterPlot::new()
.with_data(vec![(1.0, 1.0), (2.0, 4.0), (3.0, 2.0)])
.with_color("#268bd2")
.with_size(5.0);
let layout = Layout::new((0.0, 4.0), (0.0, 5.0))
.with_theme(Theme::solarized())
.with_title("Solar Scatter");
let scene = render_scatter(&plot, layout);
let svg = SvgBackend.render_scene(&scene);
std::fs::write("test_outputs/theme_solarized.svg", &svg).unwrap();
assert!(svg.contains(r##"fill="#fdf6e3""##), "expected solarized background");
assert!(svg.contains(r##"fill="#657b83""##), "expected solarized text color");
}
#[test]
fn test_theme_override() {
let plot = ScatterPlot::new()
.with_data(vec![(1.0, 2.0), (3.0, 4.0)])
.with_color("red")
.with_size(4.0);
let layout = Layout::new((0.0, 4.0), (0.0, 5.0))
.with_theme(Theme::minimal()) .with_font_family("monospace");
let scene = render_scatter(&plot, layout);
let svg = SvgBackend.render_scene(&scene);
std::fs::write("test_outputs/theme_override.svg", &svg).unwrap();
assert!(svg.contains(r#"font-family="monospace""#), "expected monospace override");
assert!(!svg.contains(r#"font-family="serif""#), "serif should be overridden");
}