package qq.test;

import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SdkSuppress;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.Until; import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith; import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat; /**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
@SdkSuppress(minSdkVersion = 18)
public class ChangeTextBehaviorTest { private static final String BASIC_SAMPLE_PACKAGE
= "com.android.music";
private static final int LAUNCH_TIMEOUT = 5000;
private static final String STRING_TO_BE_TYPED = "UiAutomator";
private UiDevice mDevice; public void startMainActivityFromHomeScreen() {
// Initialize UiDevice instance
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); // Start from the home screen
mDevice.pressHome(); // Wait for launcher
final String launcherPackage = mDevice.getLauncherPackageName();
assertThat(launcherPackage, notNullValue());
mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)),
LAUNCH_TIMEOUT); // Launch the app
Context context = InstrumentationRegistry.getContext();
final Intent intent = context.getPackageManager()
.getLaunchIntentForPackage(BASIC_SAMPLE_PACKAGE);
// Clear out any previous instances
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent); // Wait for the app to appear
mDevice.wait(Until.hasObject(By.pkg(BASIC_SAMPLE_PACKAGE).depth(0)),
LAUNCH_TIMEOUT);
}
@Test
public void testMusic(){
startMainActivityFromHomeScreen();
} }

最新文章

  1. Android的历史与花边
  2. ByteBuf和相关辅助类
  3. PHP限制提现时间-----周一至周五 9点到17点
  4. Yii2中的零碎知识点
  5. Redis的两个小技巧
  6. 数据库连接driverClass和jdbcUrl大全
  7. dojox.grid.DataGrid
  8. 用纯Css作三角形
  9. Logistic Regression逻辑回归
  10. java 21 - 10 文本文件和集合之间互相存储数据
  11. Python的pep8(代码规范)
  12. Charles使用问题, iOS7的http代理(http proxy)配置不生效问题
  13. MySQL批处理SQL语句
  14. HighCharts基本使用实例(入门)
  15. 【背包型动态规划】灵魂分流药剂(soultap) 解题报告
  16. 机器学习实战__安装python环境
  17. linux下查看进城(ps)的方法 与 杀死进程(kill)的N种方法
  18. ArcGIS多面体(multipatch)解析(一)
  19. Is It A Tree?(并查集)(dfs也可以解决)
  20. win10利用自带的IIS搭建ftp遇到瓶颈,离线求解!!!

热门文章

  1. 判断JS数据类型的几种方法
  2. 如何提高Mysql的查询效率???
  3. MySQL开启skip-name-resolve和skip-networking优化
  4. LeetCode:103Binary Tree Zigzag Level Order Traversal
  5. 备份和导入Outlook 2016 电子邮件签名
  6. EF6.0注意事项
  7. Java 设计模式之中介者模式
  8. Android(java)学习笔记134:Android数据存储5种方式总结
  9. Object Modeling
  10. Trie入门讲解