• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 - The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Tests for avd_spec."""
15
16import glob
17import os
18import subprocess
19import unittest
20
21from unittest import mock
22
23from acloud import errors
24from acloud.create import avd_spec
25from acloud.internal import constants
26from acloud.internal.lib import android_build_client
27from acloud.internal.lib import auth
28from acloud.internal.lib import driver_test_lib
29from acloud.internal.lib import utils
30from acloud.list import list as list_instances
31from acloud.public import config
32
33
34# pylint: disable=invalid-name,protected-access
35class AvdSpecTest(driver_test_lib.BaseDriverTest):
36    """Test avd_spec methods."""
37
38    def setUp(self):
39        """Initialize new avd_spec.AVDSpec."""
40        super().setUp()
41        self.args = mock.MagicMock()
42        self.args.flavor = ""
43        self.args.local_image = None
44        self.args.local_kernel_image = None
45        self.args.local_system_image = None
46        self.args.config_file = ""
47        self.args.build_target = "fake_build_target"
48        self.args.adb_port = None
49        self.args.launch_args = None
50        self.Patch(list_instances, "ChooseOneRemoteInstance", return_value=mock.MagicMock())
51        self.Patch(list_instances, "GetInstancesFromInstanceNames", return_value=mock.MagicMock())
52        self.AvdSpec = avd_spec.AVDSpec(self.args)
53
54    # pylint: disable=protected-access
55    def testProcessLocalImageArgs(self):
56        """Test process args.local_image."""
57        self.Patch(glob, "glob", return_value=["fake.img"])
58        expected_image_artifact = "/path/cf_x86_phone-img-eng.user.zip"
59        expected_image_dir = "/path-to-image-dir"
60        self.Patch(os.path, "exists",
61                   side_effect=lambda path: path in (expected_image_artifact,
62                                                     expected_image_dir))
63        self.Patch(os.path, "isdir",
64                   side_effect=lambda path: path == expected_image_dir)
65        self.Patch(os.path, "isfile",
66                   side_effect=lambda path: path == expected_image_artifact)
67
68        # Specified --local-image to a local zipped image file
69        self.args.local_image = "/path/cf_x86_phone-img-eng.user.zip"
70        self.AvdSpec._avd_type = constants.TYPE_CF
71        self.AvdSpec._instance_type = constants.INSTANCE_TYPE_REMOTE
72        self.AvdSpec._ProcessLocalImageArgs(self.args)
73        self.assertEqual(self.AvdSpec._local_image_artifact,
74                         expected_image_artifact)
75
76        # Specified --local-image to a dir contains images
77        self.Patch(utils, "GetBuildEnvironmentVariable",
78                   return_value="test_cf_x86")
79        self.args.local_image = "/path-to-image-dir"
80        self.AvdSpec._avd_type = constants.TYPE_CF
81        self.AvdSpec._instance_type = constants.INSTANCE_TYPE_REMOTE
82        self.AvdSpec._ProcessLocalImageArgs(self.args)
83        self.assertEqual(self.AvdSpec._local_image_dir, expected_image_dir)
84
85        # Specified local_image without arg
86        self.args.local_image = constants.FIND_IN_BUILD_ENV
87        self.Patch(utils, "GetBuildEnvironmentVariable",
88                   side_effect=["cf_x86_auto", "test_environ", "test_environ"])
89        self.AvdSpec._ProcessLocalImageArgs(self.args)
90        self.assertEqual(self.AvdSpec._local_image_dir, "test_environ")
91        self.assertEqual(self.AvdSpec.local_image_artifact, expected_image_artifact)
92
93        # Specified --avd-type=goldfish --local-image with a dir
94        self.Patch(utils, "GetBuildEnvironmentVariable",
95                   return_value="test_environ")
96        self.args.local_image = "/path-to-image-dir"
97        self.AvdSpec._avd_type = constants.TYPE_GF
98        self.AvdSpec._instance_type = constants.INSTANCE_TYPE_LOCAL
99        self.AvdSpec._ProcessLocalImageArgs(self.args)
100        self.assertEqual(self.AvdSpec._local_image_dir, expected_image_dir)
101
102    def testProcessLocalMixedImageArgs(self):
103        """Test process args.local_kernel_image and args.local_system_image."""
104        expected_image_dir = "/path-to-image-dir"
105        expected_image_file = "/path-to-image-file"
106        self.Patch(os.path, "exists",
107                   side_effect=lambda path: path in (expected_image_file,
108                                                     expected_image_dir))
109        self.Patch(os.path, "isdir",
110                   side_effect=lambda path: path == expected_image_dir)
111        self.Patch(os.path, "isfile",
112                   side_effect=lambda path: path == expected_image_file)
113
114        # Specified --local-kernel-image and --local-system-image with dirs.
115        self.args.local_image = expected_image_dir
116        self.args.local_kernel_image = expected_image_dir
117        self.args.local_system_image = expected_image_dir
118        self.AvdSpec._avd_type = constants.TYPE_CF
119        self.AvdSpec._instance_type = constants.INSTANCE_TYPE_LOCAL
120        with mock.patch("acloud.create.avd_spec.utils."
121                        "GetBuildEnvironmentVariable",
122                        return_value="cf_x86_phone"):
123            self.AvdSpec._ProcessLocalImageArgs(self.args)
124        self.assertEqual(self.AvdSpec.local_image_dir, expected_image_dir)
125        self.assertEqual(self.AvdSpec.local_kernel_image, expected_image_dir)
126        self.assertEqual(self.AvdSpec.local_system_image, expected_image_dir)
127
128        # Specified --local-kernel-image, and --local-system-image with files.
129        self.args.local_image = expected_image_dir
130        self.args.local_kernel_image = expected_image_file
131        self.args.local_system_image = expected_image_file
132        self.AvdSpec._avd_type = constants.TYPE_CF
133        self.AvdSpec._instance_type = constants.INSTANCE_TYPE_LOCAL
134        with mock.patch("acloud.create.avd_spec.utils."
135                        "GetBuildEnvironmentVariable",
136                        return_value="cf_x86_phone"):
137            self.AvdSpec._ProcessLocalImageArgs(self.args)
138        self.assertEqual(self.AvdSpec.local_image_dir, expected_image_dir)
139        self.assertEqual(self.AvdSpec.local_kernel_image, expected_image_file)
140        self.assertEqual(self.AvdSpec.local_system_image, expected_image_file)
141
142        # Specified --avd-type=goldfish, --local_image, and
143        # --local-system-image without args
144        self.args.local_image = constants.FIND_IN_BUILD_ENV
145        self.args.local_system_image = constants.FIND_IN_BUILD_ENV
146        self.AvdSpec._avd_type = constants.TYPE_GF
147        self.AvdSpec._instance_type = constants.INSTANCE_TYPE_LOCAL
148        with mock.patch("acloud.create.avd_spec.utils."
149                        "GetBuildEnvironmentVariable",
150                        return_value=expected_image_dir):
151            self.AvdSpec._ProcessLocalImageArgs(self.args)
152        self.assertEqual(self.AvdSpec.local_image_dir, expected_image_dir)
153        self.assertEqual(self.AvdSpec.local_system_image, expected_image_dir)
154
155    def testProcessImageArgs(self):
156        """Test process image source."""
157        self.Patch(glob, "glob", return_value=["fake.img"])
158        # No specified local_image, image source is from remote
159        self.args.local_image = None
160        self.AvdSpec._ProcessImageArgs(self.args)
161        self.assertEqual(self.AvdSpec._image_source, constants.IMAGE_SRC_REMOTE)
162        self.assertEqual(self.AvdSpec._local_image_dir, None)
163
164        # Specified local_image with an arg for cf type
165        self.Patch(os.path, "isfile", return_value=True)
166        self.args.local_image = "/test_path/cf_x86_phone-img-eng.user.zip"
167        self.AvdSpec._avd_type = constants.TYPE_CF
168        self.AvdSpec._instance_type = constants.INSTANCE_TYPE_REMOTE
169        self.AvdSpec._ProcessImageArgs(self.args)
170        self.assertEqual(self.AvdSpec._image_source, constants.IMAGE_SRC_LOCAL)
171        self.assertEqual(self.AvdSpec._local_image_artifact,
172                         "/test_path/cf_x86_phone-img-eng.user.zip")
173
174        # Specified local_image with an arg for gce type
175        self.Patch(os.path, "isfile", return_value=False)
176        self.Patch(os.path, "exists", return_value=True)
177        self.args.local_image = "/test_path_to_dir/"
178        self.AvdSpec._avd_type = constants.TYPE_GCE
179        self.AvdSpec._ProcessImageArgs(self.args)
180        self.assertEqual(self.AvdSpec._image_source, constants.IMAGE_SRC_LOCAL)
181        self.assertEqual(self.AvdSpec._local_image_artifact,
182                         "/test_path_to_dir/avd-system.tar.gz")
183
184    @mock.patch.object(avd_spec.AVDSpec, "_GetGitRemote")
185    def testGetBranchFromRepo(self, mock_gitremote):
186        """Test get branch name from repo info."""
187        # Check aosp repo gets proper branch prefix.
188        fake_subprocess = mock.MagicMock()
189        fake_subprocess.stdout = mock.MagicMock()
190        fake_subprocess.stdout.readline = mock.MagicMock(return_value='')
191        fake_subprocess.poll = mock.MagicMock(return_value=0)
192        fake_subprocess.returncode = 0
193        return_value = "Manifest branch: fake_branch"
194        fake_subprocess.communicate = mock.MagicMock(return_value=(return_value, ''))
195        self.Patch(subprocess, "Popen", return_value=fake_subprocess)
196
197        mock_gitremote.return_value = "aosp"
198        self.assertEqual(self.AvdSpec._GetBranchFromRepo(), "aosp-fake_branch")
199
200        # Check default repo gets default branch prefix.
201        mock_gitremote.return_value = ""
202        return_value = "Manifest branch: fake_branch"
203        fake_subprocess.communicate = mock.MagicMock(return_value=(return_value, ''))
204        self.Patch(subprocess, "Popen", return_value=fake_subprocess)
205        self.assertEqual(self.AvdSpec._GetBranchFromRepo(), "git_fake_branch")
206
207        # Can't get branch from repo info, set it as default branch.
208        return_value = "Manifest branch:"
209        fake_subprocess.communicate = mock.MagicMock(return_value=(return_value, ''))
210        self.Patch(subprocess, "Popen", return_value=fake_subprocess)
211        self.assertEqual(self.AvdSpec._GetBranchFromRepo(), "aosp-master")
212
213    def testGetBuildBranch(self):
214        """Test GetBuildBranch function"""
215        # Test infer branch from build_id and build_target.
216        build_client = mock.MagicMock()
217        build_id = "fake_build_id"
218        build_target = "fake_build_target"
219        expected_branch = "fake_build_branch"
220        self.Patch(android_build_client, "AndroidBuildClient",
221                   return_value=build_client)
222        self.Patch(auth, "CreateCredentials", return_value=mock.MagicMock())
223        self.Patch(build_client, "GetBranch", return_value=expected_branch)
224        self.assertEqual(self.AvdSpec._GetBuildBranch(build_id, build_target),
225                         expected_branch)
226        # Infer branch from "repo info" when build_id and build_target is None.
227        self.Patch(self.AvdSpec, "_GetBranchFromRepo", return_value="repo_branch")
228        build_id = None
229        build_target = None
230        expected_branch = "repo_branch"
231        self.assertEqual(self.AvdSpec._GetBuildBranch(build_id, build_target),
232                         expected_branch)
233
234    # pylint: disable=protected-access
235    def testGetBuildTarget(self):
236        """Test get build target name."""
237        self.AvdSpec._remote_image[constants.BUILD_BRANCH] = "git_branch"
238        self.AvdSpec._flavor = constants.FLAVOR_IOT
239        self.args.avd_type = constants.TYPE_GCE
240        self.assertEqual(
241            self.AvdSpec._GetBuildTarget(self.args),
242            "gce_x86_64_iot-userdebug")
243
244        self.AvdSpec._remote_image[constants.BUILD_BRANCH] = "aosp-master"
245        self.AvdSpec._flavor = constants.FLAVOR_PHONE
246        self.args.avd_type = constants.TYPE_CF
247        self.assertEqual(
248            self.AvdSpec._GetBuildTarget(self.args),
249            "aosp_cf_x86_64_phone-userdebug")
250
251        self.AvdSpec._remote_image[constants.BUILD_BRANCH] = "git_branch"
252        self.AvdSpec._flavor = constants.FLAVOR_PHONE
253        self.args.avd_type = constants.TYPE_CF
254        self.assertEqual(
255            self.AvdSpec._GetBuildTarget(self.args),
256            "cf_x86_64_phone-userdebug")
257
258    # pylint: disable=protected-access
259    def testProcessHWPropertyWithInvalidArgs(self):
260        """Test _ProcessHWPropertyArgs with invalid args."""
261        # Checking wrong resolution.
262        args = mock.MagicMock()
263        args.hw_property = "cpu:3,resolution:1280"
264        args.reuse_instance_name = None
265        with self.assertRaises(errors.InvalidHWPropertyError):
266            self.AvdSpec._ProcessHWPropertyArgs(args)
267
268        # Checking property should be int.
269        args = mock.MagicMock()
270        args.hw_property = "cpu:3,dpi:fake"
271        with self.assertRaises(errors.InvalidHWPropertyError):
272            self.AvdSpec._ProcessHWPropertyArgs(args)
273
274        # Checking disk property should be with 'g' suffix.
275        args = mock.MagicMock()
276        args.hw_property = "cpu:3,disk:2"
277        with self.assertRaises(errors.InvalidHWPropertyError):
278            self.AvdSpec._ProcessHWPropertyArgs(args)
279
280        # Checking memory property should be with 'g' suffix.
281        args = mock.MagicMock()
282        args.hw_property = "cpu:3,memory:2"
283        with self.assertRaises(errors.InvalidHWPropertyError):
284            self.AvdSpec._ProcessHWPropertyArgs(args)
285
286    # pylint: disable=protected-access
287    @mock.patch.object(utils, "PrintColorString")
288    def testCheckCFBuildTarget(self, print_warning):
289        """Test _CheckCFBuildTarget."""
290        # patch correct env variable.
291        self.Patch(utils, "GetBuildEnvironmentVariable",
292                   return_value="cf_x86_phone-userdebug")
293        self.AvdSpec._CheckCFBuildTarget(constants.INSTANCE_TYPE_REMOTE)
294        self.AvdSpec._CheckCFBuildTarget(constants.INSTANCE_TYPE_LOCAL)
295
296        self.Patch(utils, "GetBuildEnvironmentVariable",
297                   return_value="aosp_cf_arm64_auto-userdebug")
298        self.AvdSpec._CheckCFBuildTarget(constants.INSTANCE_TYPE_HOST)
299        # patch wrong env variable.
300        self.Patch(utils, "GetBuildEnvironmentVariable",
301                   return_value="test_environ")
302        self.AvdSpec._CheckCFBuildTarget(constants.INSTANCE_TYPE_REMOTE)
303
304        print_warning.assert_called_once()
305
306    # pylint: disable=protected-access
307    def testParseHWPropertyStr(self):
308        """Test _ParseHWPropertyStr."""
309        expected_dict = {"cpu": "2", "x_res": "1080", "y_res": "1920",
310                         "dpi": "240", "memory": "4096", "disk": "4096"}
311        args_str = "cpu:2,resolution:1080x1920,dpi:240,memory:4g,disk:4g"
312        result_dict = self.AvdSpec._ParseHWPropertyStr(args_str)
313        self.assertTrue(expected_dict == result_dict)
314
315        expected_dict = {"cpu": "2", "x_res": "1080", "y_res": "1920",
316                         "dpi": "240", "memory": "512", "disk": "4096"}
317        args_str = "cpu:2,resolution:1080x1920,dpi:240,memory:512m,disk:4g"
318        result_dict = self.AvdSpec._ParseHWPropertyStr(args_str)
319        self.assertTrue(expected_dict == result_dict)
320
321    def testGetFlavorFromBuildTargetString(self):
322        """Test _GetFlavorFromLocalImage."""
323        img_path = "/fack_path/cf_x86_tv-img-eng.user.zip"
324        self.assertEqual(self.AvdSpec._GetFlavorFromString(img_path),
325                         "tv")
326
327        build_target_str = "aosp_cf_x86_auto"
328        self.assertEqual(self.AvdSpec._GetFlavorFromString(
329            build_target_str), "auto")
330
331        # Flavor is not supported.
332        img_path = "/fack_path/cf_x86_error-img-eng.user.zip"
333        self.assertEqual(self.AvdSpec._GetFlavorFromString(img_path),
334                         None)
335
336    # pylint: disable=protected-access
337    def testProcessRemoteBuildArgs(self):
338        """Test _ProcessRemoteBuildArgs."""
339        self.args.branch = "git_master"
340        self.args.build_id = "1234"
341        self.args.launch_args = None
342
343        # Verify auto-assigned avd_type if build_targe contains "_gce_".
344        self.args.build_target = "aosp_gce_x86_phone-userdebug"
345        self.AvdSpec._ProcessRemoteBuildArgs(self.args)
346        self.assertTrue(self.AvdSpec.avd_type == "gce")
347
348        # Verify auto-assigned avd_type if build_targe contains "gce_".
349        self.args.build_target = "gce_x86_phone-userdebug"
350        self.AvdSpec._ProcessRemoteBuildArgs(self.args)
351        self.assertTrue(self.AvdSpec.avd_type == "gce")
352
353        # Verify auto-assigned avd_type if build_targe contains "_cf_".
354        self.args.build_target = "aosp_cf_x86_phone-userdebug"
355        self.AvdSpec._ProcessRemoteBuildArgs(self.args)
356        self.assertTrue(self.AvdSpec.avd_type == "cuttlefish")
357
358        # Verify auto-assigned avd_type if build_targe contains "cf_".
359        self.args.build_target = "cf_x86_phone-userdebug"
360        self.AvdSpec._ProcessRemoteBuildArgs(self.args)
361        self.assertTrue(self.AvdSpec.avd_type == "cuttlefish")
362
363        # Verify auto-assigned avd_type if build_targe contains "sdk_".
364        self.args.build_target = "sdk_phone_armv7-sdk"
365        self.AvdSpec._ProcessRemoteBuildArgs(self.args)
366        self.assertTrue(self.AvdSpec.avd_type == "goldfish")
367
368        # Verify auto-assigned avd_type if build_targe contains "_sdk_".
369        self.args.build_target = "aosp_sdk_phone_armv7-sdk"
370        self.AvdSpec._ProcessRemoteBuildArgs(self.args)
371        self.assertTrue(self.AvdSpec.avd_type == "goldfish")
372
373        # Verify auto-assigned avd_type if no match, default as cuttlefish.
374        self.args.build_target = "mini_emulator_arm64-userdebug"
375        self.args.avd_type = "cuttlefish"
376        # reset args.avd_type default value as cuttlefish.
377        self.AvdSpec = avd_spec.AVDSpec(self.args)
378        self.AvdSpec._ProcessRemoteBuildArgs(self.args)
379        self.assertTrue(self.AvdSpec.avd_type == "cuttlefish")
380
381        # Setup acloud config with betty_image spec
382        cfg = mock.MagicMock()
383        cfg.betty_image = 'foobarbaz'
384        cfg.launch_args = None
385        self.Patch(config, 'GetAcloudConfig', return_value=cfg)
386        self.AvdSpec = avd_spec.AVDSpec(self.args)
387        # --betty-image from cmdline should override config
388        self.args.cheeps_betty_image = 'abcdefg'
389        self.AvdSpec._ProcessRemoteBuildArgs(self.args)
390        self.assertEqual(
391            self.AvdSpec.remote_image[constants.CHEEPS_BETTY_IMAGE],
392            self.args.cheeps_betty_image)
393        # acloud config value is used otherwise
394        self.args.cheeps_betty_image = None
395        self.AvdSpec._ProcessRemoteBuildArgs(self.args)
396        self.assertEqual(
397            self.AvdSpec.remote_image[constants.CHEEPS_BETTY_IMAGE],
398            cfg.betty_image)
399
400
401    def testEscapeAnsi(self):
402        """Test EscapeAnsi."""
403        test_string = "\033[1;32;40m Manifest branch:"
404        expected_result = " Manifest branch:"
405        self.assertEqual(avd_spec.EscapeAnsi(test_string), expected_result)
406
407    def testGetGceLocalImagePath(self):
408        """Test get gce local image path."""
409        self.Patch(os.path, "isfile", return_value=True)
410        # Verify when specify --local-image ~/XXX.tar.gz.
411        fake_image_path = "~/gce_local_image_dir/gce_image.tar.gz"
412        self.Patch(os.path, "exists", return_value=True)
413        self.assertEqual(self.AvdSpec._GetGceLocalImagePath(fake_image_path),
414                         "~/gce_local_image_dir/gce_image.tar.gz")
415
416        # Verify when specify --local-image ~/XXX.img.
417        fake_image_path = "~/gce_local_image_dir/gce_image.img"
418        self.assertEqual(self.AvdSpec._GetGceLocalImagePath(fake_image_path),
419                         "~/gce_local_image_dir/gce_image.img")
420
421        # Verify if exist argument --local-image as a directory.
422        self.Patch(os.path, "isfile", return_value=False)
423        self.Patch(os.path, "exists", return_value=True)
424        fake_image_path = "~/gce_local_image_dir/"
425        # Default to find */avd-system.tar.gz if exist then return the path.
426        self.assertEqual(self.AvdSpec._GetGceLocalImagePath(fake_image_path),
427                         "~/gce_local_image_dir/avd-system.tar.gz")
428
429        # Otherwise choose raw file */android_system_disk_syslinux.img if
430        # exist then return the path.
431        self.Patch(os.path, "exists", side_effect=[False, True])
432        self.assertEqual(self.AvdSpec._GetGceLocalImagePath(fake_image_path),
433                         "~/gce_local_image_dir/android_system_disk_syslinux.img")
434
435        # Both _GCE_LOCAL_IMAGE_CANDIDATE could not be found then raise error.
436        self.Patch(os.path, "exists", side_effect=[False, False])
437        self.assertRaises(errors.ImgDoesNotExist,
438                          self.AvdSpec._GetGceLocalImagePath, fake_image_path)
439
440    def testProcessMiscArgs(self):
441        """Test process misc args."""
442        self.args.remote_host = None
443        self.args.local_instance = None
444        self.AvdSpec._ProcessMiscArgs(self.args)
445        self.assertEqual(self.AvdSpec._instance_type, constants.INSTANCE_TYPE_REMOTE)
446
447        self.args.remote_host = None
448        self.args.local_instance = 0
449        self.AvdSpec._ProcessMiscArgs(self.args)
450        self.assertEqual(self.AvdSpec._instance_type, constants.INSTANCE_TYPE_LOCAL)
451
452        self.args.remote_host = "1.1.1.1"
453        self.args.local_instance = None
454        self.AvdSpec._ProcessMiscArgs(self.args)
455        self.assertEqual(self.AvdSpec._instance_type, constants.INSTANCE_TYPE_HOST)
456
457        self.args.remote_host = "1.1.1.1"
458        self.args.local_instance = 1
459        self.AvdSpec._ProcessMiscArgs(self.args)
460        self.assertEqual(self.AvdSpec._instance_type, constants.INSTANCE_TYPE_HOST)
461
462        self.args.oxygen = True
463        self.AvdSpec._ProcessMiscArgs(self.args)
464        self.assertTrue(self.AvdSpec._oxygen)
465
466        # Test avd_spec.autoconnect
467        self.args.autoconnect = False
468        self.AvdSpec._ProcessMiscArgs(self.args)
469        self.assertEqual(self.AvdSpec.autoconnect, False)
470        self.assertEqual(self.AvdSpec.connect_adb, False)
471        self.assertEqual(self.AvdSpec.connect_vnc, False)
472        self.assertEqual(self.AvdSpec.connect_webrtc, False)
473
474        self.args.autoconnect = constants.INS_KEY_VNC
475        self.AvdSpec._ProcessMiscArgs(self.args)
476        self.assertEqual(self.AvdSpec.autoconnect, True)
477        self.assertEqual(self.AvdSpec.connect_adb, True)
478        self.assertEqual(self.AvdSpec.connect_vnc, True)
479        self.assertEqual(self.AvdSpec.connect_webrtc, False)
480
481        self.args.autoconnect = constants.INS_KEY_ADB
482        self.AvdSpec._ProcessMiscArgs(self.args)
483        self.assertEqual(self.AvdSpec.autoconnect, True)
484        self.assertEqual(self.AvdSpec.connect_adb, True)
485        self.assertEqual(self.AvdSpec.connect_vnc, False)
486        self.assertEqual(self.AvdSpec.connect_webrtc, False)
487
488        self.args.autoconnect = constants.INS_KEY_WEBRTC
489        self.AvdSpec._ProcessMiscArgs(self.args)
490        self.assertEqual(self.AvdSpec.autoconnect, True)
491        self.assertEqual(self.AvdSpec.connect_adb, True)
492        self.assertEqual(self.AvdSpec.connect_vnc, False)
493        self.assertEqual(self.AvdSpec.connect_webrtc, True)
494
495
496if __name__ == "__main__":
497    unittest.main()
498