2021-12-14 16:25:31 +00:00
|
|
|
use ki18n::klocalizedcontext::KLocalizedContext;
|
2021-12-23 12:05:16 +00:00
|
|
|
use qttypes::QString;
|
|
|
|
|
|
|
|
#[cfg(feature = "qmetaobject")]
|
|
|
|
use qmetaobject::QmlEngine;
|
|
|
|
|
2021-12-01 12:04:45 +00:00
|
|
|
mod common;
|
|
|
|
|
|
|
|
#[test]
|
2021-12-23 12:05:16 +00:00
|
|
|
#[cfg(feature = "qmetaobject")]
|
2021-12-01 12:04:45 +00:00
|
|
|
fn cpp_ptr() {
|
|
|
|
let _lock = common::lock_for_test();
|
|
|
|
|
|
|
|
let engine = QmlEngine::new();
|
|
|
|
let context = KLocalizedContext::init_from_engine(&engine);
|
|
|
|
|
|
|
|
let context_ptr = context.cpp_ptr();
|
|
|
|
assert_ne!(std::ptr::null(), context_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-12-23 12:05:16 +00:00
|
|
|
#[cfg(feature = "qmetaobject")]
|
2021-12-01 12:04:45 +00:00
|
|
|
fn translation_domain() {
|
|
|
|
let _lock = common::lock_for_test();
|
|
|
|
|
|
|
|
let engine = QmlEngine::new();
|
|
|
|
let mut context = KLocalizedContext::init_from_engine(&engine);
|
|
|
|
|
|
|
|
const TRANSLATION_DOMAIN: &str = "Test Domain";
|
|
|
|
context.set_translation_domain(TRANSLATION_DOMAIN.into());
|
|
|
|
|
|
|
|
let domain = context.translation_domain();
|
|
|
|
|
|
|
|
assert_eq!(domain, QString::from(TRANSLATION_DOMAIN));
|
|
|
|
}
|