mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
chore(repo): remove dead code and useless tests (#3375)
This commit is contained in:
1 parent
7e177a1c90
commit
1cd62eb661
1391 files changed
+783
-120415
No files matched your search
@@ -131,60 +131,3 @@ pub fn keycode_name_or_fallback(keycode: u16) -> String {
|
||||
None => format!("Key{keycode}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn letters_use_apple_hid_positions() {
|
||||
assert_eq!(Some("A"), keycode_to_name(0x00));
|
||||
assert_eq!(Some("Z"), keycode_to_name(0x06));
|
||||
assert_eq!(Some("M"), keycode_to_name(0x2e));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn caps_lock_maps_to_dom_style_name() {
|
||||
assert_eq!(Some("CapsLock"), keycode_to_name(0x39));
|
||||
assert_eq!("CapsLock", keycode_name_or_fallback(0x39));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn modifiers_map_to_side_distinguished_names() {
|
||||
assert_eq!(Some("ShiftLeft"), keycode_to_name(0x38));
|
||||
assert_eq!(Some("ShiftRight"), keycode_to_name(0x3c));
|
||||
assert_eq!(Some("MetaLeft"), keycode_to_name(0x37));
|
||||
assert_eq!(Some("AltLeft"), keycode_to_name(0x3a));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn function_keys_cover_f1_through_f20() {
|
||||
assert_eq!(Some("F1"), keycode_to_name(0x7a));
|
||||
assert_eq!(Some("F12"), keycode_to_name(0x6f));
|
||||
assert_eq!(Some("F13"), keycode_to_name(0x69));
|
||||
assert_eq!(Some("F20"), keycode_to_name(0x5a));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numpad_and_international_keys_map() {
|
||||
assert_eq!(Some("Numpad0"), keycode_to_name(0x52));
|
||||
assert_eq!(Some("NumpadEnter"), keycode_to_name(0x4c));
|
||||
assert_eq!(Some("NumpadEqual"), keycode_to_name(0x51));
|
||||
assert_eq!(Some("NumLock"), keycode_to_name(0x47));
|
||||
assert_eq!(Some("IntlYen"), keycode_to_name(0x5d));
|
||||
assert_eq!(Some("Lang1"), keycode_to_name(0x68));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn arrows_and_editing_keys_map() {
|
||||
assert_eq!(Some("ArrowLeft"), keycode_to_name(0x7b));
|
||||
assert_eq!(Some("ArrowDown"), keycode_to_name(0x7d));
|
||||
assert_eq!(Some("Delete"), keycode_to_name(0x75));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_keycode_falls_back_to_key_n() {
|
||||
assert_eq!(None, keycode_to_name(0xfff));
|
||||
assert_eq!("Key291", keycode_name_or_fallback(0x123));
|
||||
}
|
||||
}
|
||||
@@ -33,14 +33,3 @@ pub fn has_accessibility_permission() -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, not(target_os = "macos")))]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn stub_reports_not_available_off_macos() {
|
||||
assert!(!is_available());
|
||||
assert!(!has_accessibility_permission());
|
||||
}
|
||||
}
|
||||
@@ -104,45 +104,6 @@ pub fn modifier_key_down_from_flags(keycode: u16, flags: u64, was_held: bool) ->
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn no_flags_all_false() {
|
||||
let m = from_flags(0);
|
||||
assert!(!m.ctrl && !m.alt && !m.shift && !m.meta);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn command_alone_sets_only_meta() {
|
||||
let m = from_flags(COMMAND_MASK);
|
||||
assert!(m.meta);
|
||||
assert!(!m.ctrl && !m.alt && !m.shift);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn option_alone_sets_only_alt() {
|
||||
let m = from_flags(ALTERNATE_MASK);
|
||||
assert!(m.alt);
|
||||
assert!(!m.ctrl && !m.meta && !m.shift);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cmd_shift_combo() {
|
||||
let m = from_flags(COMMAND_MASK | SHIFT_MASK);
|
||||
assert!(m.meta && m.shift);
|
||||
assert!(!m.ctrl && !m.alt);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_four_modifiers_together() {
|
||||
let m = from_flags(SHIFT_MASK | CONTROL_MASK | ALTERNATE_MASK | COMMAND_MASK);
|
||||
assert!(m.ctrl && m.alt && m.shift && m.meta);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unrelated_high_bits_ignored() {
|
||||
let m = from_flags(0xff << 32);
|
||||
assert!(!m.ctrl && !m.alt && !m.shift && !m.meta);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn modifier_key_down_uses_the_device_side_bits() {
|
||||
let both_shifts = SHIFT_MASK | DEVICE_LEFT_SHIFT_MASK | DEVICE_RIGHT_SHIFT_MASK;
|
||||
|
||||
@@ -57,65 +57,3 @@ pub fn is_down(event_type: CgEventType) -> bool {
|
||||
CgEventType::LeftMouseDown | CgEventType::RightMouseDown | CgEventType::OtherMouseDown
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn left_and_right_buttons_map_to_0_and_2() {
|
||||
assert_eq!(
|
||||
Classification::Button(0),
|
||||
classify(CgEventType::LeftMouseDown, 0)
|
||||
);
|
||||
assert_eq!(
|
||||
Classification::Button(2),
|
||||
classify(CgEventType::RightMouseUp, 0)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn middle_button_other_2_maps_to_1() {
|
||||
assert_eq!(
|
||||
Classification::Button(1),
|
||||
classify(CgEventType::OtherMouseDown, 2)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn back_forward_other_3_4_map_to_3_and_4() {
|
||||
assert_eq!(
|
||||
Classification::Button(3),
|
||||
classify(CgEventType::OtherMouseDown, 3)
|
||||
);
|
||||
assert_eq!(
|
||||
Classification::Button(4),
|
||||
classify(CgEventType::OtherMouseUp, 4)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_other_button_is_ignored() {
|
||||
assert_eq!(
|
||||
Classification::Ignored,
|
||||
classify(CgEventType::OtherMouseDown, 99)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_down_distinguishes_press_from_release() {
|
||||
assert!(is_down(CgEventType::LeftMouseDown));
|
||||
assert!(!is_down(CgEventType::LeftMouseUp));
|
||||
assert!(is_down(CgEventType::OtherMouseDown));
|
||||
assert!(!is_down(CgEventType::KeyDown));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_u32_maps_known_event_types() {
|
||||
assert_eq!(Some(CgEventType::LeftMouseDown), CgEventType::from_u32(1));
|
||||
assert_eq!(Some(CgEventType::OtherMouseUp), CgEventType::from_u32(26));
|
||||
assert_eq!(None, CgEventType::from_u32(5));
|
||||
assert_eq!(None, CgEventType::from_u32(22));
|
||||
assert_eq!(None, CgEventType::from_u32(999));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user