1# Copyright 2017 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5"""An adapter to remotely access the CFM facade on DUT.""" 6 7 8class CFMFacadeRemoteAdapter(object): 9 """CFMFacadeRemoteAdapter is an adapter to remotely control CFM on DUT. 10 11 The Autotest host object representing the remote DUT, passed to this 12 class on initialization, can be accessed from its _client property. 13 """ 14 15 def __init__(self, host, remote_facade_proxy): 16 """Construct a CFMFacadeRemoteAdapter. 17 18 @param host: Host object representing a remote host. 19 @param remote_facade_proxy: RemoteFacadeProxy object. 20 """ 21 self._client = host 22 self._proxy = remote_facade_proxy 23 24 25 @property 26 def _cfm_proxy(self): 27 return self._proxy.cfm 28 29 30 def enroll_device(self): 31 """Enroll device into CFM.""" 32 self._cfm_proxy.enroll_device() 33 34 35 def restart_chrome_for_cfm(self): 36 """Restart chrome for CFM.""" 37 self._cfm_proxy.restart_chrome_for_cfm() 38 39 40 def skip_oobe_after_enrollment(self): 41 """Skips oobe and goes to the app landing page after enrollment.""" 42 self._cfm_proxy.skip_oobe_after_enrollment() 43 44 45 def wait_for_telemetry_commands(self): 46 """Wait for telemetry commands.""" 47 self._cfm_proxy.wait_for_telemetry_commands() 48 49 50 def wait_for_hangouts_telemetry_commands(self): 51 """Wait for Hangouts App telemetry commands.""" 52 self._cfm_proxy.wait_for_hangouts_telemetry_commands() 53 54 55 def wait_for_meetings_telemetry_commands(self): 56 """Waits for Meet App telemetry commands.""" 57 self._cfm_proxy.wait_for_meetings_telemetry_commands() 58 59 60 def wait_for_meetings_in_call_page(self): 61 """Waits for the in-call page to launch.""" 62 self._cfm_proxy.wait_for_meetings_in_call_page() 63 64 65 def wait_for_meetings_landing_page(self): 66 """Waits for the landing page screen.""" 67 self._cfm_proxy.wait_for_meetings_landing_page() 68 69 70 # UI commands/functions 71 def wait_for_oobe_start_page(self): 72 """Wait for oobe start screen to launch.""" 73 self._cfm_proxy.wait_for_oobe_start_page() 74 75 76 def skip_oobe_screen(self): 77 """Skip Chromebox for Meetings oobe screen.""" 78 self._cfm_proxy.skip_oobe_screen() 79 80 81 def is_oobe_start_page(self): 82 """Check if device is on CFM oobe start screen. 83 84 @return a boolean, based on oobe start page status. 85 """ 86 return self._cfm_proxy.is_oobe_start_page() 87 88 89 # Hangouts commands/functions 90 def start_new_hangout_session(self, session_name): 91 """Start a new hangout session. 92 93 @param session_name: Name of the hangout session. 94 """ 95 self._cfm_proxy.start_new_hangout_session(session_name) 96 97 98 def end_hangout_session(self): 99 """End current hangout session.""" 100 self._cfm_proxy.end_hangout_session() 101 102 103 def is_in_hangout_session(self): 104 """Check if device is in hangout session. 105 106 @return a boolean, for hangout session state. 107 """ 108 return self._cfm_proxy.is_in_hangout_session() 109 110 111 def is_ready_to_start_hangout_session(self): 112 """Check if device is ready to start a new hangout session. 113 114 @return a boolean for hangout session ready state. 115 """ 116 return self._cfm_proxy.is_ready_to_start_hangout_session() 117 118 119 def join_meeting_session(self, session_name): 120 """Join a meeting. 121 122 @param session_name: Name of the meeting session. 123 """ 124 self._cfm_proxy.join_meeting_session(session_name) 125 126 127 def start_meeting_session(self): 128 """Start a meeting.""" 129 self._cfm_proxy.start_meeting_session() 130 131 132 def end_meeting_session(self): 133 """End current meeting session.""" 134 self._cfm_proxy.end_meeting_session() 135 136 137 # Diagnostics commands/functions 138 def is_diagnostic_run_in_progress(self): 139 """Check if hotrod diagnostics is running. 140 141 @return a boolean for diagnostic run state. 142 """ 143 return self._cfm_proxy.is_diagnostic_run_in_progress() 144 145 146 def wait_for_diagnostic_run_to_complete(self): 147 """Wait for hotrod diagnostics to complete.""" 148 self._cfm_proxy.wait_for_diagnostic_run_to_complete() 149 150 151 def run_diagnostics(self): 152 """Run hotrod diagnostics.""" 153 self._cfm_proxy.run_diagnostics() 154 155 156 def get_last_diagnostics_results(self): 157 """Get latest hotrod diagnostics results. 158 159 @return a dict with diagnostic test results. 160 """ 161 return self._cfm_proxy.get_last_diagnostics_results() 162 163 164 # Mic audio commands/functions 165 def is_mic_muted(self): 166 """Check if mic is muted. 167 168 @return a boolean for mic mute state. 169 """ 170 return self._cfm_proxy.is_mic_muted() 171 172 173 def mute_mic(self): 174 """Local mic mute from toolbar.""" 175 self._cfm_proxy.mute_mic() 176 177 178 def unmute_mic(self): 179 """Local mic unmute from toolbar.""" 180 self._cfm_proxy.unmute_mic() 181 182 183 def remote_mute_mic(self): 184 """Remote mic mute request from cPanel.""" 185 self._cfm_proxy.remote_mute_mic() 186 187 188 def remote_unmute_mic(self): 189 """Remote mic unmute request from cPanel.""" 190 self._cfm_proxy.remote_unmute_mic() 191 192 193 def get_mic_devices(self): 194 """Get all mic devices detected by hotrod.""" 195 return self._cfm_proxy.get_mic_devices() 196 197 198 def get_preferred_mic(self): 199 """Get mic preferred for hotrod. 200 201 @return a str with preferred mic name. 202 """ 203 return self._cfm_proxy.get_preferred_mic() 204 205 206 def set_preferred_mic(self, mic): 207 """Set preferred mic for hotrod. 208 209 @param mic: String with mic name. 210 """ 211 self._cfm_proxy.set_preferred_mic(mic) 212 213 214 # Speaker commands/functions 215 def get_speaker_devices(self): 216 """Get all speaker devices detected by hotrod. 217 218 @return a list of speaker devices. 219 """ 220 return self._cfm_proxy.get_speaker_devices() 221 222 223 def get_preferred_speaker(self): 224 """Get speaker preferred for hotrod. 225 226 @return a str with preferred speaker name. 227 """ 228 return self._cfm_proxy.get_preferred_speaker() 229 230 231 def set_preferred_speaker(self, speaker): 232 """Set preferred speaker for hotrod. 233 234 @param speaker: String with speaker name. 235 """ 236 self._cfm_proxy.set_preferred_speaker(speaker) 237 238 239 def set_speaker_volume(self, volume_level): 240 """Set speaker volume. 241 242 @param volume_level: String value ranging from 0-100 to set volume to. 243 """ 244 self._cfm_proxy.set_speaker_volume(volume_level) 245 246 247 def get_speaker_volume(self): 248 """Get current speaker volume. 249 250 @return a str value with speaker volume level 0-100. 251 """ 252 return self._cfm_proxy.get_speaker_volume() 253 254 255 def play_test_sound(self): 256 """Play test sound.""" 257 self._cfm_proxy.play_test_sound() 258 259 260 # Camera commands/functions 261 def get_camera_devices(self): 262 """Get all camera devices detected by hotrod. 263 264 @return a list of camera devices. 265 """ 266 return self._cfm_proxy.get_camera_devices() 267 268 269 def get_preferred_camera(self): 270 """Get camera preferred for hotrod. 271 272 @return a str with preferred camera name. 273 """ 274 return self._cfm_proxy.get_preferred_camera() 275 276 277 def set_preferred_camera(self, camera): 278 """Set preferred camera for hotrod. 279 280 @param camera: String with camera name. 281 """ 282 self._cfm_proxy.set_preferred_camera(camera) 283 284 285 def is_camera_muted(self): 286 """Check if camera is muted (turned off). 287 288 @return a boolean for camera muted state. 289 """ 290 return self._cfm_proxy.is_camera_muted() 291 292 293 def mute_camera(self): 294 """Turned camera off.""" 295 self._cfm_proxy.mute_camera() 296 297 298 def unmute_camera(self): 299 """Turned camera on.""" 300 self._cfm_proxy.unmute_camera() 301