def send_msg(self,data): if not data.get('msg'): return 1 msg = data['msg'] print '------------ send_msg %s' % msg print ">>>send_msg 1 ",time() if self.is_group() != 0 : view = self.get_current_view() if view == 'is_info': self.touch_to_enter_group() else: print "Info : I am in the view %s !" % view return 1 print ">>>send_msg 2 ",time() get_encoded_character(self.qq['deviceid'], msg.decode('utf8')) # self.restart_qq_monkey() print ">>>send_msg 3 ",time() # self.easy_device.touch(input_location, self.easy_device.DOWN) self.device.touch(self.emulator['input'][0],self.emulator['input'][1],MonkeyDevice.DOWN) sleep(1) # self.easy_device.touch(input_location, self.easy_device.UP) self.device.touch(self.emulator['input'][0],self.emulator['input'][1],MonkeyDevice.UP) self.touchByMonkeyPixel(self.emulator['paste']) print ">>>send_msg 4 ",time() self.touchByMonkeyPixel(self.emulator['send'])
def send_msg(self,data): print '\n------------ send_msg ------------' if not data.get('msg'): return -1 if self.is_current_group() != 0: return -1 utils.get_encoded_character(deviceid, data['msg'].decode('utf8')) self.restart_qq_monkey() self.easy_device.touch(By.id("id/input"), self.easy_device.DOWN) # self.device.touch(500,1700,'DOWN') sleep(0.5) self.easy_device.touch(By.id("id/input"), self.easy_device.UP) # self.device.touch(500,1700,'UP') # sleep(1) self.touchByMonkeyPixel(270,1590) inputid = self.get_hierarchy_view_by_id('id/input') if inputid: text = self.getTextByMonkeyView(inputid) print "Info : get msg %s from clipboard !" % text if text.strip().split() == data['msg'].strip().split(): if self.touchByMonkeyId('id/fun_btn') != 0: # if self.touchByMonkeyPixel(970,1700) != 0: return -1 print "Info : send msg %s !" % data['msg'] return 0
def send_group_msg(self, msg): logger.info('send msg: %s', to_str(msg)) get_encoded_character(self.device_id, to_unicode(msg)) self.wait_screen('GROUP_CHAT') logger.debug('send_group_msg copy character done') #防止本QQ屏蔽了该群,需要先点击一下,把提示信息消除掉 time.sleep(10) time.sleep(0.5) self.touch_button('INPUT') time.sleep(0.5) self.long_touch_pixel(*BUTTON_LOCATION['INPUT']) time.sleep(0.2) self.touch_button('PASTE') logger.debug('send_group_msg click PASTE done') #验证输入框中的内容是否和要发送的内容一致 """ 因为有时候Monkeyrunner取输入框取不到,ViewClient会取到错误的文本 为了降低出错的概率,同时使用ViewClient和Monkeyrunner来验证消息, 只要有一个成功,就发送 """ #通过ViewClient去验证内容 status, msg_len1 = self.validate_input_text_by_vc(msg) if status: self.touch_button('SEND') return 0 logger.error("通过ViewClient验证要发送的内容失败") #通过Monkeyrunner去验证内容 status, msg_len2 = self.validate_input_text_by_mr(msg) if status: self.touch_button('SEND') return 0 logger.error("通过Monkeyrunner验证要发送的内容失败") msg_len = max(msg_len1, msg_len2) if msg_len > 0: #消息没发送要把残留的消息删掉 self.delete_msg(msg_len) return 1
#!-*- coding: utf-8 -*- #!/bin/env python import sys reload(sys) sys.setdefaultencoding('utf-8') import os, sys current_dir = os.path.dirname(os.path.abspath(__file__)) test_text = u"test: eng 123 黑色" sys.path.append(current_dir) import utils print("install 'Input Unicode' apk") utils.run_cmd("adb install -r %s" % os.path.join(current_dir, "Input Unicode.apk")) print("input raw 'unicode' characters") utils.get_encoded_character(test_text) print("Now, verify if encoded characters are in clipboard")
#!-*- coding: utf-8 -*- #!/bin/env python import os, sys deviceid = u'emulator-5554' #msg=u'http://s.dianping.com/event/37317?utm_source=co_diaochan&utm_medium=dp_qqpa&utm_term=group_gz&utm_content=event37317_141117 中了带基友去~' msg=u'http://s.dianping.com/event/37317?utm_source=co_diaochan&utm_medium=dp_qqpa&utm_term=group_gz&utm_content=event37317_141117 asda' current_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.append(current_dir) import utils #print("install 'Input Unicode' apk") #utils.run_cmd("adb install -r %s"% # os.path.join(current_dir, "Input Unicode.apk")) utils.get_encoded_character(deviceid,msg)
#!-*- coding: utf-8 -*- #!/bin/env python import os, sys current_dir = os.path.dirname(os.path.abspath(__file__)) test_text = u"test: eng 123 黑色 نقطة توقف όχος" sys.path.append(current_dir) import utils print("install 'Input Unicode' apk") utils.run_cmd("adb install -r %s"% os.path.join(current_dir, "Input Unicode.apk")) print("input raw 'unicode' characters") utils.get_encoded_character(test_text) print("Now, verify if encoded characters are in clipboard")