refactor: enter live

This commit is contained in:
debugtalk
2022-11-27 22:36:44 +08:00
parent c9bbc7788b
commit ecdbd3afce
4 changed files with 39 additions and 28 deletions

View File

@@ -1,15 +1,35 @@
# World Cup Live # World Cup Live
```bash ```text
$ wcl -n "法国vs丹麦" --android com.ss.android.ugc.aweme -d 120 $ wcl -h
Monitor FIFA World Cup Live
Usage:
wcl [flags]
Flags:
--android string run android app
-d, --duration int set duration in seconds (default 30)
-h, --help help for wcl
-i, --interval int set interval in seconds (default 15)
--ios string run ios app
-l, --log-level string set log level (default "INFO")
-n, --match-name string specify match name
-p, --perf strings specify performance monitor, e.g. sys_cpu,sys_mem,sys_net,sys_disk,fps,network,gpu
-u, --uuid string specify device serial or udid
-v, --version version for wcl
``` ```
抖音: ```bash
$ wcl -n "法国vs丹麦" --android com.ss.android.ugc.aweme -d 300 -i 15 -u caf0cd51
$ wcl -n "比利时vs摩洛哥" --ios com.ss.iphone.ugc.Aweme -d 300 -i 15 -p sys_cpu,sys_mem,sys_disk,sys_net,fps,network,gpu -u 00008030-000438191421802E
```
- com.ss.iphone.ugc.Aweme ## bundle id
- com.ss.android.ugc.aweme
央视频: | app | iOS | Android |
| -- | -- | -- |
咪咕视频: | 抖音 | com.ss.iphone.ugc.Aweme | com.ss.android.ugc.aweme |
| 央视频 | com.cctv.yangshipin.app.iphone | com.cctv.yangshipin.app.androidp |
| 咪咕视频 | com.wondertek.hecmccmobile | com.cmcc.cmvideo |

View File

@@ -15,7 +15,7 @@ import (
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "wcl", Use: "wcl",
Short: "Monitor FIFA World Cup Live", Short: "Monitor FIFA World Cup Live",
Version: "0.1", Version: "2022.11.27.2240",
PreRun: func(cmd *cobra.Command, args []string) { PreRun: func(cmd *cobra.Command, args []string) {
log.Logger = zerolog.New( log.Logger = zerolog.New(
zerolog.ConsoleWriter{NoColor: false, Out: os.Stderr}, zerolog.ConsoleWriter{NoColor: false, Out: os.Stderr},
@@ -28,11 +28,11 @@ var rootCmd = &cobra.Command{
var bundleID string var bundleID string
if iosApp != "" { if iosApp != "" {
log.Info().Str("bundleID", iosApp).Msg("init ios device") log.Info().Str("bundleID", iosApp).Msg("init ios device")
device = initIOSDevice() device = initIOSDevice(uuid)
bundleID = iosApp bundleID = iosApp
} else if androidApp != "" { } else if androidApp != "" {
log.Info().Str("bundleID", androidApp).Msg("init android device") log.Info().Str("bundleID", androidApp).Msg("init android device")
device = initAndroidDevice() device = initAndroidDevice(uuid)
bundleID = androidApp bundleID = androidApp
} else { } else {
return errors.New("android or ios app bundldID is required") return errors.New("android or ios app bundldID is required")

View File

@@ -36,7 +36,7 @@ func convertTimeToSeconds(timeStr string) (int, error) {
return seconds, nil return seconds, nil
} }
func initIOSDevice() uixt.Device { func initIOSDevice(uuid string) uixt.Device {
perfOptions := []gidevice.PerfOption{} perfOptions := []gidevice.PerfOption{}
for _, p := range perf { for _, p := range perf {
switch p { switch p {
@@ -69,7 +69,7 @@ func initIOSDevice() uixt.Device {
return device return device
} }
func initAndroidDevice() uixt.Device { func initAndroidDevice(uuid string) uixt.Device {
device, err := uixt.NewAndroidDevice(uixt.WithSerialNumber(uuid)) device, err := uixt.NewAndroidDevice(uixt.WithSerialNumber(uuid))
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("failed to init android device") log.Fatal().Err(err).Msg("failed to init android device")
@@ -204,21 +204,12 @@ func (wc *WorldCupLive) EnterLive(bundleID string) error {
_ = wc.driver.TapAbsXY(points[1].X, points[1].Y) _ = wc.driver.TapAbsXY(points[1].X, points[1].Y)
} }
// 点击进入搜索 // 进入世界杯 tab
err = wc.driver.TapXY(0.9, 0.07) if err = wc.driver.TapByOCR("世界杯"); err != nil {
if err != nil { log.Error().Err(err).Msg("enter 直播中 failed")
log.Error().Err(err).Msg("enter search failed")
return err return err
} }
time.Sleep(3 * time.Second)
// 搜索世界杯
_ = wc.driver.Input("世界杯")
err = wc.driver.TapByOCR("搜索")
if err != nil {
log.Error().Err(err).Msg("search 世界杯 failed")
return err
}
time.Sleep(2 * time.Second)
// 进入世界杯直播 // 进入世界杯直播
if err = wc.driver.TapByOCR("直播中"); err != nil { if err = wc.driver.TapByOCR("直播中"); err != nil {

View File

@@ -23,14 +23,14 @@ func TestConvertTimeToSeconds(t *testing.T) {
} }
func TestMainIOS(t *testing.T) { func TestMainIOS(t *testing.T) {
device := initIOSDevice() device := initIOSDevice(uuid)
wc := NewWorldCupLive(device, "", "com.ss.iphone.ugc.Aweme", 30, 10) wc := NewWorldCupLive(device, "", "com.ss.iphone.ugc.Aweme", 30, 10)
wc.Start() wc.Start()
wc.DumpResult() wc.DumpResult()
} }
func TestMainAndroid(t *testing.T) { func TestMainAndroid(t *testing.T) {
device := initAndroidDevice() device := initAndroidDevice(uuid)
wc := NewWorldCupLive(device, "", "com.ss.android.ugc.aweme", 30, 10) wc := NewWorldCupLive(device, "", "com.ss.android.ugc.aweme", 30, 10)
wc.Start() wc.Start()
wc.DumpResult() wc.DumpResult()