@@ -30,59 +30,71 @@ interface HasAndroidSettings extends HasSettings {
30
30
* by the system), in an attempt to make things less confusing or faster.
31
31
*
32
32
* @param compress ignores unimportant views if true, doesn't ignore otherwise.
33
+ * @return self instance for chaining
33
34
*/
34
- default void ignoreUnimportantViews (Boolean compress ) {
35
+ default HasAndroidSettings ignoreUnimportantViews (Boolean compress ) {
35
36
setSetting (Setting .IGNORE_UNIMPORTANT_VIEWS , compress );
37
+ return this ;
36
38
}
37
39
38
40
/**
39
41
* invoke {@code setWaitForIdleTimeout} in {@code com.android.uiautomator.core.Configurator}.
40
42
*
41
43
* @param timeout A negative value would reset to its default value. Minimum time unit
42
44
* resolution is one millisecond
45
+ * @return self instance for chaining
43
46
*/
44
- default void configuratorSetWaitForIdleTimeout (Duration timeout ) {
47
+ default HasAndroidSettings configuratorSetWaitForIdleTimeout (Duration timeout ) {
45
48
setSetting (Setting .WAIT_FOR_IDLE_TIMEOUT , timeout .toMillis ());
49
+ return this ;
46
50
}
47
51
48
52
/**
49
53
* invoke {@code setWaitForSelectorTimeout} in {@code com.android.uiautomator.core.Configurator}.
50
54
*
51
55
* @param timeout A negative value would reset to its default value. Minimum time unit
52
56
* resolution is one millisecond
57
+ * @return self instance for chaining
53
58
*/
54
- default void configuratorSetWaitForSelectorTimeout (Duration timeout ) {
59
+ default HasAndroidSettings configuratorSetWaitForSelectorTimeout (Duration timeout ) {
55
60
setSetting (Setting .WAIT_FOR_SELECTOR_TIMEOUT , timeout .toMillis ());
61
+ return this ;
56
62
}
57
63
58
64
/**
59
65
* invoke {@code setScrollAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator}.
60
66
*
61
67
* @param timeout A negative value would reset to its default value. Minimum time unit
62
68
* resolution is one millisecond
69
+ * @return self instance for chaining
63
70
*/
64
- default void configuratorSetScrollAcknowledgmentTimeout (Duration timeout ) {
71
+ default HasAndroidSettings configuratorSetScrollAcknowledgmentTimeout (Duration timeout ) {
65
72
setSetting (Setting .WAIT_SCROLL_ACKNOWLEDGMENT_TIMEOUT , timeout .toMillis ());
73
+ return this ;
66
74
}
67
75
68
76
/**
69
77
* invoke {@code configuratorSetKeyInjectionDelay} in {@code com.android.uiautomator.core.Configurator}.
70
78
*
71
79
* @param delay A negative value would reset to its default value. Minimum time unit
72
80
* resolution is one millisecond
81
+ * @return self instance for chaining
73
82
*/
74
- default void configuratorSetKeyInjectionDelay (Duration delay ) {
83
+ default HasAndroidSettings configuratorSetKeyInjectionDelay (Duration delay ) {
75
84
setSetting (Setting .KEY_INJECTION_DELAY , delay .toMillis ());
85
+ return this ;
76
86
}
77
87
78
88
/**
79
89
* invoke {@code setActionAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator}.
80
90
*
81
91
* @param timeout A negative value would reset to its default value. Minimum time unit
82
92
* resolution is one millisecond
93
+ * @return self instance for chaining
83
94
*/
84
- default void configuratorSetActionAcknowledgmentTimeout (Duration timeout ) {
95
+ default HasAndroidSettings configuratorSetActionAcknowledgmentTimeout (Duration timeout ) {
85
96
setSetting (Setting .WAIT_ACTION_ACKNOWLEDGMENT_TIMEOUT , timeout .toMillis ());
97
+ return this ;
86
98
}
87
99
88
100
/**
@@ -93,10 +105,64 @@ default void configuratorSetActionAcknowledgmentTimeout(Duration timeout) {
93
105
* XML parsing exceptions caused by XPath lookup.
94
106
* The Unicode to ASCII transliteration is based on
95
107
* JUnidecode library (https://github.com/gcardone/junidecode).
108
+ * Works for UIAutomator2 only.
96
109
*
97
110
* @param enabled Either true or false. The default value if false.
111
+ * @return self instance for chaining
98
112
*/
99
- default void normalizeTagNames (boolean enabled ) {
113
+ default HasAndroidSettings normalizeTagNames (boolean enabled ) {
100
114
setSetting (Setting .NORMALIZE_TAG_NAMES , enabled );
115
+ return this ;
116
+ }
117
+
118
+ /**
119
+ * Whether to return compact (standards-compliant) and faster responses in find element/s
120
+ * (the default setting). If set to false then the response may also contain other
121
+ * available element attributes.
122
+ *
123
+ * @param enabled Either true or false. The default value if true.
124
+ * @return self instance for chaining
125
+ */
126
+ default HasAndroidSettings setShouldUseCompactResponses (boolean enabled ) {
127
+ setSetting (Setting .SHOULD_USE_COMPACT_RESPONSES , enabled );
128
+ return this ;
129
+ }
130
+
131
+ /**
132
+ * Which attributes should be returned if compact responses are disabled.
133
+ * It works only if shouldUseCompactResponses is false. Defaults to "type,label" string.
134
+ *
135
+ * @param attrNames The comma-separated list of fields to return with each element.
136
+ * @return self instance for chaining
137
+ */
138
+ default HasAndroidSettings setElementResponseAttributes (String attrNames ) {
139
+ setSetting (Setting .ELEMENT_RESPONSE_ATTRIBUTES , attrNames );
140
+ return this ;
141
+ }
142
+
143
+ /**
144
+ * Set whether the source output/xpath search should consider all elements, visible and invisible.
145
+ * Disabling this setting speeds up source and xml search. Works for UIAutomator2 only.
146
+ *
147
+ * @param enabled Either true or false. The default value if false.
148
+ * @return self instance for chaining
149
+ */
150
+ default HasAndroidSettings allowInvisibleElements (boolean enabled ) {
151
+ setSetting (Setting .ALLOW_INVISIBLE_ELEMENTS , enabled );
152
+ return this ;
153
+ }
154
+
155
+ /**
156
+ * Whether to enable or disable the notification listener.
157
+ * No toast notifications are going to be added into page source output if
158
+ * this setting is disabled.
159
+ * Works for UIAutomator2 only.
160
+ *
161
+ * @param enabled Either true or false. The default value if true.
162
+ * @return self instance for chaining
163
+ */
164
+ default HasAndroidSettings enableNotificationListener (boolean enabled ) {
165
+ setSetting (Setting .ENABLE_NOTIFICATION_LISTENER , enabled );
166
+ return this ;
101
167
}
102
168
}
0 commit comments