栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Go语言

Go adb 自动调试

Go语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Go adb 自动调试

自动调试脚本
上传文件,
打开软件处理文件,
关闭软件,
拉取处理结果,
对结果处理

func TestAdbPush(t *testing.T) {
	Do([]string{"push", "./AAA.txt", "/storage/emulated/0/"})
}

func TestAdbPull(t *testing.T) {
	Do([]string{"pull", "/storage/emulated/0/AAA.txt", "./"})
}

func TestAdbPullFile(t *testing.T) {
	Do([]string{"pull", "/storage/emulated/0/Result.txt", "./"})
}

func Do(command []string) {
	cmd := exec.Command("adb", command...)
	out, err := cmd.CombinedOutput()
	if err != nil {
		fmt.Printf("combined out:n%sn", string(out))
		fmt.Printf("cmd.Run() failed with %sn", err)
		return
	}
	fmt.Printf("combined out:n%sn", string(out))
}

func TestStart(t *testing.T) {
	Do([]string{"shell", "am", "start", "-n", "com.android.authtest/com.android.authtest.ui.mainPage.LoginActivity"})
}

func TestStop(t *testing.T) {
	Do([]string{"shell", "am", "force-stop", "com.android.authtest"})
}

//adb shell am start -n com.android.authtest/com.android.authtest.ui.mainPage.LoginActivity

//adb shell am force-stop com.android.authtest

func TestFull(t *testing.T) {
	Do([]string{"push", "./AAA.txt", "/storage/emulated/0/"})
	Do([]string{"shell", "am", "start", "-n", "com.android.authtest/com.android.authtest.ui.mainPage.LoginActivity"})
	time.Sleep(time.Second)
	Do([]string{"shell", "am", "force-stop", "com.android.authtest"})
	Do([]string{"pull", "/storage/emulated/0/Result.txt", "./"})
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/905536.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号