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
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ socket2 = "0.6" # To disable dual stack on listening, make IPv4 and IPv6 listen
# GUI
slint = { version = "1.17", default-features = false, features=["compat-1-2", "log", "backend-winit", "renderer-winit-software"] }
slint-build = "1.18.0"
i-slint-backend-testing = "1.18.1"
rfd = "0.17"
# Web services
tokio-tungstenite = { version = "0.30", features = [
Expand Down
3 changes: 3 additions & 0 deletions crates/config-unmanaged/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ rfd = { workspace = true }
reqwest = { workspace = true }
tokio = { workspace = true }

[dev-dependencies]
i-slint-backend-testing = { workspace = true }

[build-dependencies]
builder = { path = "../builder" }
slint-build = { workspace = true }
5 changes: 4 additions & 1 deletion crates/config-unmanaged/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
Author: Adolfo Gómez, dkmaster at dkmon dot com
*/
fn main() {
slint_build::compile("src/config.slint").unwrap();
// Element lookup by type in i-slint-backend-testing needs the debug info.
let is_debug_build = std::env::var("PROFILE").as_deref() == Ok("debug");
let config = slint_build::CompilerConfiguration::new().with_debug_info(is_debug_build);
slint_build::compile_with_config("src/config.slint", config).unwrap();
#[cfg(windows)]
builder::build_windows(builder::BuildInfo {
product_name: "UDS Actor Config Unmanaged",
Expand Down
11 changes: 10 additions & 1 deletion crates/config-unmanaged/src/config.slint
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, LineEdit, ComboBox, GroupBox, VerticalBox, HorizontalBox, TabWidget, TextEdit } from "std-widgets.slint";
import { Button, LineEdit, ComboBox, GroupBox, VerticalBox, HorizontalBox, TabWidget, TextEdit, AboutSlint } from "std-widgets.slint";

export component AppWindow inherits Window {
title: "UDS Actor Unmanaged Configuration";
Expand Down Expand Up @@ -153,6 +153,15 @@ export component AppWindow inherits Window {
}
}
}
Tab {
title: "About";
VerticalLayout {
alignment: center;
AboutSlint {
width: 100%;
}
}
}
}

Text {
Expand Down
27 changes: 27 additions & 0 deletions crates/config-unmanaged/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*!
Author: Adolfo Gómez, dkmaster at dkmon dot com
Author: Janier Rodríguez, jrodriguez at virtualcable dot es
*/
#![cfg_attr(not(test), windows_subsystem = "windows")]

Expand Down Expand Up @@ -98,3 +99,29 @@ async fn main() {

ui.run().unwrap();
}

#[cfg(test)]
mod tests {
use super::*;
use i_slint_backend_testing::{AccessibleRole, ElementHandle};
use slint::platform::PointerEventButton;

fn about_widget_count(window: &AppWindow) -> usize {
ElementHandle::find_by_element_type_name(window, "AboutSlint").count()
}

#[test]
fn about_tab_shows_slint_attribution() {
i_slint_backend_testing::init_no_event_loop();
let window = AppWindow::new().unwrap();
window.show().unwrap();
let about_tab = ElementHandle::find_by_accessible_label(&window, "About")
.find(|element| element.accessible_role() == Some(AccessibleRole::Tab))
.expect("About tab not found");
assert_eq!(about_widget_count(&window), 0);

about_tab.mock_single_click(PointerEventButton::Left);

assert_eq!(about_widget_count(&window), 1);
}
}
3 changes: 3 additions & 0 deletions crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ rfd = { workspace = true }
reqwest = { workspace = true }
tokio = { workspace = true }

[dev-dependencies]
i-slint-backend-testing = { workspace = true }

[build-dependencies]
builder = { path = "../builder" }
slint-build = { workspace = true }
5 changes: 4 additions & 1 deletion crates/config/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
Author: Adolfo Gómez, dkmaster at dkmon dot com
*/
fn main() {
slint_build::compile("src/config.slint").unwrap();
// Element lookup by type in i-slint-backend-testing needs the debug info.
let is_debug_build = std::env::var("PROFILE").as_deref() == Ok("debug");
let config = slint_build::CompilerConfiguration::new().with_debug_info(is_debug_build);
slint_build::compile_with_config("src/config.slint", config).unwrap();
#[cfg(windows)]
builder::build_windows(builder::BuildInfo {
product_name: "UDS Actor Config",
Expand Down
27 changes: 27 additions & 0 deletions crates/config/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*!
Author: Adolfo Gómez, dkmaster at dkmon dot com
Author: Janier Rodríguez, jrodriguez at virtualcable dot es
*/
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

Expand Down Expand Up @@ -162,3 +163,29 @@ async fn main() {

ui.run().unwrap();
}

#[cfg(test)]
mod tests {
use super::*;
use i_slint_backend_testing::{AccessibleRole, ElementHandle};
use slint::platform::PointerEventButton;

fn about_widget_count(window: &AppWindow) -> usize {
ElementHandle::find_by_element_type_name(window, "AboutSlint").count()
}

#[test]
fn about_tab_shows_slint_attribution() {
i_slint_backend_testing::init_no_event_loop();
let window = AppWindow::new().unwrap();
window.show().unwrap();
let about_tab = ElementHandle::find_by_accessible_label(&window, "About")
.find(|element| element.accessible_role() == Some(AccessibleRole::Tab))
.expect("About tab not found");
assert_eq!(about_widget_count(&window), 0);

about_tab.mock_single_click(PointerEventButton::Left);

assert_eq!(about_widget_count(&window), 1);
}
}
3 changes: 3 additions & 0 deletions crates/gui-helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ license = "BSD-3-Clause"
slint = { workspace = true }
tokio = { workspace = true }

[dev-dependencies]
i-slint-backend-testing = { workspace = true }

[build-dependencies]
builder = { path = "../builder" }
slint-build = { workspace = true }
5 changes: 4 additions & 1 deletion crates/gui-helper/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
Author: Adolfo Gómez, dkmaster at dkmon dot com
*/
fn main() {
slint_build::compile("src/gui.slint").unwrap();
// Element lookup by id in i-slint-backend-testing needs the debug info.
let is_debug_build = std::env::var("PROFILE").as_deref() == Ok("debug");
let config = slint_build::CompilerConfiguration::new().with_debug_info(is_debug_build);
slint_build::compile_with_config("src/gui.slint", config).unwrap();
#[cfg(windows)]
builder::build_windows(builder::BuildInfo {
product_name: "UDS Actor Client",
Expand Down
18 changes: 17 additions & 1 deletion crates/gui-helper/src/gui.slint
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, VerticalBox } from "std-widgets.slint";
import { Button, VerticalBox, AboutSlint } from "std-widgets.slint";

export component AppWindow inherits Window {
title: root.title_text;
Expand All @@ -7,6 +7,7 @@ export component AppWindow inherits Window {

in-out property <string> title_text: "Message";
in-out property <string> message_text: "";
property <bool> show_about: false;

callback ok_clicked();

Expand All @@ -31,5 +32,20 @@ export component AppWindow inherits Window {
clicked => { root.ok_clicked(); }
}
}

Text {
text: "About";
color: #0055aa;
font-size: 11px;
horizontal-alignment: center;

about-link := TouchArea {
width: 80px;
clicked => { root.show_about = !root.show_about; }
}
}
if root.show_about: AboutSlint {
height: 120px;
}
}
}
24 changes: 24 additions & 0 deletions crates/gui-helper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*!
Author: Adolfo Gómez, dkmaster at dkmon dot com
Author: Janier Rodríguez, jrodriguez at virtualcable dot es
*/
#![cfg_attr(not(test), windows_subsystem = "windows")]

Expand Down Expand Up @@ -107,6 +108,29 @@ fn show_messagebox(title: &str, message: &str) {
#[cfg(test)]
mod tests {
use super::*;
use i_slint_backend_testing::ElementHandle;
use slint::platform::PointerEventButton;

fn about_widget_count(window: &AppWindow) -> usize {
ElementHandle::find_by_element_type_name(window, "AboutSlint").count()
}

#[test]
fn about_link_toggles_slint_attribution() {
i_slint_backend_testing::init_no_event_loop();
let window = AppWindow::new().unwrap();
window.show().unwrap();
let about_link = ElementHandle::find_by_element_id(&window, "AppWindow::about-link")
.next()
.expect("About link not found");
assert_eq!(about_widget_count(&window), 0);

about_link.mock_single_click(PointerEventButton::Left);
assert_eq!(about_widget_count(&window), 1);

about_link.mock_single_click(PointerEventButton::Left);
assert_eq!(about_widget_count(&window), 0);
}

#[test]
#[ignore = "Requires GUI interaction"]
Expand Down
Loading