def Page_Check(self, x, y):
# 防止概率出现的坐标点击失效情况
while (1):
point_back_shot_test = self.d.find_component(
BY.text("拍照")).getBoundsCenter()
print(point_back_shot_test.X, point_back_shot_test.Y)
if (point_back_shot_test.X >= 580 and point_back_shot_test.X <= 712) and (
point_back_shot_test.Y >= 2073 and point_back_shot_test.Y <= 2165):
print("======当前页面为拍照页面======")
break
print("======目前在专业相机页面======")
self.d.touch((x, y))
time.sleep(1)
def ResourceUsage_PerformanceDynamic_Camera_0010(self):
# 1. 打开相机,等待5s
self.d.start_app("com.huawei.camera", "com.huawei.camera")
time.sleep(5)
# 2. 点击拍照模式,等待2s
self.d.touch(BY.text("拍照"))
time.sleep(2)
#
# CommonUtilsAOSP.camera_record_settings(self.d, "[16:9] 1080p", "30 fps")
# 2. 获取测试过程需要的坐标点点击人像模式
point_back_people = self.d.find_component(BY.text("人像")).getBoundsCenter()
center_point = self.d.find_component(BY.key("com.huawei.camera:id/main_view_base")).getBoundsCenter()
self.d.touch((point_back_people.X, point_back_people.Y))
# 切换到录像模式
point_back_video = self.d.find_component(BY.text("录像")).getBoundsCenter()
self.d.touch((point_back_video.X, point_back_video.Y))
# 切换到专业模式
point_back_pro = self.d.find_component(BY.text("专业")).getBoundsCenter()
self.d.touch((point_back_pro.X, point_back_pro.Y))
# 切换到拍照模式
point_back_shot = self.d.find_component(BY.text("拍照")).getBoundsCenter()
self.d.touch((point_back_shot.X, point_back_shot.Y))
time.sleep(1)
print(point_back_shot.X, point_back_shot.Y)
# 防止概率出现的坐标点击失效情况
self.Page_Check(point_back_shot.X, point_back_shot.Y)
# 切换前置摄像头
point_front_switch = self.d.find_component(
BY.key("com.huawei.camera:id/iv_camera_switch_single_outCircle")).getBoundsCenter()
self.d.touch((point_front_switch.X, point_front_switch.Y))
# 切换拍照模式
point_front_shot = self.d.find_component(BY.text("拍照")).getBoundsCenter()
self.d.touch((point_front_shot.X, point_front_shot.Y))
time.sleep(1)
# 切换后置摄像头
self.d.touch((point_front_switch.X, point_front_switch.Y))
# 检查Zoom1倍
if not self.d.check_component_exist(BY.text("1x")):
zoom_index1_point = self.d.find_component(BY.key("com.huawei.camera:id/one_button_bg")).getBoundsCenter()
self.d.touch((zoom_index1_point.X, zoom_index1_point.Y))
time.sleep(5)
tag = "1"
self.cpu_collect._start_task(rounds=int(self.round), tag=tag, cpu_time=30)
time_start = time.time()
# 保证第一个点击操作可以被采集到
time.sleep(2)
# 点击屏幕中心,避免进入休眠模式
self.d.touch((center_point.X, center_point.Y))
time.sleep(2)
# 3. 预览30s
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0001&桌面-点击-页面切换-相机首页-1、点击人像模式,等待5s",
tag_step="Start")
# Step.点击人像模式,等待5s
self.d.touch((point_back_people.X, point_back_people.Y))
time.sleep(5)
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0001&桌面-点击-页面切换-相机首页-1、点击人像模式,等待5s",
tag_step="End")
# Step.点击录像模式,等待5s
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0002&相机首页-点击-页面切换-拍照页面-2、点击录像模式,等待5s",
tag_step="Start")
self.d.touch((point_back_video.X, point_back_video.Y))
time.sleep(5)
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0002&相机首页-点击-页面切换-拍照页面-2、点击录像模式,等待5s",
tag_step="End")
# Step.点击专业模式,等待5s
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0003&相机首页-点击-页面切换-拍照页面-3、点击专业模式,等待5s",
tag_step="Start")
self.d.touch((point_back_pro.X, point_back_pro.Y))
time.sleep(5)
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0003&相机首页-点击-页面切换-拍照页面-3、点击专业模式,等待5s",
tag_step="End")
# Step.点击拍照模式,等待5s
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0004&相机首页-点击-页面切换-拍照页面-4、点击拍照模式,等待5s",
tag_step="Start")
self.d.touch((point_back_shot.X, point_back_shot.Y))
time.sleep(5)
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0004&相机首页-点击-页面切换-拍照页面-4、点击拍照模式,等待5s",
tag_step="End")
# Step.切换至前置,等待5s
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0005&相机首页-点击-页面切换-拍照页面-5、切换至前置,等待5s",
tag_step="Start")
self.d.touch((point_front_switch.X, point_front_switch.Y))
time.sleep(5)
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0005&相机首页-点击-页面切换-拍照页面-5、切换至前置,等待5s",
tag_step="End")
# Step.切换至拍照模式
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0006&桌面-点击-页面切换-相机首页-6、点击拍照模式,等待5s",
tag_step="Start")
self.d.touch((point_front_shot.X, point_front_shot.Y))
time.sleep(5)
CommonUtilsAOSP.record_test_step_bytrace(self.d, package_name=self.packagename, case_name=self.TAG,
step_code_num="0006&桌面-点击-页面切换-相机首页-6、点击拍照模式,等待5s",
tag_step="End")
time_end = time.time()
if time_end - time_start < 40:
time.sleep(30 - (time_end - time_start))
self.cpu_collect._stop_task(self.report_path, tag=tag)
time.sleep(10)
# 点击屏幕中心,避免进入休眠模式
self.d.touch((center_point.X, center_point.Y))
time.sleep(1)
# 4.判断测试结束后页面是否人像和前置
# self.d.check_component_exist(BY.key("TAB_BAR_LIVE_PHOTO_TAB_BAR_CLOSE"))
point_front_people = self.d.find_component(BY.text("人像")).getBoundsCenter()
host.check(point_back_people.X, point_front_people.X)
host.check(point_back_people.Y, point_front_people.Y)
time.sleep(2)
# 切换至后置摄像头
point_front_switch = self.d.find_component(
BY.key("com.huawei.camera:id/iv_normal_control_bar_switcher_single")).getBoundsCenter()
self.d.touch((point_front_switch.X, point_front_switch.Y))