Go adb 自动调试

Go adb 自动调试,第1张

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

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%s\n", string(out))
		fmt.Printf("cmd.Run() failed with %s\n", err)
		return
	}
	fmt.Printf("combined out:\n%s\n", 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", "./"})
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/994555.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存