mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
Add tests, G513L laptop
This commit is contained in:
@@ -12,7 +12,7 @@ echo '+cargo clippy --all -- -D warnings'
|
||||
cargo clippy --all -- -D warnings
|
||||
|
||||
echo '+cargo test --all'
|
||||
cargo test --all
|
||||
cargo test --all --test-threads=1
|
||||
|
||||
echo '+cargo cranky'
|
||||
cargo cranky
|
||||
cargo cranky
|
||||
|
||||
@@ -52,7 +52,7 @@ test:
|
||||
<<: *rust_cache
|
||||
script:
|
||||
- mkdir -p .git/hooks > /dev/null
|
||||
- cargo test --all
|
||||
- cargo test --all --test-threads=1
|
||||
|
||||
release:
|
||||
only:
|
||||
|
||||
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- Add G512L laptop DB entry
|
||||
|
||||
### Changed
|
||||
- Add more tests to verify things
|
||||
|
||||
### Fix
|
||||
- asusctl incorrectly assumes fan-curves unsupported. Now fixed.
|
||||
|
||||
## [v6.0.7]
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -5,7 +5,6 @@ use std::process::Command;
|
||||
use std::thread::sleep;
|
||||
|
||||
use anime_cli::{AnimeActions, AnimeCommand};
|
||||
use asusd::ctrl_fancurves::FAN_CURVE_ZBUS_NAME;
|
||||
use aura_cli::{LedPowerCommand1, LedPowerCommand2};
|
||||
use dmi_id::DMIID;
|
||||
use fan_curve_cli::FanCurveCommand;
|
||||
@@ -172,7 +171,7 @@ fn do_parsed(
|
||||
handle_throttle_profile(&conn, supported_properties, cmd)?
|
||||
}
|
||||
Some(CliCommand::FanCurve(cmd)) => {
|
||||
handle_fan_curve(&conn, supported_interfaces, cmd)?;
|
||||
handle_fan_curve(&conn, cmd)?;
|
||||
}
|
||||
Some(CliCommand::Graphics(_)) => do_gfx(),
|
||||
Some(CliCommand::Anime(cmd)) => handle_anime(&conn, cmd)?,
|
||||
@@ -807,13 +806,13 @@ fn handle_throttle_profile(
|
||||
|
||||
fn handle_fan_curve(
|
||||
conn: &Connection,
|
||||
supported: &[String],
|
||||
cmd: &FanCurveCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if !supported.contains(&FAN_CURVE_ZBUS_NAME.to_string()) {
|
||||
println!("Fan-curves not supported by either this kernel or by the laptop.");
|
||||
let Ok(fan_proxy) = FanCurvesProxyBlocking::new(conn).map_err(|e| {
|
||||
println!("Fan-curves not supported by either this kernel or by the laptop: {e:?}");
|
||||
}) else {
|
||||
return Err(ProfileError::NotSupported.into());
|
||||
}
|
||||
};
|
||||
|
||||
if !cmd.get_enabled && !cmd.default && cmd.mod_profile.is_none() {
|
||||
if !cmd.help {
|
||||
@@ -838,7 +837,6 @@ fn handle_fan_curve(
|
||||
}
|
||||
|
||||
let plat_proxy = PlatformProxyBlocking::new(conn)?;
|
||||
let fan_proxy = FanCurvesProxyBlocking::new(conn)?;
|
||||
if cmd.get_enabled {
|
||||
let profile = plat_proxy.throttle_thermal_policy()?;
|
||||
let curves = fan_proxy.fan_curve_data(profile)?;
|
||||
|
||||
@@ -134,12 +134,16 @@ impl AuraConfig {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour};
|
||||
use rog_aura::keyboard::AuraPowerState;
|
||||
use rog_aura::{
|
||||
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed,
|
||||
};
|
||||
|
||||
use super::AuraConfig;
|
||||
|
||||
#[test]
|
||||
fn set_multizone_4key_config() {
|
||||
std::env::set_var("BOARD_NAME", "");
|
||||
let mut config = AuraConfig::new("19b6");
|
||||
|
||||
let effect = AuraEffect {
|
||||
@@ -230,6 +234,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn set_multizone_multimode_config() {
|
||||
std::env::set_var("BOARD_NAME", "");
|
||||
let mut config = AuraConfig::new("19b6");
|
||||
|
||||
let effect = AuraEffect {
|
||||
@@ -274,4 +279,66 @@ mod tests {
|
||||
let sta = res.get(&AuraModeNum::Pulse).unwrap();
|
||||
assert_eq!(sta.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verify_0x1866_g531i() {
|
||||
std::env::set_var("BOARD_NAME", "G513I");
|
||||
let mut config = AuraConfig::new("1866");
|
||||
|
||||
assert_eq!(config.brightness, LedBrightness::Med);
|
||||
assert_eq!(config.builtins.len(), 5);
|
||||
assert_eq!(
|
||||
config.builtins.first_entry().unwrap().get(),
|
||||
&AuraEffect {
|
||||
mode: AuraModeNum::Static,
|
||||
zone: AuraZone::None,
|
||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right
|
||||
}
|
||||
);
|
||||
assert_eq!(config.enabled.states.len(), 1);
|
||||
assert_eq!(
|
||||
config.enabled.states[0],
|
||||
AuraPowerState {
|
||||
zone: PowerZones::KeyboardAndLightbar,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verify_0x19b6_g634j() {
|
||||
std::env::set_var("BOARD_NAME", "G634J");
|
||||
let mut config = AuraConfig::new("19b6");
|
||||
|
||||
assert_eq!(config.brightness, LedBrightness::Med);
|
||||
assert_eq!(config.builtins.len(), 12);
|
||||
assert_eq!(
|
||||
config.builtins.first_entry().unwrap().get(),
|
||||
&AuraEffect {
|
||||
mode: AuraModeNum::Static,
|
||||
zone: AuraZone::None,
|
||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right
|
||||
}
|
||||
);
|
||||
assert_eq!(config.enabled.states.len(), 4);
|
||||
assert_eq!(
|
||||
config.enabled.states[0],
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,15 @@
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
(
|
||||
device_name: "G512L",
|
||||
product_id: "",
|
||||
layout_name: "g512",
|
||||
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
|
||||
basic_zones: [Key1, Key2, Key3, Key4],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
device_name: "G513I",
|
||||
product_id: "",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::env;
|
||||
|
||||
use dmi_id::DMIID;
|
||||
use log::{error, info, warn};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
@@ -60,7 +62,10 @@ impl LedSupportData {
|
||||
/// matches against laptops first, then will proceed with matching the
|
||||
/// `device_name` if there are no DMI matches.
|
||||
pub fn get_data(product_id: &str) -> Self {
|
||||
let dmi = DMIID::new().unwrap_or_default();
|
||||
let mut dmi = DMIID::new().unwrap_or_default();
|
||||
if let Ok(board_name) = env::var("BOARD_NAME") {
|
||||
dmi.board_name = board_name;
|
||||
}
|
||||
// let prod_family = dmi.product_family().expect("Could not get
|
||||
// product_family");
|
||||
|
||||
|
||||
@@ -434,7 +434,7 @@ impl From<AuraZone> for i32 {
|
||||
/// ```
|
||||
#[typeshare]
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||
pub struct AuraEffect {
|
||||
/// The effect type
|
||||
pub mode: AuraModeNum,
|
||||
|
||||
@@ -488,7 +488,7 @@ mod tests {
|
||||
let rows = &data.key_rows;
|
||||
for row in rows {
|
||||
for k in &row.row {
|
||||
if data.key_shapes.get(&k.1).is_some() {
|
||||
if data.key_shapes.contains_key(&k.1) {
|
||||
unused.remove(&k.1);
|
||||
} else {
|
||||
panic!("Key {:?} was missing matching shape {}", k.0, k.1);
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
use log::{error, info};
|
||||
use rog_aura::keyboard::LaptopAuraPower;
|
||||
use rog_aura::{AuraDeviceType, PowerZones};
|
||||
use rog_dbus::zbus_aura::AuraProxy;
|
||||
use slint::{ComponentHandle, Model, RgbaColor, SharedString};
|
||||
|
||||
@@ -84,24 +85,40 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
set_ui_props_async!(handle, aura, AuraPageData, led_power);
|
||||
set_ui_props_async!(handle, aura, AuraPageData, device_type);
|
||||
|
||||
if let Ok(pow3r) = aura.supported_power_zones().await {
|
||||
if let Ok(mut pow3r) = aura.supported_power_zones().await {
|
||||
let dev_type = aura
|
||||
.device_type()
|
||||
.await
|
||||
.unwrap_or(AuraDeviceType::LaptopPost2021);
|
||||
log::debug!("Available LED power modes {pow3r:?}");
|
||||
handle
|
||||
.upgrade_in_event_loop(move |handle| {
|
||||
let power: Vec<SlintPowerZones> = pow3r.iter().map(|p| (*p).into()).collect();
|
||||
let names: Vec<SharedString> = handle
|
||||
.global::<AuraPageData>()
|
||||
.get_power_zone_names()
|
||||
.iter()
|
||||
.collect();
|
||||
let names: Vec<SharedString> =
|
||||
pow3r.iter().map(|n| names[(*n) as usize].clone()).collect();
|
||||
handle
|
||||
.global::<AuraPageData>()
|
||||
.set_supported_power_zones(power.as_slice().into());
|
||||
handle
|
||||
.global::<AuraPageData>()
|
||||
.set_power_zone_names_old(names.as_slice().into());
|
||||
|
||||
if dev_type.is_old_laptop() {
|
||||
// Need to add the specific KeyboardAndLightbar
|
||||
if pow3r.contains(&PowerZones::Keyboard)
|
||||
&& pow3r.contains(&PowerZones::Lightbar)
|
||||
{
|
||||
pow3r.push(PowerZones::KeyboardAndLightbar);
|
||||
}
|
||||
let names: Vec<SharedString> =
|
||||
pow3r.iter().map(|n| names[(*n) as usize].clone()).collect();
|
||||
handle
|
||||
.global::<AuraPageData>()
|
||||
.set_power_zone_names_old(names.as_slice().into());
|
||||
} else {
|
||||
let power: Vec<SlintPowerZones> =
|
||||
pow3r.iter().map(|p| (*p).into()).collect();
|
||||
|
||||
handle
|
||||
.global::<AuraPageData>()
|
||||
.set_supported_power_zones(power.as_slice().into());
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2024-05-14 05:08+0000\n"
|
||||
"POT-Creation-Date: 2024-05-16 21:35+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -642,42 +642,42 @@ msgctxt "AuraPowerGroupOld"
|
||||
msgid "Sleep"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/main_window.slint:50
|
||||
#: rog-control-center/ui/main_window.slint:51
|
||||
msgctxt "MainWindow"
|
||||
msgid "ROG"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/main_window.slint:52
|
||||
#: rog-control-center/ui/main_window.slint:53
|
||||
msgctxt "Menu1"
|
||||
msgid "System Control"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/main_window.slint:53
|
||||
#: rog-control-center/ui/main_window.slint:54
|
||||
msgctxt "Menu2"
|
||||
msgid "Keyboard Aura"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/main_window.slint:54
|
||||
#: rog-control-center/ui/main_window.slint:55
|
||||
msgctxt "Menu3"
|
||||
msgid "AniMe Matrix"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/main_window.slint:55
|
||||
#: rog-control-center/ui/main_window.slint:56
|
||||
msgctxt "Menu4"
|
||||
msgid "Fan Curves"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/main_window.slint:56
|
||||
#: rog-control-center/ui/main_window.slint:57
|
||||
msgctxt "Menu5"
|
||||
msgid "App Settings"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/main_window.slint:57
|
||||
#: rog-control-center/ui/main_window.slint:58
|
||||
msgctxt "Menu6"
|
||||
msgid "About"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/main_window.slint:69
|
||||
#: rog-control-center/ui/main_window.slint:70
|
||||
msgctxt "MainWindow"
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
@@ -5,6 +5,7 @@ import { SideBar } from "widgets/sidebar.slint";
|
||||
import { PageAbout } from "pages/about.slint";
|
||||
import { PageFans } from "pages/fans.slint";
|
||||
import { PageAnime, AnimePageData } from "pages/anime.slint";
|
||||
import { RogItem } from "widgets/common.slint";
|
||||
import { PageAura } from "pages/aura.slint";
|
||||
import { Node } from "widgets/graph.slint";
|
||||
export { Node }
|
||||
@@ -178,4 +179,39 @@ export component MainWindow inherits Window {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if SomeError.error_message != "": Rectangle {
|
||||
x: 0px;
|
||||
y: 0px;
|
||||
width: root.width;
|
||||
height: root.height;
|
||||
padding: 10px;
|
||||
|
||||
background: Palette.background;
|
||||
border-color: Palette.border;
|
||||
border-width: 3px;
|
||||
border-radius: 10px;
|
||||
|
||||
VerticalBox {
|
||||
RogItem {
|
||||
min-height: 50px;
|
||||
max-height: 100px;
|
||||
Text {
|
||||
text <=> SomeError.error_message;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text <=> SomeError.error_help;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export global SomeError {
|
||||
in property <string> error_message: "";
|
||||
in property <string> error_help: "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user