ferroui_android/automation/
node_info.rs1pub const ACTION_FOCUS: i32 = 1;
10pub const ACTION_CLEAR_FOCUS: i32 = 2;
12pub const ACTION_SELECT: i32 = 4;
14pub const ACTION_CLICK: i32 = 16;
16pub const ACTION_ACCESSIBILITY_FOCUS: i32 = 64;
18pub const ACTION_CLEAR_ACCESSIBILITY_FOCUS: i32 = 128;
20pub const ACTION_SCROLL_FORWARD: i32 = 4096;
22pub const ACTION_SCROLL_BACKWARD: i32 = 8192;
24pub const ACTION_EXPAND: i32 = 262144;
26pub const ACTION_COLLAPSE: i32 = 524288;
28pub const ACTION_SET_TEXT: i32 = 2097152;
30
31pub const FOCUS_INPUT: i32 = 1;
33pub const FOCUS_ACCESSIBILITY: i32 = 2;
35
36pub const RANGE_TYPE_FLOAT: i32 = 1;
38
39pub const CHECKED_STATE_FALSE: i32 = 0;
41pub const CHECKED_STATE_TRUE: i32 = 1;
42pub const CHECKED_STATE_PARTIAL: i32 = 2;
43
44pub const CONTENT_CHANGE_TYPE_UNDEFINED: i32 = 0;
47pub const CONTENT_CHANGE_TYPE_SUBTREE: i32 = 1;
48pub const CONTENT_CHANGE_TYPE_TEXT: i32 = 2;
49pub const CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION: i32 = 4;
50
51pub const ACCESSIBILITY_LIVE_REGION_NONE: i32 = 0;
53pub const ACCESSIBILITY_LIVE_REGION_POLITE: i32 = 1;
54
55pub const DEFAULT_CLASS_NAME: &str = "android.view.View";
57
58#[derive(Clone, Copy, Debug, PartialEq)]
60pub struct RangeInfo {
61 pub range_type: i32,
62 pub min: f32,
63 pub max: f32,
64 pub current: f32,
65}
66
67#[derive(Clone, Debug, PartialEq)]
69pub struct NodeInfo {
70 pub children: Vec<i32>,
72 pub labeled_by: Vec<i32>,
74 pub class_name: Option<String>,
75 pub unique_id: Option<String>,
76 pub view_id_resource_name: Option<String>,
77 pub enabled: bool,
78 pub screen_reader_focusable: bool,
79 pub focusable: bool,
80 pub accessibility_focused: bool,
81 pub focused: bool,
82 pub bounds_in_screen: Option<(i32, i32, i32, i32)>,
84 pub text: Option<String>,
85 pub content_description: Option<String>,
86 pub actions: Vec<i32>,
88 pub clickable: bool,
89 pub checkable: bool,
90 pub checked: i32,
92 pub scrollable: bool,
93 pub selected: bool,
94 pub editable: bool,
95 pub range_info: Option<RangeInfo>,
96 pub text_selection: Option<(i32, i32)>,
98 pub live_region: i32,
99}
100
101impl Default for NodeInfo {
102 fn default() -> Self {
103 Self::new()
104 }
105}
106
107impl NodeInfo {
108 pub fn new() -> Self {
110 Self {
111 children: Vec::new(),
112 labeled_by: Vec::new(),
113 class_name: None,
114 unique_id: None,
115 view_id_resource_name: None,
116 enabled: false,
117 screen_reader_focusable: false,
118 focusable: false,
119 accessibility_focused: false,
120 focused: false,
121 bounds_in_screen: None,
122 text: None,
123 content_description: None,
124 actions: Vec::new(),
125 clickable: false,
126 checkable: false,
127 checked: CHECKED_STATE_FALSE,
128 scrollable: false,
129 selected: false,
130 editable: false,
131 range_info: None,
132 text_selection: None,
133 live_region: ACCESSIBILITY_LIVE_REGION_NONE,
134 }
135 }
136
137 pub fn add_action(&mut self, action: i32) {
140 if !self.actions.contains(&action) {
141 self.actions.push(action);
142 }
143 }
144
145 pub fn has_action(&self, action: i32) -> bool {
147 self.actions.contains(&action)
148 }
149
150 pub fn action_mask(&self) -> i32 {
152 self.actions.iter().fold(0, |mask, action| mask | action)
153 }
154}