forked from electricbubble/gidevice
-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
xctestconfiguration.go
88 lines (78 loc) 路 2.92 KB
/
xctestconfiguration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package nskeyedarchiver
import (
"howett.net/plist"
"reflect"
)
type XCTestConfiguration struct {
internal map[string]interface{}
}
func newXCTestConfiguration(cfg interface{}) *XCTestConfiguration {
return cfg.(*XCTestConfiguration)
}
func NewXCTestConfiguration(nsuuid *NSUUID, nsurl *NSURL, targetBundleID, targetAppPath string) *XCTestConfiguration {
contents := map[string]interface{}{
"aggregateStatisticsBeforeCrash": map[string]interface{}{
"XCSuiteRecordsKey": map[string]interface{}{},
},
"automationFrameworkPath": "/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework",
"baselineFileRelativePath": nil,
"baselineFileURL": nil,
"defaultTestExecutionTimeAllowance": nil,
"disablePerformanceMetrics": false,
"emitOSLogs": false,
"formatVersion": 2,
"gatherLocalizableStringsData": false,
"initializeForUITesting": true,
"maximumTestExecutionTimeAllowance": nil,
"productModuleName": "WebDriverAgentRunner", // set to other value is also OK
"randomExecutionOrderingSeed": nil,
"reportActivities": true,
"reportResultsToIDE": true,
"systemAttachmentLifetime": 2,
"targetApplicationArguments": []interface{}{}, // maybe useless
"targetApplicationEnvironment": nil,
"targetApplicationPath": targetAppPath,
"testApplicationDependencies": map[string]interface{}{},
"testApplicationUserOverrides": nil,
"testBundleRelativePath": nil,
"testExecutionOrdering": 0,
"testTimeoutsEnabled": false,
"testsDrivenByIDE": false,
"testsMustRunOnMainThread": true,
"testsToRun": nil,
"testsToSkip": nil,
"treatMissingBaselinesAsFailures": false,
"userAttachmentLifetime": 1,
"testBundleURL": nsurl,
"sessionIdentifier": nsuuid,
"targetApplicationBundleID": targetBundleID,
// "targetApplicationBundleID": "",
}
return &XCTestConfiguration{internal: contents}
}
func (cfg *XCTestConfiguration) archive(objects []interface{}) []interface{} {
info := map[string]interface{}{}
objects = append(objects, info)
info["$class"] = plist.UID(len(objects))
cls := map[string]interface{}{
"$classname": "XCTestConfiguration",
"$classes": []interface{}{"XCTestConfiguration", "NSObject"},
}
objects = append(objects, cls)
for k, v := range cfg.internal {
val := reflect.ValueOf(v)
if !val.IsValid() {
info[k] = plist.UID(0)
continue
}
typ := val.Type()
if k != "formatVersion" && (typ.Kind() == reflect.Bool || typ.Kind() == reflect.Uintptr || typ.Kind() == reflect.Int) {
info[k] = v
} else {
var uid plist.UID
objects, uid = archive(objects, v)
info[k] = uid
}
}
return objects
}