예제 #1
0
 def por_input(self):
     top_y = self.M.select_user(
         'com.emoji.ikeyboard/com.android.inputmethod.latin.LatinIME')
     keyboard = Keyboard_Operation(self.d, top_y)
     # 切换输入法至葡萄牙语
     while True:
         location = keyboard.keyboard_reader(' ')
         orc = keyboard.orc_location(location['x'], location['y'],
                                     location['width'], location['height'])
         print(orc)
         if 'Po' in orc:
             break
         else:
             keyboard.swip_location(location['x'], location['y'],
                                    location['width'], location['height'])
     keyboard.send_input('portug')
     orc_select = keyboard.orc_location(0,
                                        top_y,
                                        keyboard.phone_width,
                                        40 * keyboard.density()['density'],
                                        set_lang='por')
     print(orc_select)
     if 'Português' in orc_select:
         orc_result = True
     else:
         orc_result = False
     self.BF.check_assertTrue(orc_result, '没有纠正')
예제 #2
0
 def es_input(self):
     top_y = self.M.select_user(
         'com.qisiemoji.inputmethod/com.android.inputmethod.latin.LatinIME')
     keyboard = Keyboard_Operation(self.d, top_y)
     # 切换输入法至西班牙语
     while True:
         location = keyboard.keyboard_reader(' ')
         orc = keyboard.orc_location_text(location['x'], location['y'],
                                          location['width'],
                                          location['height'])
         print(orc)
         if 'Es' in orc:
             break
         else:
             keyboard.swip_location(location['x'], location['y'],
                                    location['width'], location['height'])
     keyboard.send_input('espa')
     orc_select = keyboard.orc_location_text(0,
                                             top_y,
                                             keyboard.phone_width,
                                             40 *
                                             keyboard.density()['density'],
                                             set_lang='epo')
     # print(orc_select)
     if 'Espaĥol' in orc_select:
         orc_result = True
     else:
         orc_result = False
     self.BF.check_assertTrue(orc_result, '没有纠正')
예제 #3
0
    def test_add_language(self):
        print('Test add language, swipe and screenshot keyboard: ')
        new = '/Users/yanqing.xu/Downloads/app-kika-215101-release-ef36305.apk'
        old = '/Users/yanqing.xu/Downloads/app-kika-214801-release-60bf8dd.apk'
        package = 'com.qisiemoji.inputmethod'
        Typewriting = package + '/com.android.inputmethod.latin.LatinIME'
        activity = package + '/com.qisi.ikeyboarduirestruct.NavigationActivity'
        # 添加和截取键盘个数
        num = 50
        # 滑动添加时滑动次数
        rd = 20
        for i in range(0, 11):
            if self.kika.device_config == 'none':
                try:
                    unin_result = os.popen('adb uninstall %s' % package)
                except Exception as e:
                    print(e)
                    print('没有对应应用')
            else:
                try:
                    unin_result = os.popen('adb -s %s uninstall %s' %
                                           (self.device_config, package))
                except Exception as e:
                    print(e)
                    print('没有对应应用')
        os.system('adb install -r %s' % old)

        # 安装测试包并设置默认输入法
        #   del_package = 'com.qisiemoji.inputmethod'
        self.BF.keyboard_select(Typewriting)
        time.sleep(2)
        self.BF.open_app_atcivity(activity)
        time.sleep(3)
        self.BF.click('name', 'Settings')
        time.sleep(1)
        self.BF.click('name', 'Language')
        #   获取手机分辨率,计算右下角add大概坐标
        # adb shell dumpsys window displays |head -n 3计算x y
        dis = os.popen('adb shell dumpsys window displays |head -3').read()
        x = re.findall(r'init\=(.*?)x', dis)[0]
        y = re.findall(r'x(.*?)\s', dis)[0]
        swipex = int(x) * 1 / 2
        swipey1 = int(y) * 3 / 4
        swipey2 = int(y) * 1 / 4
        addx = int(x) - 30
        addy = int(y) - 100
        swipe = 'adb shell input swipe '
        add = 'adb shell input tap '
        # 向上滑
        for i in range(rd):
            print("swipe time:", i)
            ret = os.popen(swipe + str(int(swipex)) + ' ' + str(int(swipey1)) +
                           ' ' + str(int(swipex)) + ' ' + str(int(swipey2)))
            ret.close()

        # 点击add添加所有language
        for j in range(num):
            print('Add language time:', j)
            try:
                self.BF.check_find_element('name', 'Yes')
                time.sleep(0.5)
                self.BF.click('name', 'Yes')
            except:
                pass
            os.system(add + str(addx) + ' ' + str(addy))

        os.system('adb shell am start -n yuside.cn.numbersonly/.MainActivity')
        time.sleep(1)

        top_y = self.BF.keyboard_get_ready(Typewriting, 'class',
                                           'android.widget.ScrollView')
        keyboard = Keyboard_Operation(self.d, top_y)
        width = keyboard.phone_width
        # 获取空格键位置
        sp = keyboard.keyboard_reader(' ')
        height = (keyboard.phone_height - top_y)
        time.sleep(1)

        picinfo = dict()
        for k in range(num):
            keyboard.swip_location(sp['x'], sp['y'], sp['width'], sp['height'])
            time.sleep(1)
            picinfo[k] = keyboard.get_keyboard_picture(0, top_y, width, height,
                                                       'lang')
        # ******************分割线*********
        # 等待几秒,安装新版包,做截图对比
        time.sleep(2)
        os.system('adb uninstall %s' % package)
        os.system('adb install -r %s' % new)
        self.BF.keyboard_select(Typewriting)
        self.BF.open_app_atcivity(activity)
        time.sleep(3)
        self.BF.click('name', 'Settings')
        time.sleep(1)
        self.BF.click('name', 'Language')

        for i in range(rd):
            print("swipe time:", i)
            ret = os.popen(swipe + str(int(swipex)) + ' ' + str(int(swipey1)) +
                           ' ' + str(int(swipex)) + ' ' + str(int(swipey2)))
            ret.close()

        # 点击add添加所有language
        for j in range(num):
            print('Add language time:', j)
            try:
                self.BF.check_find_element('name', 'Yes')
                time.sleep(0.5)
                self.BF.click('name', 'Yes')
            except:
                pass
            os.system(add + str(addx) + ' ' + str(addy))
        os.system('adb shell am start -n yuside.cn.numbersonly/.MainActivity')
        self.BF.keyboard_get_ready(Typewriting, 'class',
                                   'android.widget.ScrollView')
        for k in range(num):
            keyboard.swip_location(sp['x'], sp['y'], sp['width'], sp['height'])
            time.sleep(1)
            keyboard.keyboard_same(0, top_y, width, height, picinfo[k])
        time.sleep(1)