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 1168 matching lines...) Loading... |
1179 // struct Foo | 1179 // struct Foo |
1180 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeStructType{mojom_types.MojomStruct{ | 1180 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
1181 DeclData: test.newDeclData("Foo", "Foo"), | 1181 DeclData: test.newDeclData("Foo", "Foo"), |
1182 Fields: []mojom_types.StructField{ | 1182 Fields: []mojom_types.StructField{ |
1183 // The fields are in ordinal order and the first
two arguments to newShortDeclDataO() are | 1183 // The fields are in ordinal order and the first
two arguments to newShortDeclDataO() are |
1184 // declarationOrder and declaredOrdinal. | 1184 // declarationOrder and declaredOrdinal. |
1185 // field x | 1185 // field x |
1186 { | 1186 { |
1187 DeclData: test.newShortDeclDataO(0, -1,
"x"), | 1187 DeclData: test.newShortDeclDataO(0, -1,
"x"), |
1188 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, | 1188 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, |
| 1189 Offset: 0, |
1189 }, | 1190 }, |
1190 // field y | 1191 // field y |
1191 { | 1192 { |
1192 DeclData: test.newShortDeclDataO(1, -1,
"y"), | 1193 DeclData: test.newShortDeclDataO(1, -1,
"y"), |
1193 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, | 1194 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, |
| 1195 Offset: 4, |
1194 }, | 1196 }, |
1195 // field z | 1197 // field z |
1196 { | 1198 { |
1197 DeclData: test.newShortDeclDataAO(2, -
1, "z", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{1}}}), | 1199 DeclData: test.newShortDeclDataAO(2, -
1, "z", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{1}}}), |
1198 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, | 1200 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, |
1199 MinVersion: 1, | 1201 MinVersion: 1, |
| 1202 Offset: 8, |
1200 }, | 1203 }, |
1201 // field w | 1204 // field w |
1202 { | 1205 { |
1203 DeclData: test.newShortDeclDataAO(3, -
1, "w", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{2}}}), | 1206 DeclData: test.newShortDeclDataAO(3, -
1, "w", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{2}}}), |
1204 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, | 1207 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, |
1205 MinVersion: 2, | 1208 MinVersion: 2, |
| 1209 Offset: 16, |
1206 }, | 1210 }, |
1207 }, | 1211 }, |
1208 VersionInfo: &[]mojom_types.StructVersion{ | 1212 VersionInfo: &[]mojom_types.StructVersion{ |
1209 mojom_types.StructVersion{ | 1213 mojom_types.StructVersion{ |
1210 VersionNumber: 0, | 1214 VersionNumber: 0, |
1211 NumFields: 2, | 1215 NumFields: 2, |
1212 » » » » » NumBytes: 0, | 1216 » » » » » NumBytes: 16, |
1213 }, | 1217 }, |
1214 mojom_types.StructVersion{ | 1218 mojom_types.StructVersion{ |
1215 VersionNumber: 1, | 1219 VersionNumber: 1, |
1216 NumFields: 3, | 1220 NumFields: 3, |
1217 » » » » » NumBytes: 0, | 1221 » » » » » NumBytes: 24, |
1218 }, | 1222 }, |
1219 mojom_types.StructVersion{ | 1223 mojom_types.StructVersion{ |
1220 VersionNumber: 2, | 1224 VersionNumber: 2, |
1221 NumFields: 4, | 1225 NumFields: 4, |
1222 » » » » » NumBytes: 0, | 1226 » » » » » NumBytes: 32, |
1223 }, | 1227 }, |
1224 }, | 1228 }, |
1225 }} | 1229 }} |
1226 | 1230 |
1227 test.endTestCase() | 1231 test.endTestCase() |
1228 } | 1232 } |
1229 | 1233 |
1230 //////////////////////////////////////////////////////////// | 1234 //////////////////////////////////////////////////////////// |
1231 // Test Case: Test struct field min versions: 1, 3 | 1235 // Test Case: Test struct field min versions: 1, 3 |
1232 //////////////////////////////////////////////////////////// | 1236 //////////////////////////////////////////////////////////// |
(...skipping 19 matching lines...) Loading... |
1252 // struct Foo | 1256 // struct Foo |
1253 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeStructType{mojom_types.MojomStruct{ | 1257 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
1254 DeclData: test.newDeclData("Foo", "Foo"), | 1258 DeclData: test.newDeclData("Foo", "Foo"), |
1255 Fields: []mojom_types.StructField{ | 1259 Fields: []mojom_types.StructField{ |
1256 // The fields are in ordinal order and the first
two arguments to newShortDeclDataO() are | 1260 // The fields are in ordinal order and the first
two arguments to newShortDeclDataO() are |
1257 // declarationOrder and declaredOrdinal. | 1261 // declarationOrder and declaredOrdinal. |
1258 // field x | 1262 // field x |
1259 { | 1263 { |
1260 DeclData: test.newShortDeclDataO(0, -1,
"x"), | 1264 DeclData: test.newShortDeclDataO(0, -1,
"x"), |
1261 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, | 1265 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, |
| 1266 Offset: 0, |
1262 }, | 1267 }, |
1263 // field y | 1268 // field y |
1264 { | 1269 { |
1265 DeclData: test.newShortDeclDataO(1, -1,
"y"), | 1270 DeclData: test.newShortDeclDataO(1, -1,
"y"), |
1266 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, | 1271 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, |
| 1272 Offset: 4, |
1267 }, | 1273 }, |
1268 // field z | 1274 // field z |
1269 { | 1275 { |
1270 DeclData: test.newShortDeclDataAO(2, -
1, "z", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{1}}}), | 1276 DeclData: test.newShortDeclDataAO(2, -
1, "z", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{1}}}), |
1271 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, | 1277 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, |
1272 MinVersion: 1, | 1278 MinVersion: 1, |
| 1279 Offset: 8, |
1273 }, | 1280 }, |
1274 // field w | 1281 // field w |
1275 { | 1282 { |
1276 DeclData: test.newShortDeclDataAO(3, -
1, "w", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{3}}}), | 1283 DeclData: test.newShortDeclDataAO(3, -
1, "w", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{3}}}), |
1277 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, | 1284 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, |
1278 MinVersion: 3, | 1285 MinVersion: 3, |
| 1286 Offset: 16, |
1279 }, | 1287 }, |
1280 }, | 1288 }, |
1281 VersionInfo: &[]mojom_types.StructVersion{ | 1289 VersionInfo: &[]mojom_types.StructVersion{ |
1282 mojom_types.StructVersion{ | 1290 mojom_types.StructVersion{ |
1283 VersionNumber: 0, | 1291 VersionNumber: 0, |
1284 NumFields: 2, | 1292 NumFields: 2, |
1285 » » » » » NumBytes: 0, | 1293 » » » » » NumBytes: 16, |
1286 }, | 1294 }, |
1287 mojom_types.StructVersion{ | 1295 mojom_types.StructVersion{ |
1288 VersionNumber: 1, | 1296 VersionNumber: 1, |
1289 NumFields: 3, | 1297 NumFields: 3, |
1290 » » » » » NumBytes: 0, | 1298 » » » » » NumBytes: 24, |
1291 }, | 1299 }, |
1292 mojom_types.StructVersion{ | 1300 mojom_types.StructVersion{ |
1293 VersionNumber: 3, | 1301 VersionNumber: 3, |
1294 NumFields: 4, | 1302 NumFields: 4, |
1295 » » » » » NumBytes: 0, | 1303 » » » » » NumBytes: 32, |
1296 }, | 1304 }, |
1297 }, | 1305 }, |
1298 }} | 1306 }} |
1299 | 1307 |
1300 test.endTestCase() | 1308 test.endTestCase() |
1301 } | 1309 } |
1302 | 1310 |
1303 //////////////////////////////////////////////////////////// | 1311 //////////////////////////////////////////////////////////// |
1304 // Test Case: Test struct field min versions: 1, 1 | 1312 // Test Case: Test struct field min versions: 1, 1 |
1305 //////////////////////////////////////////////////////////// | 1313 //////////////////////////////////////////////////////////// |
(...skipping 19 matching lines...) Loading... |
1325 // struct Foo | 1333 // struct Foo |
1326 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeStructType{mojom_types.MojomStruct{ | 1334 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
1327 DeclData: test.newDeclData("Foo", "Foo"), | 1335 DeclData: test.newDeclData("Foo", "Foo"), |
1328 Fields: []mojom_types.StructField{ | 1336 Fields: []mojom_types.StructField{ |
1329 // The fields are in ordinal order and the first
two arguments to newShortDeclDataO() are | 1337 // The fields are in ordinal order and the first
two arguments to newShortDeclDataO() are |
1330 // declarationOrder and declaredOrdinal. | 1338 // declarationOrder and declaredOrdinal. |
1331 // field x | 1339 // field x |
1332 { | 1340 { |
1333 DeclData: test.newShortDeclDataO(0, -1,
"x"), | 1341 DeclData: test.newShortDeclDataO(0, -1,
"x"), |
1334 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, | 1342 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, |
| 1343 Offset: 0, |
1335 }, | 1344 }, |
1336 // field y | 1345 // field y |
1337 { | 1346 { |
1338 DeclData: test.newShortDeclDataO(1, -1,
"y"), | 1347 DeclData: test.newShortDeclDataO(1, -1,
"y"), |
1339 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, | 1348 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, |
| 1349 Offset: 4, |
1340 }, | 1350 }, |
1341 // field z | 1351 // field z |
1342 { | 1352 { |
1343 DeclData: test.newShortDeclDataAO(2, -
1, "z", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{1}}}), | 1353 DeclData: test.newShortDeclDataAO(2, -
1, "z", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{1}}}), |
1344 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, | 1354 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, |
1345 MinVersion: 1, | 1355 MinVersion: 1, |
| 1356 Offset: 8, |
1346 }, | 1357 }, |
1347 // field w | 1358 // field w |
1348 { | 1359 { |
1349 DeclData: test.newShortDeclDataAO(3, -
1, "w", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{1}}}), | 1360 DeclData: test.newShortDeclDataAO(3, -
1, "w", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Val
ue{1}}}), |
1350 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, | 1361 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, |
1351 MinVersion: 1, | 1362 MinVersion: 1, |
| 1363 Offset: 16, |
1352 }, | 1364 }, |
1353 }, | 1365 }, |
1354 VersionInfo: &[]mojom_types.StructVersion{ | 1366 VersionInfo: &[]mojom_types.StructVersion{ |
1355 mojom_types.StructVersion{ | 1367 mojom_types.StructVersion{ |
1356 VersionNumber: 0, | 1368 VersionNumber: 0, |
1357 NumFields: 2, | 1369 NumFields: 2, |
1358 » » » » » NumBytes: 0, | 1370 » » » » » NumBytes: 16, |
1359 }, | 1371 }, |
1360 mojom_types.StructVersion{ | 1372 mojom_types.StructVersion{ |
1361 VersionNumber: 1, | 1373 VersionNumber: 1, |
1362 NumFields: 4, | 1374 NumFields: 4, |
1363 » » » » » NumBytes: 0, | 1375 » » » » » NumBytes: 32, |
1364 }, | 1376 }, |
1365 }, | 1377 }, |
1366 }} | 1378 }} |
1367 | 1379 |
1368 test.endTestCase() | 1380 test.endTestCase() |
1369 } | 1381 } |
1370 | 1382 |
1371 //////////////////////////////////////////////////////////// | 1383 //////////////////////////////////////////////////////////// |
1372 // Test Case: Test struct field min versions: 1,2 with specified ordinal
s | 1384 // Test Case: Test struct field min versions: 1,2 with specified ordinal
s |
1373 //////////////////////////////////////////////////////////// | 1385 //////////////////////////////////////////////////////////// |
(...skipping 20 matching lines...) Loading... |
1394 // struct Foo | 1406 // struct Foo |
1395 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeStructType{mojom_types.MojomStruct{ | 1407 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
1396 DeclData: test.newDeclData("Foo", "Foo"), | 1408 DeclData: test.newDeclData("Foo", "Foo"), |
1397 Fields: []mojom_types.StructField{ | 1409 Fields: []mojom_types.StructField{ |
1398 // The fields are in ordinal order and the first
two arguments to newShortDeclDataO() are | 1410 // The fields are in ordinal order and the first
two arguments to newShortDeclDataO() are |
1399 // declarationOrder and declaredOrdinal. | 1411 // declarationOrder and declaredOrdinal. |
1400 // field x | 1412 // field x |
1401 { | 1413 { |
1402 DeclData: test.newShortDeclDataO(3, 0, "
x"), | 1414 DeclData: test.newShortDeclDataO(3, 0, "
x"), |
1403 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, | 1415 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, |
| 1416 Offset: 0, |
1404 }, | 1417 }, |
1405 // field y | 1418 // field y |
1406 { | 1419 { |
1407 DeclData: test.newShortDeclDataO(0, 1, "
y"), | 1420 DeclData: test.newShortDeclDataO(0, 1, "
y"), |
1408 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, | 1421 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, |
| 1422 Offset: 4, |
1409 }, | 1423 }, |
1410 // field z | 1424 // field z |
1411 { | 1425 { |
1412 DeclData: test.newShortDeclDataAO(1, 2
, "z", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Valu
e{1}}}), | 1426 DeclData: test.newShortDeclDataAO(1, 2
, "z", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Valu
e{1}}}), |
1413 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, | 1427 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, |
1414 MinVersion: 1, | 1428 MinVersion: 1, |
| 1429 Offset: 8, |
1415 }, | 1430 }, |
1416 // field w | 1431 // field w |
1417 { | 1432 { |
1418 DeclData: test.newShortDeclDataAO(2, 3
, "w", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Valu
e{2}}}), | 1433 DeclData: test.newShortDeclDataAO(2, 3
, "w", &[]mojom_types.Attribute{{"MinVersion", &mojom_types.LiteralValueInt8Valu
e{2}}}), |
1419 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, | 1434 Type: &mojom_types.TypeArrayType{m
ojom_types.ArrayType{true, -1, &mojom_types.TypeSimpleType{mojom_types.SimpleTyp
e_Int32}}}, |
1420 MinVersion: 2, | 1435 MinVersion: 2, |
| 1436 Offset: 16, |
1421 }, | 1437 }, |
1422 }, | 1438 }, |
1423 VersionInfo: &[]mojom_types.StructVersion{ | 1439 VersionInfo: &[]mojom_types.StructVersion{ |
1424 mojom_types.StructVersion{ | 1440 mojom_types.StructVersion{ |
1425 VersionNumber: 0, | 1441 VersionNumber: 0, |
1426 NumFields: 2, | 1442 NumFields: 2, |
1427 » » » » » NumBytes: 0, | 1443 » » » » » NumBytes: 16, |
1428 }, | 1444 }, |
1429 mojom_types.StructVersion{ | 1445 mojom_types.StructVersion{ |
1430 VersionNumber: 1, | 1446 VersionNumber: 1, |
1431 NumFields: 3, | 1447 NumFields: 3, |
1432 » » » » » NumBytes: 0, | 1448 » » » » » NumBytes: 24, |
1433 }, | 1449 }, |
1434 mojom_types.StructVersion{ | 1450 mojom_types.StructVersion{ |
1435 VersionNumber: 2, | 1451 VersionNumber: 2, |
1436 NumFields: 4, | 1452 NumFields: 4, |
1437 » » » » » NumBytes: 0, | 1453 » » » » » NumBytes: 32, |
1438 }, | 1454 }, |
1439 }, | 1455 }, |
1440 }} | 1456 }} |
| 1457 |
| 1458 test.endTestCase() |
| 1459 } |
| 1460 |
| 1461 //////////////////////////////////////////////////////////// |
| 1462 // Test Case: 3 boolean fields |
| 1463 //////////////////////////////////////////////////////////// |
| 1464 { |
| 1465 contents := ` |
| 1466 struct MyStruct1 { |
| 1467 bool b1; |
| 1468 bool b2; |
| 1469 bool b3; |
| 1470 };` |
| 1471 |
| 1472 test.addTestCase("", contents) |
| 1473 |
| 1474 test.expectedFile().DeclaredMojomObjects.Structs = &[]string{"TY
PE_KEY:MyStruct1"} |
| 1475 |
| 1476 // ResolvedTypes |
| 1477 |
| 1478 // struct Foo |
| 1479 test.expectedGraph().ResolvedTypes["TYPE_KEY:MyStruct1"] = &mojo
m_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
| 1480 DeclData: test.newDeclData("MyStruct1", "MyStruct1"), |
| 1481 Fields: []mojom_types.StructField{ |
| 1482 // The fields are in ordinal order and the first
two arguments to newShortDeclDataO() are |
| 1483 // declarationOrder and declaredOrdinal. |
| 1484 // field b1 |
| 1485 { |
| 1486 DeclData: test.newShortDeclDataO(0, -1,
"b1"), |
| 1487 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Bool}, |
| 1488 Offset: 0, |
| 1489 Bit: 0, |
| 1490 }, |
| 1491 // field b2 |
| 1492 { |
| 1493 DeclData: test.newShortDeclDataO(1, -1,
"b2"), |
| 1494 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Bool}, |
| 1495 Offset: 0, |
| 1496 Bit: 1, |
| 1497 }, |
| 1498 // field b3 |
| 1499 { |
| 1500 DeclData: test.newShortDeclDataO(2, -1,
"b3"), |
| 1501 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Bool}, |
| 1502 Offset: 0, |
| 1503 Bit: 2, |
| 1504 }, |
| 1505 }, |
| 1506 VersionInfo: &[]mojom_types.StructVersion{ |
| 1507 mojom_types.StructVersion{ |
| 1508 VersionNumber: 0, |
| 1509 NumFields: 3, |
| 1510 NumBytes: 16, |
| 1511 }, |
| 1512 }, |
| 1513 }} |
| 1514 |
| 1515 test.endTestCase() |
| 1516 } |
| 1517 |
| 1518 //////////////////////////////////////////////////////////// |
| 1519 // Test Case: int8 field + 2 boolean fields + int32field + 2 boolean fie
lds |
| 1520 //////////////////////////////////////////////////////////// |
| 1521 { |
| 1522 contents := ` |
| 1523 struct MyStruct1 { |
| 1524 int8 x; |
| 1525 |
| 1526 bool b1; |
| 1527 bool b2; |
| 1528 |
| 1529 int32 y; |
| 1530 |
| 1531 bool b3; |
| 1532 bool b4; |
| 1533 };` |
| 1534 |
| 1535 test.addTestCase("", contents) |
| 1536 |
| 1537 test.expectedFile().DeclaredMojomObjects.Structs = &[]string{"TY
PE_KEY:MyStruct1"} |
| 1538 |
| 1539 // ResolvedTypes |
| 1540 |
| 1541 // struct Foo |
| 1542 test.expectedGraph().ResolvedTypes["TYPE_KEY:MyStruct1"] = &mojo
m_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
| 1543 DeclData: test.newDeclData("MyStruct1", "MyStruct1"), |
| 1544 Fields: []mojom_types.StructField{ |
| 1545 // The fields are in ordinal order and the first
two arguments to newShortDeclDataO() are |
| 1546 // declarationOrder and declaredOrdinal. |
| 1547 // field x |
| 1548 { |
| 1549 DeclData: test.newShortDeclDataO(0, -1,
"x"), |
| 1550 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int8}, |
| 1551 Offset: 0, |
| 1552 }, |
| 1553 // field b1 |
| 1554 { |
| 1555 DeclData: test.newShortDeclDataO(1, -1,
"b1"), |
| 1556 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Bool}, |
| 1557 Offset: 1, |
| 1558 Bit: 0, |
| 1559 }, |
| 1560 // field b2 |
| 1561 { |
| 1562 DeclData: test.newShortDeclDataO(2, -1,
"b2"), |
| 1563 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Bool}, |
| 1564 Offset: 1, |
| 1565 Bit: 1, |
| 1566 }, |
| 1567 // field y |
| 1568 { |
| 1569 DeclData: test.newShortDeclDataO(3, -1,
"y"), |
| 1570 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Int32}, |
| 1571 Offset: 4, |
| 1572 }, |
| 1573 // field b3 |
| 1574 { |
| 1575 DeclData: test.newShortDeclDataO(4, -1,
"b3"), |
| 1576 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Bool}, |
| 1577 Offset: 1, |
| 1578 Bit: 2, |
| 1579 }, |
| 1580 // field b4 |
| 1581 { |
| 1582 DeclData: test.newShortDeclDataO(5, -1,
"b4"), |
| 1583 Type: &mojom_types.TypeSimpleType{mo
jom_types.SimpleType_Bool}, |
| 1584 Offset: 1, |
| 1585 Bit: 3, |
| 1586 }, |
| 1587 }, |
| 1588 VersionInfo: &[]mojom_types.StructVersion{ |
| 1589 mojom_types.StructVersion{ |
| 1590 VersionNumber: 0, |
| 1591 NumFields: 6, |
| 1592 NumBytes: 16, |
| 1593 }, |
| 1594 }, |
| 1595 }} |
1441 | 1596 |
1442 test.endTestCase() | 1597 test.endTestCase() |
1443 } | 1598 } |
1444 | 1599 |
1445 //////////////////////////////////////////////////////////// | 1600 //////////////////////////////////////////////////////////// |
1446 // Execute all of the test cases. | 1601 // Execute all of the test cases. |
1447 //////////////////////////////////////////////////////////// | 1602 //////////////////////////////////////////////////////////// |
1448 for _, c := range test.cases { | 1603 for _, c := range test.cases { |
1449 // Parse and resolve the mojom input. | 1604 // Parse and resolve the mojom input. |
1450 descriptor := mojom.NewMojomDescriptor() | 1605 descriptor := mojom.NewMojomDescriptor() |
(...skipping 1118 matching lines...) Loading... |
2569 } | 2724 } |
2570 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na
ctual=\n*****\n%q\n*****\n"+ | 2725 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na
ctual=\n*****\n%q\n*****\n"+ |
2571 "match failed at position %d: expected=\n*****\n
%q\n******\nactual=\n*****\n%q\n******\n", | 2726 "match failed at position %d: expected=\n*****\n
%q\n******\nactual=\n*****\n%q\n******\n", |
2572 expectedString, actualString, diffPos, mismatchE
xpected, mismatchActual) | 2727 expectedString, actualString, diffPos, mismatchE
xpected, mismatchActual) |
2573 } else { | 2728 } else { |
2574 return fmt.Errorf("expected != actual but the two printe
d equal.") | 2729 return fmt.Errorf("expected != actual but the two printe
d equal.") |
2575 } | 2730 } |
2576 } | 2731 } |
2577 return nil | 2732 return nil |
2578 } | 2733 } |
OLD | NEW |