VoLTE和语音呼通率测试开发--主叫终端(二)

上篇文章写完被叫,我们这里肯定先写主叫,这里值得注意的是,暂不支持两台终端同时连接(在改进,后面在发出来),我们会通过shell/bat脚本文件去实现运行;


VoLTE视频通话呼通率:

代码如下:匆匆忙忙写的,格式很乱,被注释的语句请忽略(或者删除),只看中文注释

package uiauto;

import java.util.Scanner;

import util.FileUtil;

import android.R.string;

import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;

public class callphone extends UiAutomatorTestCase {
	public void testcallphone() throws Exception{
		int count=1;
		int count1=1;
		int count2=1;
		int count3=1;
		//控件名称统一选定
		UiObject bohaojieting = new UiObject(new UiSelector().text("正在拨号"));//拨号中,是否被接听
		UiObject jietingone = new UiObject(new UiSelector().text("视频通话来电"));
		UiObject jietingtwo = new UiObject(new UiSelector().resourceId("com.android.dialer:id/callStateLabel"));//视频通话来电
		UiObject emNum = new UiObject(new UiSelector().resourceId("com.android.dialer:id/digits"));//输入框
		UiObject closeYangshengqi = new UiObject(new UiSelector().resourceId("com.android.dialer:id/audioButton"));//关闭扬声器
		UiObject viodCall = new UiObject(new UiSelector().text("发起视频通话"));
		UiObject guaduan = new UiObject(new UiSelector().resourceId("com.android.dialer:id/floating_end_call_action_button"));//挂断按钮
		UiObject JieTingHou = new UiObject(new UiSelector().resourceId("com.android.dialer:id/previewVideo"));//接听后本地视频

		//Home主页
		getUiDevice().pressHome();
/*		//由用户输入
		Scanner sc=new Scanner(System.in);  
		System.out.println("Pless input phone Number2:"); 
		String sb=sc.nextLine();
		System.out.println(sb);*/
		
		for(int i=0;i<50;i++){ //通话次数50 次
				
		//打开拨号盘(VoLTE只能用坐标,根据自己机型进行切换)
		Runtime.getRuntime().exec("am start com.android.dialer");
		sleep(2000);
		UiDevice.getInstance().click(248,176);//通话记录
		sleep(1000);
		UiDevice.getInstance().click(417,744);//通话记录右下角拨号盘
		sleep(1000);
		//输入用户输入的号码
		String sb="13714263544";
		emNum.setText(sb);
		sleep(1000);
		UiDevice.getInstance().swipe(405, 226, 411, 175, 2);//长按让输入框缩小,滑动界面一下,因为那个VoLTE按钮在下面,被输入框挡住了
		sleep(1000);
		viodCall.click();
//		Runtime.getRuntime().exec("input tap 313 438");
		sleep(1000);
		closeYangshengqi.click();
		sleep(1000);
		
		//判断拨出成功
		System.out.println("Log:NO."+i+"test");
		Runtime.getRuntime().exec("mkdir sdcard/GotaTestPresure");
		Runtime.getRuntime().exec("mkdir sdcard/GotaTestPresure/CallRecording");
		if(bohaojieting.exists()){
			System.out.println("Log:BoChuSuccess");
			FileUtil.out("sdcard/GotaTestPresure/CallRecording/VOLT拨出成功.txt", "VOLTE拨出成功次数"+count);
			count=count+1;	
		 
		  //判断接听成功
		  System.out.println("Log:WaitJieTing30s");
		  sleep(30000);//30s不接听算失败,
		  if(JieTingHou.exists()){
				System.out.println("Log:JieTingSuccess,TongHua-Wait180s");
				sleep(155000);//通话时长180s
				FileUtil.out("sdcard/GotaTestPresure/CallRecording/VOLT接听成功.txt", "VOLTE对方接听成功次数"+count2);
				count2=count2+1;
				//挂断
				guaduan.click();
				if(!getUiDevice().isScreenOn()){//截图前避免熄屏
					getUiDevice().wakeUp();
				}
				System.out.println("Log:XM-30s");
				sleep(30000);//挂断后间隔时间30s,再次发起
				
			}else{
				System.out.println("Log:JieTingFail");
				FileUtil.out("sdcard/GotaTestPresure/CallRecording/VOLTE接听失败.txt", "VOLTE对方接听次数"+count3);
				count3=count3+1;
				System.out.println("Log:JG-30s");
				guaduan.click();
				sleep(30000);//挂断后间隔时间30s,再次发起
				if(!getUiDevice().isScreenOn()){//截图前避免熄屏
					getUiDevice().wakeUp();
				}
		     }
		 	
		}else{
			System.out.println("Log:BoChuFail");
			FileUtil.out("sdcard/GotaTestPresure/CallRecording/VOLTE拨出失败.txt", "VOLTE拨出失败次数"+count1);
			count1=count1+1;
		}
		

		

		}
		
		
	}
}

普通语音呼通率,

代码如下:匆匆忙忙写的,格式很乱,被注释的语句请忽略(或者删除),只看中文注释

package yuyin;

import java.util.Scanner;

import util.FileUtil;

import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;

public class zhujiao extends UiAutomatorTestCase {
	public void testcallphone() throws Exception{
		int count=1;
		int count1=1;
		int count2=1;
		int count3=1;

		UiObject bohaojieting = new UiObject(new UiSelector().text("正在拨号"));//拨号中,是否被接听
		UiObject jietingone = new UiObject(new UiSelector().text("视频通话来电"));
		UiObject jietingtwo = new UiObject(new UiSelector().resourceId("com.android.dialer:id/callStateLabel"));//视频通话来电
		UiObject emNum = new UiObject(new UiSelector().resourceId("com.android.dialer:id/digits"));//输入框
		UiObject closeYangshengqi = new UiObject(new UiSelector().resourceId("com.android.dialer:id/audioButton"));//关闭扬声器
		UiObject viodCall = new UiObject(new UiSelector().text("发起视频通话"));
		UiObject guaduan = new UiObject(new UiSelector().resourceId("com.android.dialer:id/floating_end_call_action_button"));//挂断按钮
		UiObject JieTingHou = new UiObject(new UiSelector().resourceId("com.android.dialer:id/previewVideo"));//接听后本地视频

		//Home主页
		getUiDevice().pressHome();
/*		//由用户输入
		System.out.println("Pless input phone Number2:"); 
		Scanner sc=new Scanner(System.in); 
		int sb=sc.nextInt();
//		long sb=13714263515;
		//强制类型转换
//		String sm = "";
//		sm=sb+"";
		String sm = String.valueOf(sb); 
		System.out.println("int:"+sb);
		System.out.println("String:"+sm);
		*/
		for(int i=0;i<50;i++){ //通话次数50 次
				
		//打开拨号盘
		Runtime.getRuntime().exec("am start -a android.intent.action.CALL tel:"+"13714263544");
		closeYangshengqi.click();
		sleep(1000);
		
		//判断拨出成功
		System.out.println("Log:NO."+i+"test");
		Runtime.getRuntime().exec("mkdir sdcard/GotaTestPresure");
		Runtime.getRuntime().exec("mkdir sdcard/GotaTestPresure/CallRecording");
		if(bohaojieting.exists()){
			System.out.println("Log:BoChuSuccess");
			FileUtil.out("sdcard/GotaTestPresure/CallRecording/语音拨出成功.txt", "语音拨出成功次数"+count);
			count=count+1;	
		 
		  //判断接听成功
		  System.out.println("Log:WaitJieTing30s");
		  sleep(30000);//30s不接听算失败,
		  if(!bohaojieting.exists()){
				System.out.println("Log:JieTingSuccess,TongHua-Wait180s");
				sleep(155000);//通话时长180s
				FileUtil.out("sdcard/GotaTestPresure/CallRecording/语音接听成功.txt", "语音对方接听成功次数"+count2);
				count2=count2+1;
				//挂断
				guaduan.click();
				if(!getUiDevice().isScreenOn()){//截图前避免熄屏
					getUiDevice().wakeUp();
				}
				System.out.println("Log:XM-30s");
				sleep(30000);//挂断后间隔时间30s,再次发起
				
			}else{
				System.out.println("Log:JieTingFail");
				FileUtil.out("sdcard/GotaTestPresure/CallRecording/语音接听失败.txt", "语音对方接听次数"+count3);
				count3=count3+1;
				System.out.println("Log:JG-30s");
				guaduan.click();
				sleep(30000);//挂断后间隔时间30s,再次发起
				if(!getUiDevice().isScreenOn()){//截图前避免熄屏
					getUiDevice().wakeUp();
				}
		     }
		 	
		}else{
			System.out.println("Log:BoChuFail");
			FileUtil.out("sdcard/GotaTestPresure/CallRecording/语音拨出失败.txt", "语音拨出失败次数"+count1);
			count1=count1+1;
		}
		

		

		}
		
		
	}
}


代码写完后,编译,导出jar包,具体方法参考我的另篇文章《uiautomator如何编译运行

猜你喜欢

转载自blog.csdn.net/bbs11007/article/details/80817521