Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: mojom/mojom_parser/serialization/serialization_test.go

Issue 1832143003: Mojom frontend: Don't stop after processing the first method. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojom/mojom_parser/mojom/computed_data.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 NumFields: 4, 1467 NumFields: 4,
1468 NumBytes: 32, 1468 NumBytes: 32,
1469 }, 1469 },
1470 }, 1470 },
1471 }} 1471 }}
1472 1472
1473 test.endTestCase() 1473 test.endTestCase()
1474 } 1474 }
1475 1475
1476 //////////////////////////////////////////////////////////// 1476 ////////////////////////////////////////////////////////////
1477 // Test Case: Method parameter versions.
1478 ////////////////////////////////////////////////////////////
1479 {
1480 contents := `
1481 interface MyInterface42 {
1482 DoIt(int8 x0, [MinVersion=1] int64 x1, [MinVersion=2] int8 x2)
1483 => (int8 y0, [MinVersion=1] int64 y1);
1484
1485 DoItAgain(int8 x0);
1486 };`
1487
1488 test.addTestCase("", contents)
1489
1490 test.expectedFile().DeclaredMojomObjects.Interfaces = &[]string{ "TYPE_KEY:MyInterface42"}
1491
1492 test.expectedGraph().ResolvedTypes["TYPE_KEY:MyInterface42"] = & mojom_types.UserDefinedTypeInterfaceType{mojom_types.MojomInterface{
1493 DeclData: test.newDeclData("MyInterface42", "MyInterface 42"),
1494 Methods: map[uint32]mojom_types.MojomMethod{
1495 // DoIt
1496 0: mojom_types.MojomMethod{
1497 DeclData: test.newDeclData("DoIt", ""),
1498 Parameters: mojom_types.MojomStruct{
1499 DeclData: test.newDeclData("DoIt -request", ""),
1500 Fields: []mojom_types.StructFiel d{
1501 // The fields are in ord inal order and the first two arguments to newShortDeclDataO() are
1502 // declarationOrder and declaredOrdinal.
1503 // x0
1504 mojom_types.StructField{
1505 DeclData: test .newDeclDataO(0, -1, "x0", ""),
1506 Type: &moj om_types.TypeSimpleType{mojom_types.SimpleType_Int8},
1507 Offset: 0,
1508 MinVersion: 0,
1509 },
1510 // x1
1511 mojom_types.StructField{
1512 DeclData: test .newShortDeclDataAO(1, -1, "x1", &[]mojom_types.Attribute{{"MinVersion", &mojom_ types.LiteralValueInt8Value{1}}}),
1513 Type: &moj om_types.TypeSimpleType{mojom_types.SimpleType_Int64},
1514 Offset: 8,
1515 MinVersion: 1,
1516 },
1517 // x2
1518 mojom_types.StructField{
1519 DeclData: test .newShortDeclDataAO(2, -1, "x2", &[]mojom_types.Attribute{{"MinVersion", &mojom_ types.LiteralValueInt8Value{2}}}),
1520 Type: &moj om_types.TypeSimpleType{mojom_types.SimpleType_Int8},
1521 Offset: 1,
1522 MinVersion: 2,
1523 },
1524 },
1525 VersionInfo: &[]mojom_types.Stru ctVersion{
1526 mojom_types.StructVersio n{
1527 VersionNumber: 0 ,
1528 NumFields: 1 ,
1529 NumBytes: 1 6,
1530 },
1531 mojom_types.StructVersio n{
1532 VersionNumber: 1 ,
1533 NumFields: 2 ,
1534 NumBytes: 2 4,
1535 },
1536 mojom_types.StructVersio n{
1537 VersionNumber: 2 ,
1538 NumFields: 3 ,
1539 NumBytes: 2 4,
1540 },
1541 },
1542 },
1543 ResponseParams: &mojom_types.MojomStruct {
1544 DeclData: test.newDeclData("DoIt -response", ""),
1545 Fields: []mojom_types.StructFiel d{
1546 // yo
1547 mojom_types.StructField{
1548 DeclData: test .newDeclDataO(0, -1, "y0", ""),
1549 Type: &moj om_types.TypeSimpleType{mojom_types.SimpleType_Int8},
1550 Offset: 0,
1551 MinVersion: 0,
1552 },
1553 // y1
1554 mojom_types.StructField{
1555 DeclData: test .newShortDeclDataAO(1, -1, "y1", &[]mojom_types.Attribute{{"MinVersion", &mojom_ types.LiteralValueInt8Value{1}}}),
1556 Type: &moj om_types.TypeSimpleType{mojom_types.SimpleType_Int64},
1557 Offset: 8,
1558 MinVersion: 1,
1559 },
1560 },
1561 VersionInfo: &[]mojom_types.Stru ctVersion{
1562 mojom_types.StructVersio n{
1563 VersionNumber: 0 ,
1564 NumFields: 1 ,
1565 NumBytes: 1 6,
1566 },
1567 mojom_types.StructVersio n{
1568 VersionNumber: 1 ,
1569 NumFields: 2 ,
1570 NumBytes: 2 4,
1571 },
1572 },
1573 },
1574 },
1575
1576 // DoItAgain
1577 1: mojom_types.MojomMethod{
1578 DeclData: test.newDeclData("DoItAgain", ""),
1579 Parameters: mojom_types.MojomStruct{
1580 DeclData: test.newDeclData("DoIt Again-request", ""),
1581 Fields: []mojom_types.StructFiel d{
1582 // The fields are in ord inal order and the first two arguments to newShortDeclDataO() are
1583 // declarationOrder and declaredOrdinal.
1584 // x0
1585 mojom_types.StructField{
1586 DeclData: test .newDeclDataO(0, -1, "x0", ""),
1587 Type: &moj om_types.TypeSimpleType{mojom_types.SimpleType_Int8},
1588 Offset: 0,
1589 MinVersion: 0,
1590 },
1591 },
1592 VersionInfo: &[]mojom_types.Stru ctVersion{
1593 mojom_types.StructVersio n{
1594 VersionNumber: 0 ,
1595 NumFields: 1 ,
1596 NumBytes: 1 6,
1597 },
1598 },
1599 },
1600 Ordinal: 1,
1601 },
1602 },
1603 }}
1604
1605 test.endTestCase()
1606 }
1607
1608 ////////////////////////////////////////////////////////////
1477 // Test Case: 3 boolean fields 1609 // Test Case: 3 boolean fields
1478 //////////////////////////////////////////////////////////// 1610 ////////////////////////////////////////////////////////////
1479 { 1611 {
1480 contents := ` 1612 contents := `
1481 struct MyStruct1 { 1613 struct MyStruct1 {
1482 bool b1; 1614 bool b1;
1483 bool b2; 1615 bool b2;
1484 bool b3; 1616 bool b3;
1485 };` 1617 };`
1486 1618
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after
3212 } 3344 }
3213 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na ctual=\n*****\n%q\n*****\n"+ 3345 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na ctual=\n*****\n%q\n*****\n"+
3214 "match failed at position %d: expected=\n*****\n %q\n******\nactual=\n*****\n%q\n******\n", 3346 "match failed at position %d: expected=\n*****\n %q\n******\nactual=\n*****\n%q\n******\n",
3215 expectedString, actualString, diffPos, mismatchE xpected, mismatchActual) 3347 expectedString, actualString, diffPos, mismatchE xpected, mismatchActual)
3216 } else { 3348 } else {
3217 return fmt.Errorf("expected != actual but the two printe d equal.") 3349 return fmt.Errorf("expected != actual but the two printe d equal.")
3218 } 3350 }
3219 } 3351 }
3220 return nil 3352 return nil
3221 } 3353 }
OLDNEW
« no previous file with comments | « mojom/mojom_parser/mojom/computed_data.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698