mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 03:30:01 +08:00
feat: GetPackageInfo for ios
This commit is contained in:
@@ -453,6 +453,7 @@ func (dev *AndroidDevice) GetPackageInfo(packageName string) (AppInfo, error) {
|
|||||||
PackageName: packageName,
|
PackageName: packageName,
|
||||||
VersionName: matches[1],
|
VersionName: matches[1],
|
||||||
}
|
}
|
||||||
|
log.Info().Interface("appInfo", appInfo).Msg("get app info")
|
||||||
return appInfo, nil
|
return appInfo, nil
|
||||||
}
|
}
|
||||||
return appInfo, errors.New("failed to get package version")
|
return appInfo, errors.New("failed to get package version")
|
||||||
|
|||||||
@@ -42,6 +42,14 @@ func TestAndroidDevice_GetPackageInfo(t *testing.T) {
|
|||||||
t.Log(appInfo)
|
t.Log(appInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIOSDevice_GetPackageInfo(t *testing.T) {
|
||||||
|
device, err := NewIOSDevice()
|
||||||
|
checkErr(t, err)
|
||||||
|
appInfo, err := device.GetPackageInfo("com.apple.Preferences")
|
||||||
|
checkErr(t, err)
|
||||||
|
t.Log(appInfo)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDriver_NewSession(t *testing.T) {
|
func TestDriver_NewSession(t *testing.T) {
|
||||||
driver, err := NewUIADriver(nil, uiaServerURL)
|
driver, err := NewUIADriver(nil, uiaServerURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mitchellh/mapstructure"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
@@ -734,6 +735,39 @@ func (dev *IOSDevice) RunXCTest(bundleID string) (cancel context.CancelFunc, err
|
|||||||
return cancel, nil
|
return cancel, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Application struct {
|
||||||
|
CFBundleVersion string `json:"version"`
|
||||||
|
CFBundleDisplayName string `json:"name"`
|
||||||
|
CFBundleIdentifier string `json:"bundleId"`
|
||||||
|
}
|
||||||
|
|
||||||
func (dev *IOSDevice) GetPackageInfo(packageName string) (AppInfo, error) {
|
func (dev *IOSDevice) GetPackageInfo(packageName string) (AppInfo, error) {
|
||||||
return AppInfo{}, nil
|
appInfo := AppInfo{
|
||||||
|
Name: packageName,
|
||||||
|
}
|
||||||
|
applicationType := gidevice.ApplicationTypeAny
|
||||||
|
result, err := dev.d.InstallationProxyBrowse(
|
||||||
|
gidevice.WithApplicationType(applicationType),
|
||||||
|
gidevice.WithReturnAttributes("CFBundleVersion", "CFBundleDisplayName", "CFBundleIdentifier"))
|
||||||
|
if err != nil {
|
||||||
|
return appInfo, errors.Wrap(code.DeviceShellExecError,
|
||||||
|
fmt.Sprintf("get app list failed %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, app := range result {
|
||||||
|
a := Application{}
|
||||||
|
mapstructure.Decode(app, &a)
|
||||||
|
|
||||||
|
if a.CFBundleIdentifier != packageName {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
appInfo.AppBaseInfo = AppBaseInfo{
|
||||||
|
BundleId: a.CFBundleIdentifier,
|
||||||
|
VersionName: a.CFBundleVersion,
|
||||||
|
AppName: a.CFBundleDisplayName,
|
||||||
|
}
|
||||||
|
log.Info().Interface("appInfo", appInfo).Msg("get app info")
|
||||||
|
return appInfo, nil
|
||||||
|
}
|
||||||
|
return appInfo, errors.New("failed to get package version")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user