def test_72_desktopmode_move_left1(self): print("#测试点# 强制横屏模式测试:移动-屏幕内左移") sleep(0.5) caption_x, caption_y = d(resourceId="android:id/caption").center() extendevent.drag_2(d, mouseID, caption_x, caption_y, screen_width / 2, 100) sleep(0.5) caption_x, caption_y = d(resourceId="android:id/caption").center() windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') extendevent.drag_2(d, mouseID, caption_x, caption_y, 480 + 100, caption_y) check_windowBounds = { 'top': windowBounds['top'], 'bottom': windowBounds['top'] + 540, 'left': 100, 'right': 100 + 960 } sleep(0.5) windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') print("期望:" + str(check_windowBounds)) print("实际:" + str(windowBounds)) output_res(windowBounds == check_windowBounds) if (module_result == True): print("模块通过") else: print("模块失败")
def test_32_button_max(self): print("#测试点# 标准窗口测试:按钮-最大化") sleep(0.5) windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') window_width = windowBounds['right'] - windowBounds['left'] if window_width < 700: windowBounds = resize("right", -800 + window_width) d(resourceId="android:id/maximize_window").click() sleep(0.5) check_windowBounds = { 'top': 0, 'bottom': screen_height, 'left': 0, 'right': screen_width } windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') print("期望:" + str(check_windowBounds)) print("实际:" + str(windowBounds)) output_res(windowBounds == check_windowBounds) d(resourceId="android:id/maximize_window").click() if (module_result == True): print("模块通过") else: print("模块失败")
def test_13_move_up1(self): print("#测试点# 标准窗口测试:移动-屏幕内上移") sleep(0.5) caption_x, caption_y = d(resourceId="android:id/caption").center() windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') window_width = windowBounds['right'] - windowBounds['left'] window_height = windowBounds['bottom'] - windowBounds['top'] caption_bounds = d( resourceId="android:id/caption").info.get('visibleBounds') caption_height = caption_bounds['bottom'] - caption_bounds['top'] extendevent.drag_2(d, mouseID, caption_x, caption_y, screen_width / 2, 100) check_windowBounds = { 'top': 100 - caption_height / 2 - 1, 'bottom': (100 - caption_height / 2) - 1 + window_height, 'left': screen_width / 2 - window_width / 2, 'right': screen_width / 2 + window_width / 2 } sleep(0.5) windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') print("期望:" + str(check_windowBounds)) print("实际:" + str(windowBounds)) output_res(windowBounds == check_windowBounds) if (module_result == True): print("模块通过") else: print("模块失败")
def test_12_move_right1(self): print("#测试点# 标准窗口测试:移动-屏幕内右移") sleep(0.5) caption_x, caption_y = d(resourceId="android:id/caption").center() windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') window_width = windowBounds['right'] - windowBounds['left'] extendevent.drag_2(d, mouseID, caption_x, caption_y, screen_width - 100 - window_width / 2, caption_y) check_windowBounds = { 'top': windowBounds['top'], 'bottom': windowBounds['bottom'], 'left': screen_width - 100 - window_width, 'right': screen_width - 100 } sleep(0.5) windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') print("期望:" + str(check_windowBounds)) print("实际:" + str(windowBounds)) output_res(windowBounds == check_windowBounds) if (module_result == True): print("模块通过") else: print("模块失败")
def test_22_doubleclick(self): print("#测试点# 标准窗口测试:双击") sleep(0.5) caption_x, caption_y = d(resourceId="android:id/caption").center() extendevent.drag_2(d, mouseID, caption_x, caption_y, screen_width / 2, 100) sleep(0.5) extendevent.double_click(d, mouseID, d(resourceId="android:id/caption")) sleep(0.5) check_windowBounds = { 'top': 0, 'bottom': screen_height, 'left': 0, 'right': screen_width } windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') print("期望:" + str(check_windowBounds)) print("实际:" + str(windowBounds)) output_res(windowBounds == check_windowBounds) if (module_result == True): print("模块通过") else: print("模块失败")
def test_00_prepare(self): print("#测试点# 标准窗口测试:测试准备-打开应用") d.app_start(package) sleep(6) extendevent.hover_00(d, mouseID) while (not d(resourceId="android:id/caption").exists(timeout=2)): solve_problem() sleep(1) if (not d(resourceId="android:id/maximize_window").exists): sleep(0.5) d(resourceId="android:id/setting_window").click() d(text="标准模式").click() sleep(1) d(text="确定").click() sleep(0.5) startapp(package) d(resourceId="android:id/caption").exists(timeout=30) sleep(0.5) d(resourceId="android:id/caption").drag_to(screen_width / 2, 100, duration=0.1) sleep(0.5) windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') window_width = windowBounds['right'] - windowBounds['left'] if window_width < 700: windowBounds = resize("right", -800 + window_width) if (module_result == True): print("模块通过") else: print("模块失败")
def test_14_move_down1(self): print("#测试点# 标准窗口测试:移动-屏幕内下移") sleep(0.5) caption_x, caption_y = d(resourceId="android:id/caption").center() windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') window_height = windowBounds['top'] - windowBounds['bottom'] extendevent.drag_2(d, mouseID, caption_x, caption_y, caption_x, 800 - window_height) if (module_result == True): print("模块通过") else: print("模块失败")
def test_75_desktopmode_doubleclick(self): print("#测试点# 强制横屏模式测试:双击") sleep(0.5) windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') extendevent.double_click(d, mouseID, d(resourceId="android:id/caption")) sleep(0.5) check_windowBounds = { 'top': 0, 'bottom': 540, 'left': windowBounds['left'], 'right': windowBounds['left'] + 960 } windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') print("期望:" + str(check_windowBounds)) print("实际:" + str(windowBounds)) output_res(windowBounds == check_windowBounds) if (module_result == True): print("模块通过") else: print("模块失败")
def test_51_fullscreen_change(self): print("#测试点# 全屏窗口测试:切换") sleep(0.5) app_name = str(d(resourceId="android:id/title_window").get_text()) print(app_name) d(resourceId="android:id/setting_window").click() d(text="全屏模式").click() sleep(1) d(text="确定").click() sleep(0.5) d.app_start("com.android.calculator2") sleep(1) extendevent.open_startmenu(d, mouseID) sleep(1) d(resourceId='com.android.systemui:id/search').set_text(app_name) sleep(1) d(resourceId="com.android.systemui:id/grid_view").child( instance=0).click() sleep(2) extendevent.hover_00(d, mouseID) sleep(1) check_windowBounds = { 'top': 0, 'bottom': screen_height, 'left': 0, 'right': screen_width } windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') print("期望:" + str(check_windowBounds)) print("实际:" + str(windowBounds)) output_res(windowBounds == check_windowBounds) d.shell("sendevent /dev/input/event" + mouseID + " 2 0 0") d.shell("sendevent /dev/input/event" + mouseID + " 2 1 200") d.shell("sendevent /dev/input/event" + mouseID + " 0 0 0") sleep(0.5) output_res(not d(resourceId="android:id/caption").exists) sleep(0.5) extendevent.hover_00(d, mouseID) output_res(d(resourceId="android:id/caption").exists) if (module_result == True): print("模块通过") else: print("模块失败")
def test_71_desktopmode_change(self): print("#测试点# 强制横屏模式测试:切换") sleep(0.5) d(resourceId="android:id/setting_window").click() d(text="手机模式(横屏)").click() sleep(0.5) d(text="确定").click() sleep(0.5) startapp(package) sleep(1) windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') print("实际:" + str(windowBounds)) output_res((windowBounds['right'] - windowBounds['left']) == 960 and (windowBounds['bottom'] - windowBounds['top']) == 540) if (module_result == True): print("模块通过") else: print("模块失败")
def test_64_phonemode_move_top(self): print("#测试点# 强制竖屏模式测试:移动-上边界") sleep(0.5) caption_x, caption_y = d(resourceId="android:id/caption").center() extendevent.drag_2(d, mouseID, caption_x, caption_y, 800, 0) sleep(0.5) windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') check_windowBounds = { 'top': 0, 'bottom': 720, 'left': windowBounds['left'], 'right': windowBounds['left'] + 405 } print("期望:" + str(check_windowBounds)) print("实际:" + str(windowBounds)) output_res(windowBounds == check_windowBounds) if (module_result == True): print("模块通过") else: print("模块失败")
def resize(orientation, i): windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') print("实际:" + str(windowBounds)) currentApp_hcenter = (windowBounds['left'] + windowBounds['right']) / 2 currentApp_vcenter = (windowBounds['top'] + windowBounds['bottom']) / 2 if (orientation == "top"): extendevent.drag(d, mouseID, currentApp_hcenter, windowBounds['top'] - 1, currentApp_hcenter, windowBounds['top'] - 1 + i) check_windowBounds = { 'top': windowBounds['top'] + i, 'bottom': windowBounds['bottom'], 'left': windowBounds['left'], 'right': windowBounds['right'] } elif (orientation == "bottom"): extendevent.drag(d, mouseID, currentApp_hcenter, windowBounds['bottom'] + 1, currentApp_hcenter, windowBounds['bottom'] + 1 - i) check_windowBounds = { 'top': windowBounds['top'], 'bottom': windowBounds['bottom'] - i, 'left': windowBounds['left'], 'right': windowBounds['right'] } elif (orientation == "left"): extendevent.drag(d, mouseID, windowBounds['left'] - 1, currentApp_vcenter, windowBounds['left'] - 1 - i, currentApp_vcenter) check_windowBounds = { 'top': windowBounds['top'], 'bottom': windowBounds['bottom'], 'left': windowBounds['left'] - i, 'right': windowBounds['right'] } elif (orientation == "right"): extendevent.drag(d, mouseID, windowBounds['right'] + 1, currentApp_vcenter, windowBounds['right'] + 1 - i, currentApp_vcenter) check_windowBounds = { 'top': windowBounds['top'], 'bottom': windowBounds['bottom'], 'left': windowBounds['left'], 'right': windowBounds['right'] - i } elif (orientation == "left-top"): extendevent.drag(d, mouseID, windowBounds['left'] - 1, windowBounds['top'] - 1, windowBounds['left'] - 1 + i, windowBounds['top'] - 1 + i) check_windowBounds = { 'top': windowBounds['top'] + i, 'bottom': windowBounds['bottom'], 'left': windowBounds['left'] + i, 'right': windowBounds['right'] } elif (orientation == "left-bottom"): extendevent.drag(d, mouseID, windowBounds['left'] - 1, windowBounds['bottom'] + 1, windowBounds['left'] - 1 + i, windowBounds['bottom'] + 1 - i) check_windowBounds = { 'top': windowBounds['top'], 'bottom': windowBounds['bottom'] - i, 'left': windowBounds['left'] + i, 'right': windowBounds['right'] } elif (orientation == "right-top"): extendevent.drag(d, mouseID, windowBounds['right'] + 1, windowBounds['top'] - 1, windowBounds['right'] + 1 - i, windowBounds['top'] - 1 + i) check_windowBounds = { 'top': windowBounds['top'] + i, 'bottom': windowBounds['bottom'], 'left': windowBounds['left'], 'right': windowBounds['right'] - i } else: extendevent.drag(d, mouseID, windowBounds['right'] + 1, windowBounds['bottom'] + 1, windowBounds['right'] + 1 - i, windowBounds['bottom'] + 1 - i) check_windowBounds = { 'top': windowBounds['top'], 'bottom': windowBounds['bottom'] - i, 'left': windowBounds['left'], 'right': windowBounds['right'] - i } sleep(0.5) windowBounds = extendfunction.getParentBounds( d.dump_hierarchy(), 'resource-id="android:id/caption"') output_res(windowBounds == check_windowBounds) print("期望:" + str(check_windowBounds)) print("实际:" + str(windowBounds)) return windowBounds