• Home
  • Raw
  • Download

Lines Matching refs:self

38     def setUp(self):  argument
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)
55 def testProcessLocalImageArgs(self): argument
57 self.Patch(glob, "glob", return_value=["fake.img"])
60 self.Patch(os.path, "exists",
63 self.Patch(os.path, "isdir",
65 self.Patch(os.path, "isfile",
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,
77 self.Patch(utils, "GetBuildEnvironmentVariable",
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)
86 self.args.local_image = constants.FIND_IN_BUILD_ENV
87 self.Patch(utils, "GetBuildEnvironmentVariable",
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)
94 self.Patch(utils, "GetBuildEnvironmentVariable",
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)
102 def testProcessLocalMixedImageArgs(self): argument
106 self.Patch(os.path, "exists",
109 self.Patch(os.path, "isdir",
111 self.Patch(os.path, "isfile",
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
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)
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
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)
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
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)
155 def testProcessImageArgs(self): argument
157 self.Patch(glob, "glob", return_value=["fake.img"])
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)
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,
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,
185 def testGetBranchFromRepo(self, mock_gitremote): argument
195 self.Patch(subprocess, "Popen", return_value=fake_subprocess)
198 self.assertEqual(self.AvdSpec._GetBranchFromRepo(), "aosp-fake_branch")
204 self.Patch(subprocess, "Popen", return_value=fake_subprocess)
205 self.assertEqual(self.AvdSpec._GetBranchFromRepo(), "git_fake_branch")
210 self.Patch(subprocess, "Popen", return_value=fake_subprocess)
211 self.assertEqual(self.AvdSpec._GetBranchFromRepo(), "aosp-master")
213 def testGetBuildBranch(self): argument
220 self.Patch(android_build_client, "AndroidBuildClient",
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),
227 self.Patch(self.AvdSpec, "_GetBranchFromRepo", return_value="repo_branch")
231 self.assertEqual(self.AvdSpec._GetBuildBranch(build_id, build_target),
235 def testGetBuildTarget(self): argument
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),
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),
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),
259 def testProcessHWPropertyWithInvalidArgs(self): argument
265 with self.assertRaises(errors.InvalidHWPropertyError):
266 self.AvdSpec._ProcessHWPropertyArgs(args)
271 with self.assertRaises(errors.InvalidHWPropertyError):
272 self.AvdSpec._ProcessHWPropertyArgs(args)
277 with self.assertRaises(errors.InvalidHWPropertyError):
278 self.AvdSpec._ProcessHWPropertyArgs(args)
283 with self.assertRaises(errors.InvalidHWPropertyError):
284 self.AvdSpec._ProcessHWPropertyArgs(args)
288 def testCheckCFBuildTarget(self, print_warning): argument
291 self.Patch(utils, "GetBuildEnvironmentVariable",
293 self.AvdSpec._CheckCFBuildTarget(constants.INSTANCE_TYPE_REMOTE)
294 self.AvdSpec._CheckCFBuildTarget(constants.INSTANCE_TYPE_LOCAL)
296 self.Patch(utils, "GetBuildEnvironmentVariable",
298 self.AvdSpec._CheckCFBuildTarget(constants.INSTANCE_TYPE_HOST)
300 self.Patch(utils, "GetBuildEnvironmentVariable",
302 self.AvdSpec._CheckCFBuildTarget(constants.INSTANCE_TYPE_REMOTE)
307 def testParseHWPropertyStr(self): argument
312 result_dict = self.AvdSpec._ParseHWPropertyStr(args_str)
313 self.assertTrue(expected_dict == result_dict)
318 result_dict = self.AvdSpec._ParseHWPropertyStr(args_str)
319 self.assertTrue(expected_dict == result_dict)
321 def testGetFlavorFromBuildTargetString(self): argument
324 self.assertEqual(self.AvdSpec._GetFlavorFromString(img_path),
328 self.assertEqual(self.AvdSpec._GetFlavorFromString(
333 self.assertEqual(self.AvdSpec._GetFlavorFromString(img_path),
337 def testProcessRemoteBuildArgs(self): argument
339 self.args.branch = "git_master"
340 self.args.build_id = "1234"
341 self.args.launch_args = None
344 self.args.build_target = "aosp_gce_x86_phone-userdebug"
345 self.AvdSpec._ProcessRemoteBuildArgs(self.args)
346 self.assertTrue(self.AvdSpec.avd_type == "gce")
349 self.args.build_target = "gce_x86_phone-userdebug"
350 self.AvdSpec._ProcessRemoteBuildArgs(self.args)
351 self.assertTrue(self.AvdSpec.avd_type == "gce")
354 self.args.build_target = "aosp_cf_x86_phone-userdebug"
355 self.AvdSpec._ProcessRemoteBuildArgs(self.args)
356 self.assertTrue(self.AvdSpec.avd_type == "cuttlefish")
359 self.args.build_target = "cf_x86_phone-userdebug"
360 self.AvdSpec._ProcessRemoteBuildArgs(self.args)
361 self.assertTrue(self.AvdSpec.avd_type == "cuttlefish")
364 self.args.build_target = "sdk_phone_armv7-sdk"
365 self.AvdSpec._ProcessRemoteBuildArgs(self.args)
366 self.assertTrue(self.AvdSpec.avd_type == "goldfish")
369 self.args.build_target = "aosp_sdk_phone_armv7-sdk"
370 self.AvdSpec._ProcessRemoteBuildArgs(self.args)
371 self.assertTrue(self.AvdSpec.avd_type == "goldfish")
374 self.args.build_target = "mini_emulator_arm64-userdebug"
375 self.args.avd_type = "cuttlefish"
377 self.AvdSpec = avd_spec.AVDSpec(self.args)
378 self.AvdSpec._ProcessRemoteBuildArgs(self.args)
379 self.assertTrue(self.AvdSpec.avd_type == "cuttlefish")
385 self.Patch(config, 'GetAcloudConfig', return_value=cfg)
386 self.AvdSpec = avd_spec.AVDSpec(self.args)
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)
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],
401 def testEscapeAnsi(self): argument
405 self.assertEqual(avd_spec.EscapeAnsi(test_string), expected_result)
407 def testGetGceLocalImagePath(self): argument
409 self.Patch(os.path, "isfile", return_value=True)
412 self.Patch(os.path, "exists", return_value=True)
413 self.assertEqual(self.AvdSpec._GetGceLocalImagePath(fake_image_path),
418 self.assertEqual(self.AvdSpec._GetGceLocalImagePath(fake_image_path),
422 self.Patch(os.path, "isfile", return_value=False)
423 self.Patch(os.path, "exists", return_value=True)
426 self.assertEqual(self.AvdSpec._GetGceLocalImagePath(fake_image_path),
431 self.Patch(os.path, "exists", side_effect=[False, True])
432 self.assertEqual(self.AvdSpec._GetGceLocalImagePath(fake_image_path),
436 self.Patch(os.path, "exists", side_effect=[False, False])
437 self.assertRaises(errors.ImgDoesNotExist,
438 self.AvdSpec._GetGceLocalImagePath, fake_image_path)
440 def testProcessMiscArgs(self): argument
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)
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)
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)
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)
462 self.args.oxygen = True
463 self.AvdSpec._ProcessMiscArgs(self.args)
464 self.assertTrue(self.AvdSpec._oxygen)
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)
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)
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)
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)