| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package serialization | 5 package serialization |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "compress/gzip" | 9 "compress/gzip" |
| 10 "encoding/base64" | 10 "encoding/base64" |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 // Simulate setting the canonical file name for the imported fil
es. In real operation | 1152 // Simulate setting the canonical file name for the imported fil
es. In real operation |
| 1153 // this step is done in parser_driver.go when each of the import
ed files are parsed. | 1153 // this step is done in parser_driver.go when each of the import
ed files are parsed. |
| 1154 mojomFile := parser.GetMojomFile() | 1154 mojomFile := parser.GetMojomFile() |
| 1155 if mojomFile.Imports != nil { | 1155 if mojomFile.Imports != nil { |
| 1156 for _, imp := range mojomFile.Imports { | 1156 for _, imp := range mojomFile.Imports { |
| 1157 imp.CanonicalFileName = fmt.Sprintf("%s.canonica
l", imp.SpecifiedName) | 1157 imp.CanonicalFileName = fmt.Sprintf("%s.canonica
l", imp.SpecifiedName) |
| 1158 } | 1158 } |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 // Serialize | 1161 // Serialize |
| 1162 » » bytes, _, err := serialize(descriptor, false, false, c.lineAndco
lumnNumbers, false, false) | 1162 » » bytes, _, err := serialize(descriptor, false, false, c.lineAndco
lumnNumbers, false) |
| 1163 if err != nil { | 1163 if err != nil { |
| 1164 t.Errorf("Serialization error for %s: %s", c.fileName, e
rr.Error()) | 1164 t.Errorf("Serialization error for %s: %s", c.fileName, e
rr.Error()) |
| 1165 continue | 1165 continue |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 // Serialize again and check for consistency. | 1168 // Serialize again and check for consistency. |
| 1169 » » bytes2, _, err := serialize(descriptor, false, false, c.lineAndc
olumnNumbers, false, false) | 1169 » » bytes2, _, err := serialize(descriptor, false, false, c.lineAndc
olumnNumbers, false) |
| 1170 if err != nil { | 1170 if err != nil { |
| 1171 t.Errorf("Serialization error for %s: %s", c.fileName, e
rr.Error()) | 1171 t.Errorf("Serialization error for %s: %s", c.fileName, e
rr.Error()) |
| 1172 continue | 1172 continue |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 if !reflect.DeepEqual(bytes, bytes2) { | 1175 if !reflect.DeepEqual(bytes, bytes2) { |
| 1176 t.Errorf("Inconsistent serialization for %s:\nbytes=%v\n
bytes2=%v\n", | 1176 t.Errorf("Inconsistent serialization for %s:\nbytes=%v\n
bytes2=%v\n", |
| 1177 c.fileName, bytes, bytes2) | 1177 c.fileName, bytes, bytes2) |
| 1178 continue | 1178 continue |
| 1179 } | 1179 } |
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2307 // Simulate setting the canonical file name for the imported fil
es. In real operation | 2307 // Simulate setting the canonical file name for the imported fil
es. In real operation |
| 2308 // this step is done in parser_driver.go when each of the import
ed files are parsed. | 2308 // this step is done in parser_driver.go when each of the import
ed files are parsed. |
| 2309 mojomFile := parser.GetMojomFile() | 2309 mojomFile := parser.GetMojomFile() |
| 2310 if mojomFile.Imports != nil { | 2310 if mojomFile.Imports != nil { |
| 2311 for _, imp := range mojomFile.Imports { | 2311 for _, imp := range mojomFile.Imports { |
| 2312 imp.CanonicalFileName = fmt.Sprintf("%s.canonica
l", imp.SpecifiedName) | 2312 imp.CanonicalFileName = fmt.Sprintf("%s.canonica
l", imp.SpecifiedName) |
| 2313 } | 2313 } |
| 2314 } | 2314 } |
| 2315 | 2315 |
| 2316 // Serialize. Notice that the fourth argument is |true|. | 2316 // Serialize. Notice that the fourth argument is |true|. |
| 2317 » » bytes, _, err := serialize(descriptor, false, false, true, false
, false) | 2317 » » bytes, _, err := serialize(descriptor, false, false, true, false
) |
| 2318 if err != nil { | 2318 if err != nil { |
| 2319 t.Errorf("Serialization error for %s: %s", c.fileName, e
rr.Error()) | 2319 t.Errorf("Serialization error for %s: %s", c.fileName, e
rr.Error()) |
| 2320 continue | 2320 continue |
| 2321 } | 2321 } |
| 2322 | 2322 |
| 2323 // Serialize again and check for consistency. | 2323 // Serialize again and check for consistency. |
| 2324 » » bytes2, _, err := serialize(descriptor, false, false, true, fals
e, false) | 2324 » » bytes2, _, err := serialize(descriptor, false, false, true, fals
e) |
| 2325 if err != nil { | 2325 if err != nil { |
| 2326 t.Errorf("Serialization error for %s: %s", c.fileName, e
rr.Error()) | 2326 t.Errorf("Serialization error for %s: %s", c.fileName, e
rr.Error()) |
| 2327 continue | 2327 continue |
| 2328 } | 2328 } |
| 2329 | 2329 |
| 2330 if !reflect.DeepEqual(bytes, bytes2) { | 2330 if !reflect.DeepEqual(bytes, bytes2) { |
| 2331 t.Errorf("Inconsistent serialization for %s:\nbytes=%v\n
bytes2=%v\n", | 2331 t.Errorf("Inconsistent serialization for %s:\nbytes=%v\n
bytes2=%v\n", |
| 2332 c.fileName, bytes, bytes2) | 2332 c.fileName, bytes, bytes2) |
| 2333 continue | 2333 continue |
| 2334 } | 2334 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2407 if err := descriptor.Resolve(); err != nil { | 2407 if err := descriptor.Resolve(); err != nil { |
| 2408 t.Errorf("Resolve error for %s: %s", c.fileName, err.Err
or()) | 2408 t.Errorf("Resolve error for %s: %s", c.fileName, err.Err
or()) |
| 2409 continue | 2409 continue |
| 2410 } | 2410 } |
| 2411 if err := descriptor.ComputeFinalData(); err != nil { | 2411 if err := descriptor.ComputeFinalData(); err != nil { |
| 2412 t.Errorf("ComputeFinalData error for %s: %s", c.fileName
, err.Error()) | 2412 t.Errorf("ComputeFinalData error for %s: %s", c.fileName
, err.Error()) |
| 2413 continue | 2413 continue |
| 2414 } | 2414 } |
| 2415 | 2415 |
| 2416 // Serialize | 2416 // Serialize |
| 2417 » » bytes, _, err := serialize(descriptor, false, false, c.lineAndco
lumnNumbers, false, false) | 2417 » » bytes, _, err := serialize(descriptor, false, false, c.lineAndco
lumnNumbers, false) |
| 2418 if err != nil { | 2418 if err != nil { |
| 2419 t.Errorf("Serialization error for %s: %s", c.fileName, e
rr.Error()) | 2419 t.Errorf("Serialization error for %s: %s", c.fileName, e
rr.Error()) |
| 2420 continue | 2420 continue |
| 2421 } | 2421 } |
| 2422 | 2422 |
| 2423 // Deserialize | 2423 // Deserialize |
| 2424 decoder := bindings.NewDecoder(bytes, nil) | 2424 decoder := bindings.NewDecoder(bytes, nil) |
| 2425 fileGraph := mojom_files.MojomFileGraph{} | 2425 fileGraph := mojom_files.MojomFileGraph{} |
| 2426 fileGraph.Decode(decoder) | 2426 fileGraph.Decode(decoder) |
| 2427 | 2427 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2682 if err := descriptor.Resolve(); err != nil { | 2682 if err := descriptor.Resolve(); err != nil { |
| 2683 t.Errorf("Resolve error for case %d: %s", i, err.Error()
) | 2683 t.Errorf("Resolve error for case %d: %s", i, err.Error()
) |
| 2684 continue | 2684 continue |
| 2685 } | 2685 } |
| 2686 if err := descriptor.ComputeFinalData(); err != nil { | 2686 if err := descriptor.ComputeFinalData(); err != nil { |
| 2687 t.Errorf("ComputeFinalData error for case %d: %s", i, er
r.Error()) | 2687 t.Errorf("ComputeFinalData error for case %d: %s", i, er
r.Error()) |
| 2688 continue | 2688 continue |
| 2689 } | 2689 } |
| 2690 | 2690 |
| 2691 // Serialize | 2691 // Serialize |
| 2692 » » bytes, _, err := serialize(descriptor, false, false, c.lineAndco
lumnNumbers, false, false) | 2692 » » bytes, _, err := serialize(descriptor, false, false, c.lineAndco
lumnNumbers, false) |
| 2693 if err != nil { | 2693 if err != nil { |
| 2694 t.Errorf("Serialization error for case %d: %s", i, err.E
rror()) | 2694 t.Errorf("Serialization error for case %d: %s", i, err.E
rror()) |
| 2695 continue | 2695 continue |
| 2696 } | 2696 } |
| 2697 | 2697 |
| 2698 // Deserialize | 2698 // Deserialize |
| 2699 decoder := bindings.NewDecoder(bytes, nil) | 2699 decoder := bindings.NewDecoder(bytes, nil) |
| 2700 fileGraph := mojom_files.MojomFileGraph{} | 2700 fileGraph := mojom_files.MojomFileGraph{} |
| 2701 fileGraph.Decode(decoder) | 2701 fileGraph.Decode(decoder) |
| 2702 | 2702 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2728 func (t *runtimeTypeInfoTest) expectedRuntimeTypeInfoA() *mojom_types.RuntimeTyp
eInfo { | 2728 func (t *runtimeTypeInfoTest) expectedRuntimeTypeInfoA() *mojom_types.RuntimeTyp
eInfo { |
| 2729 return t.cases[t.testCaseNum].expectedRuntimeTypeInfoA | 2729 return t.cases[t.testCaseNum].expectedRuntimeTypeInfoA |
| 2730 } | 2730 } |
| 2731 | 2731 |
| 2732 func (t *runtimeTypeInfoTest) expectedRuntimeTypeInfoB() *mojom_types.RuntimeTyp
eInfo { | 2732 func (t *runtimeTypeInfoTest) expectedRuntimeTypeInfoB() *mojom_types.RuntimeTyp
eInfo { |
| 2733 return t.cases[t.testCaseNum].expectedRuntimeTypeInfoB | 2733 return t.cases[t.testCaseNum].expectedRuntimeTypeInfoB |
| 2734 } | 2734 } |
| 2735 | 2735 |
| 2736 func (test *runtimeTypeInfoTest) addTestCase(contentsA, contentsB string) { | 2736 func (test *runtimeTypeInfoTest) addTestCase(contentsA, contentsB string) { |
| 2737 test.cases = append(test.cases, runtimeTypeInfoTestCase{contentsA, conte
ntsB, new(mojom_types.RuntimeTypeInfo), new(mojom_types.RuntimeTypeInfo)}) | 2737 test.cases = append(test.cases, runtimeTypeInfoTestCase{contentsA, conte
ntsB, new(mojom_types.RuntimeTypeInfo), new(mojom_types.RuntimeTypeInfo)}) |
| 2738 » test.expectedRuntimeTypeInfoA().ServicesByName = make(map[string]mojom_t
ypes.ServiceTypeInfo) | 2738 » test.expectedRuntimeTypeInfoA().Services = make(map[string]string) |
| 2739 test.expectedRuntimeTypeInfoA().TypeMap = make(map[string]mojom_types.Us
erDefinedType) | 2739 test.expectedRuntimeTypeInfoA().TypeMap = make(map[string]mojom_types.Us
erDefinedType) |
| 2740 » test.expectedRuntimeTypeInfoB().ServicesByName = make(map[string]mojom_t
ypes.ServiceTypeInfo) | 2740 » test.expectedRuntimeTypeInfoB().Services = make(map[string]string) |
| 2741 test.expectedRuntimeTypeInfoB().TypeMap = make(map[string]mojom_types.Us
erDefinedType) | 2741 test.expectedRuntimeTypeInfoB().TypeMap = make(map[string]mojom_types.Us
erDefinedType) |
| 2742 } | 2742 } |
| 2743 | 2743 |
| 2744 func (test *runtimeTypeInfoTest) fileNameA() string { | 2744 func (test *runtimeTypeInfoTest) fileNameA() string { |
| 2745 return fmt.Sprintf("file%dA", test.testCaseNum) | 2745 return fmt.Sprintf("file%dA", test.testCaseNum) |
| 2746 } | 2746 } |
| 2747 | 2747 |
| 2748 func (test *runtimeTypeInfoTest) fileNameB() string { | 2748 func (test *runtimeTypeInfoTest) fileNameB() string { |
| 2749 return fmt.Sprintf("file%dB", test.testCaseNum) | 2749 return fmt.Sprintf("file%dB", test.testCaseNum) |
| 2750 } | 2750 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2915 struct FooB{ | 2915 struct FooB{ |
| 2916 }; | 2916 }; |
| 2917 | 2917 |
| 2918 interface InterfaceB { | 2918 interface InterfaceB { |
| 2919 DoIt(a.b.c.FooA x) => (FooB? y); | 2919 DoIt(a.b.c.FooA x) => (FooB? y); |
| 2920 }; | 2920 }; |
| 2921 | 2921 |
| 2922 ` | 2922 ` |
| 2923 test.addTestCase(contentsA, contentsB) | 2923 test.addTestCase(contentsA, contentsB) |
| 2924 | 2924 |
| 2925 » » // ServicesByName for file A | 2925 » » // Services for file A |
| 2926 » » test.expectedRuntimeTypeInfoA().ServicesByName["AwesomeService"]
= mojom_types.ServiceTypeInfo{ | 2926 » » test.expectedRuntimeTypeInfoA().Services["AwesomeService"] = "TY
PE_KEY:a.b.c.InterfaceA" |
| 2927 » » » TopLevelInterface: "TYPE_KEY:a.b.c.InterfaceA", | |
| 2928 » » » CompleteTypeSet: []string{"TYPE_KEY:a.b.c.FooA", "TYPE
_KEY:a.b.c.InterfaceA", "TYPE_KEY:b.c.d.FooB"}, | |
| 2929 » » } | |
| 2930 | 2927 |
| 2931 // TypeMap for file A | 2928 // TypeMap for file A |
| 2932 | 2929 |
| 2933 // FooA | 2930 // FooA |
| 2934 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.FooA"] =
&mojom_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ | 2931 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.FooA"] =
&mojom_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
| 2935 DeclData: newDeclData(test.fileNameA(), "FooA", "a.b.c.F
ooA"), | 2932 DeclData: newDeclData(test.fileNameA(), "FooA", "a.b.c.F
ooA"), |
| 2936 Fields: []mojom_types.StructField{}}} | 2933 Fields: []mojom_types.StructField{}}} |
| 2937 | 2934 |
| 2938 // InterfaceA | 2935 // InterfaceA |
| 2939 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.Interfac
eA"] = &mojom_types.UserDefinedTypeInterfaceType{mojom_types.MojomInterface{ | 2936 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.Interfac
eA"] = &mojom_types.UserDefinedTypeInterfaceType{mojom_types.MojomInterface{ |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3031 }; | 3028 }; |
| 3032 | 3029 |
| 3033 [ServiceName = 42] | 3030 [ServiceName = 42] |
| 3034 interface InterfaceB { | 3031 interface InterfaceB { |
| 3035 DoIt(a.b.c.FooA x) => (FooB? y); | 3032 DoIt(a.b.c.FooA x) => (FooB? y); |
| 3036 }; | 3033 }; |
| 3037 | 3034 |
| 3038 ` | 3035 ` |
| 3039 test.addTestCase(contentsA, contentsB) | 3036 test.addTestCase(contentsA, contentsB) |
| 3040 | 3037 |
| 3041 » » // ServicesByName for file A | 3038 » » // Services for file A |
| 3042 » » test.expectedRuntimeTypeInfoA().ServicesByName["AwesomeService"]
= mojom_types.ServiceTypeInfo{ | 3039 » » test.expectedRuntimeTypeInfoA().Services["AwesomeService"] = "TY
PE_KEY:a.b.c.InterfaceA" |
| 3043 » » » TopLevelInterface: "TYPE_KEY:a.b.c.InterfaceA", | |
| 3044 » » » CompleteTypeSet: []string{"TYPE_KEY:a.b.c.FooA", "TYPE
_KEY:a.b.c.InterfaceA", "TYPE_KEY:b.c.d.FooB"}, | |
| 3045 » » } | |
| 3046 | |
| 3047 » » // TypeMap for file A | |
| 3048 | 3040 |
| 3049 // FooA | 3041 // FooA |
| 3050 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.FooA"] =
&mojom_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ | 3042 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.FooA"] =
&mojom_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
| 3051 DeclData: newDeclData(test.fileNameA(), "FooA", "a.b.c.F
ooA"), | 3043 DeclData: newDeclData(test.fileNameA(), "FooA", "a.b.c.F
ooA"), |
| 3052 Fields: []mojom_types.StructField{}}} | 3044 Fields: []mojom_types.StructField{}}} |
| 3053 | 3045 |
| 3054 // InterfaceA | 3046 // InterfaceA |
| 3055 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.Interfac
eA"] = &mojom_types.UserDefinedTypeInterfaceType{mojom_types.MojomInterface{ | 3047 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.Interfac
eA"] = &mojom_types.UserDefinedTypeInterfaceType{mojom_types.MojomInterface{ |
| 3056 DeclData: newDeclDataA(test.fileNameA(), "InterfaceA", "
a.b.c.InterfaceA", | 3048 DeclData: newDeclDataA(test.fileNameA(), "InterfaceA", "
a.b.c.InterfaceA", |
| 3057 &[]mojom_types.Attribute{ | 3049 &[]mojom_types.Attribute{ |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3156 Enum1 x; | 3148 Enum1 x; |
| 3157 }; | 3149 }; |
| 3158 | 3150 |
| 3159 interface InterfaceB { | 3151 interface InterfaceB { |
| 3160 DoIt(a.b.c.FooA x) => (FooB? y, Enum2 z); | 3152 DoIt(a.b.c.FooA x) => (FooB? y, Enum2 z); |
| 3161 }; | 3153 }; |
| 3162 | 3154 |
| 3163 ` | 3155 ` |
| 3164 test.addTestCase(contentsA, contentsB) | 3156 test.addTestCase(contentsA, contentsB) |
| 3165 | 3157 |
| 3166 » » // ServicesByName for file A | 3158 » » // Services for file A |
| 3167 » » test.expectedRuntimeTypeInfoA().ServicesByName["AwesomeService"]
= mojom_types.ServiceTypeInfo{ | 3159 » » test.expectedRuntimeTypeInfoA().Services["AwesomeService"] = "TY
PE_KEY:a.b.c.InterfaceA" |
| 3168 » » » TopLevelInterface: "TYPE_KEY:a.b.c.InterfaceA", | |
| 3169 » » » CompleteTypeSet: []string{"TYPE_KEY:a.b.c.FooA", "TYPE
_KEY:a.b.c.InterfaceA", "TYPE_KEY:b.c.d.Enum1", "TYPE_KEY:b.c.d.FooB"}, | |
| 3170 » » } | |
| 3171 | 3160 |
| 3172 // TypeMap for file A | 3161 // TypeMap for file A |
| 3173 | 3162 |
| 3174 // FooA | 3163 // FooA |
| 3175 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.FooA"] =
&mojom_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ | 3164 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.FooA"] =
&mojom_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
| 3176 DeclData: newDeclData(test.fileNameA(), "FooA", "a.b.c.F
ooA"), | 3165 DeclData: newDeclData(test.fileNameA(), "FooA", "a.b.c.F
ooA"), |
| 3177 Fields: []mojom_types.StructField{}}} | 3166 Fields: []mojom_types.StructField{}}} |
| 3178 | 3167 |
| 3179 // InterfaceA | 3168 // InterfaceA |
| 3180 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.Interfac
eA"] = &mojom_types.UserDefinedTypeInterfaceType{mojom_types.MojomInterface{ | 3169 test.expectedRuntimeTypeInfoA().TypeMap["TYPE_KEY:a.b.c.Interfac
eA"] = &mojom_types.UserDefinedTypeInterfaceType{mojom_types.MojomInterface{ |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3302 if err := descriptor.Resolve(); err != nil { | 3291 if err := descriptor.Resolve(); err != nil { |
| 3303 t.Errorf("Resolve error for case %d: %s", i, err.Error()
) | 3292 t.Errorf("Resolve error for case %d: %s", i, err.Error()
) |
| 3304 continue | 3293 continue |
| 3305 } | 3294 } |
| 3306 if err := descriptor.ComputeFinalData(); err != nil { | 3295 if err := descriptor.ComputeFinalData(); err != nil { |
| 3307 t.Errorf("ComputeFinalData error for case %d: %s", i, er
r.Error()) | 3296 t.Errorf("ComputeFinalData error for case %d: %s", i, er
r.Error()) |
| 3308 continue | 3297 continue |
| 3309 } | 3298 } |
| 3310 | 3299 |
| 3311 // Serialize | 3300 // Serialize |
| 3312 » » bytes, _, err := serialize(descriptor, false, false, false, true
, true) | 3301 » » bytes, _, err := serialize(descriptor, false, false, false, true
) |
| 3313 if err != nil { | 3302 if err != nil { |
| 3314 t.Errorf("Serialization error for case %d: %s", i, err.E
rror()) | 3303 t.Errorf("Serialization error for case %d: %s", i, err.E
rror()) |
| 3315 continue | 3304 continue |
| 3316 } | 3305 } |
| 3317 | 3306 |
| 3318 // Deserialize | 3307 // Deserialize |
| 3319 decoder := bindings.NewDecoder(bytes, nil) | 3308 decoder := bindings.NewDecoder(bytes, nil) |
| 3320 fileGraph := mojom_files.MojomFileGraph{} | 3309 fileGraph := mojom_files.MojomFileGraph{} |
| 3321 fileGraph.Decode(decoder) | 3310 fileGraph.Decode(decoder) |
| 3322 | 3311 |
| 3323 // Deserialize RuntimeTypeInfo A | 3312 // Deserialize RuntimeTypeInfo A |
| 3324 runtimeTypeInfoA := deserializeRuntimeTypeInfo(*fileGraph.Files[
fileNameA].SerializedRuntimeTypeInfo) | 3313 runtimeTypeInfoA := deserializeRuntimeTypeInfo(*fileGraph.Files[
fileNameA].SerializedRuntimeTypeInfo) |
| 3325 | 3314 |
| 3326 // Deserialize RuntimeTypeInfo B | 3315 // Deserialize RuntimeTypeInfo B |
| 3327 runtimeTypeInfoB := deserializeRuntimeTypeInfo(*fileGraph.Files[
fileNameB].SerializedRuntimeTypeInfo) | 3316 runtimeTypeInfoB := deserializeRuntimeTypeInfo(*fileGraph.Files[
fileNameB].SerializedRuntimeTypeInfo) |
| 3328 | 3317 |
| 3329 // Compare A | 3318 // Compare A |
| 3330 if err := compareTwoGoObjects(c.expectedRuntimeTypeInfoA, &runti
meTypeInfoA); err != nil { | 3319 if err := compareTwoGoObjects(c.expectedRuntimeTypeInfoA, &runti
meTypeInfoA); err != nil { |
| 3331 t.Errorf("case %d A:\n%s", i, err.Error()) | 3320 t.Errorf("case %d A:\n%s", i, err.Error()) |
| 3332 } | 3321 } |
| 3333 | 3322 |
| 3334 // Compare B | 3323 // Compare B |
| 3335 if err := compareTwoGoObjects(c.expectedRuntimeTypeInfoB, &runti
meTypeInfoB); err != nil { | 3324 if err := compareTwoGoObjects(c.expectedRuntimeTypeInfoB, &runti
meTypeInfoB); err != nil { |
| 3336 t.Errorf("case %d B:\n%s", i, err.Error()) | 3325 t.Errorf("case %d B:\n%s", i, err.Error()) |
| 3337 } | 3326 } |
| 3338 | |
| 3339 // Test the parameter populateCompleteTypeSet. We set the final | |
| 3340 // parameter to false. | |
| 3341 bytes, _, err = serialize(descriptor, false, false, false, true,
false) | |
| 3342 if err != nil { | |
| 3343 t.Errorf("Serialization error for case %d: %s", i, err.E
rror()) | |
| 3344 continue | |
| 3345 } | |
| 3346 | |
| 3347 // Deserialize | |
| 3348 decoder = bindings.NewDecoder(bytes, nil) | |
| 3349 fileGraph = mojom_files.MojomFileGraph{} | |
| 3350 fileGraph.Decode(decoder) | |
| 3351 runtimeTypeInfoA = deserializeRuntimeTypeInfo(*fileGraph.Files[f
ileNameA].SerializedRuntimeTypeInfo) | |
| 3352 | |
| 3353 // Check that CompleteTypeSet has not been populated for any ser
vice. | |
| 3354 for name, service := range runtimeTypeInfoA.ServicesByName { | |
| 3355 length := len(service.CompleteTypeSet) | |
| 3356 if length != 0 { | |
| 3357 t.Errorf("len(CompleteTypeSet)=%d for service=%q
", length, name) | |
| 3358 } | |
| 3359 } | |
| 3360 } | 3327 } |
| 3361 } | 3328 } |
| 3362 | 3329 |
| 3363 func deserializeRuntimeTypeInfo(base64String string) mojom_types.RuntimeTypeInfo
{ | 3330 func deserializeRuntimeTypeInfo(base64String string) mojom_types.RuntimeTypeInfo
{ |
| 3364 compressedBytes, err := base64.StdEncoding.DecodeString(base64String) | 3331 compressedBytes, err := base64.StdEncoding.DecodeString(base64String) |
| 3365 if err != nil { | 3332 if err != nil { |
| 3366 panic(fmt.Sprintf("Error while unencoding runtimeTypeInfo: %s",
err.Error())) | 3333 panic(fmt.Sprintf("Error while unencoding runtimeTypeInfo: %s",
err.Error())) |
| 3367 } | 3334 } |
| 3368 reader, err2 := gzip.NewReader(bytes.NewBuffer(compressedBytes)) | 3335 reader, err2 := gzip.NewReader(bytes.NewBuffer(compressedBytes)) |
| 3369 if err2 != nil { | 3336 if err2 != nil { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3410 } | 3377 } |
| 3411 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na
ctual=\n*****\n%q\n*****\n"+ | 3378 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na
ctual=\n*****\n%q\n*****\n"+ |
| 3412 "match failed at position %d: expected=\n*****\n
%q\n******\nactual=\n*****\n%q\n******\n", | 3379 "match failed at position %d: expected=\n*****\n
%q\n******\nactual=\n*****\n%q\n******\n", |
| 3413 expectedString, actualString, diffPos, mismatchE
xpected, mismatchActual) | 3380 expectedString, actualString, diffPos, mismatchE
xpected, mismatchActual) |
| 3414 } else { | 3381 } else { |
| 3415 return fmt.Errorf("expected != actual but the two printe
d equal.") | 3382 return fmt.Errorf("expected != actual but the two printe
d equal.") |
| 3416 } | 3383 } |
| 3417 } | 3384 } |
| 3418 return nil | 3385 return nil |
| 3419 } | 3386 } |
| OLD | NEW |