tests: Verify all bundled layouts

This commit is contained in:
Dorota Czaplejewicz
2019-09-13 09:08:50 +00:00
parent b07689939b
commit edb28cb859
7 changed files with 51 additions and 76 deletions

29
examples/test_layout.rs Normal file
View File

@ -0,0 +1,29 @@
extern crate rs;
extern crate xkbcommon;
use std::env;
use rs::data::{ load_layout_from_resource, LoadError };
use xkbcommon::xkb;
fn check_layout(name: &str) {
let layout = load_layout_from_resource(name)
.and_then(|layout| layout.build().map_err(LoadError::BadKeyMap))
.expect("layout broken");
let context = xkb::Context::new(xkb::CONTEXT_NO_FLAGS);
xkb::Keymap::new_from_string(
&context,
layout.keymap_str
.clone()
.into_string().expect("Failed to decode keymap string"),
xkb::KEYMAP_FORMAT_TEXT_V1,
xkb::KEYMAP_COMPILE_NO_FLAGS,
).expect("Failed to create keymap");
}
fn main() -> () {
check_layout(env::args().nth(1).expect("No argument given").as_str());
}