Exemple #1
0
    def enter_group_by_search(self, gid):
        self.touch_button('GROUP_SEARCH')
        time.sleep(0.5)
        self.device.type(gid)
        time.sleep(0.5)
        search_result = self.get_vc_view_by_id('id/tv_name', 3)

        if not search_result:  # 没有搜索到,点击取消
            logger.error("搜索结果查找id/tv_name失败,可能需要取消搜索")
            self.cancel_search()
            return False
        # 搜索到结果了,验证一下id对不对,结果示例: 北航人在点评(71771261)
        _text = vc_view_text(search_result)
        logger.debug('群搜索结果: %s', to_str(_text))
        _id = self.split_group_id(_text)
        if not _id:
            logger.error("搜索结果[%s]解析群号失败", to_str(_text))
            self.cancel_search()
            return False
        if not str_equal(_id, gid):
            logger.error("搜索结果的群号[%s]和需要进的群号[%s]不一致",
                         to_str(_id), to_str(gid))
            self.cancel_search()
            return False

        #都对了,进群吧
        if not self.switch_by_pixel("GROUP_LIST", "GROUP_CHAT",
                                    *BUTTON_LOCATION["SEARCH_RESULT"]):
            logger.error("点击搜索结果进群失败!!!!")
            self.cancel_search()
            return False
        return True
Exemple #2
0
 def validate_input_text_by_mr(self, msg):
     logger.debug('validate msg by mr begin')
     msg_to_send = self.get_mr_view_text_by_id('id/input')
     if not msg_to_send:
         #可能是消息没粘贴上、禁言或者语言输入打开了
         logger.warning("Monkeyrunner查找id/input元素失败")
         send_btn = self.get_mr_view_text_by_id('id/fun_btn')
         if str_equal("切换到文字输入", send_btn):
             logger.debug("语音输入打开了,关闭之")
             self.touch_button('REC_SEND')
             time.sleep(0.5)
             self.touch_button('MSG_SPACE')
         return False, 0
     #消息框有内容了,验证一下对不对
     if not str_equal(msg_to_send, msg):
         logger.warning("要发送的消息[%s]和输入框中的消息[%s]不一致",
                        to_str(msg), to_str(msg_to_send))
         return False, len(msg_to_send)
     return True, 0
Exemple #3
0
 def gen_groups(self):
     logger.info("遍历群并生成群信息")
     self.interrupt = False
     if not self.goto('CONTACTS'):
         return
     if not self.goto('GROUP_LIST'):
         return
     last_end_group_name = "", ""
     for i in xrange(30):
         if self.interrupt:
             logger.info("生成群列表被中断")
             return
         if i != 0:
             self.drag(1)
         groups = self.extract_groups()
         if not groups:
             continue
         if str_equal(last_end_group_name[0], groups[-2][0]) and \
            str_equal(last_end_group_name[1], groups[-1][0]):
             logger.info("群列表已到底部,扫描完毕,一共发现%s个群",
                         to_str(len(self.groups)))
             break
         last_end_group_name = groups[-2][0], groups[-1][0]
         self.walk_through_groups(groups)
Exemple #4
0
 def check_group_msg(self, target):
     # 在'GROUP_CHAT'界面查看是否有指定的消息
     # 先获取第一屏的消息
     logger.info("check group msg: %s", to_str(target))
     for i in xrange(3):
         if i != 0:
             self.drag(-1)
         msgs = self.extract_group_msgs()
         for sender, msg in msgs:
             logger.info("群消息[%s]来自[%s]", to_str(msg), to_str(sender))
             if str_equal(msg, target):
                 logger.info("target msg[%s] found", to_str(target))
                 return {"drag": i, "sender": sender}
     self.move_to_screen_end()
     logger.info("target msg[%s] not found in 3 screens", to_str(target))
     return 1
Exemple #5
0
 def group_in_list(self, gname):
     for g in self.groups.itervalues():
         if str_equal(g.name, gname):
             return True
     return False