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

Unified Diff: mojo/go/tests/validation_type_test.go

Issue 1483313002: go generator: generate full identifiers (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/go_templates/mojom_type_macros.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/go/tests/validation_type_test.go
diff --git a/mojo/go/tests/validation_type_test.go b/mojo/go/tests/validation_type_test.go
index 9584729cab3bb720d6a3db2036a16100be551950..5e4c6a58d862d149f36ebc127758a482bb45d286 100644
--- a/mojo/go/tests/validation_type_test.go
+++ b/mojo/go/tests/validation_type_test.go
@@ -27,6 +27,7 @@ func init() {
func TestEnumType(t *testing.T) {
enumID := test.ID_validation_test_interfaces_BasicEnum__
shortName := "BasicEnum"
+ fullIdentifier := "mojo.test.BasicEnum"
labelMap := map[string]int32{
"A": 0,
"B": 1,
@@ -55,7 +56,13 @@ func TestEnumType(t *testing.T) {
t.Fatalf("Declaration Data's ShortName for %s is missing", enumID)
}
if *me.DeclData.ShortName != shortName {
- t.Fatalf("Declaration Data's ShortName for %s was not %s", enumID, shortName)
+ t.Fatalf("Declaration Data's ShortName for %s was %s, expected %s", enumID, *me.DeclData.ShortName, shortName)
+ }
+ if me.DeclData.FullIdentifier == nil {
+ t.Fatalf("Declaration Data's FullIdentifier for %s is missing", enumID)
+ }
+ if *me.DeclData.FullIdentifier != fullIdentifier {
+ t.Fatalf("Declaration Data's FullIdentifier for %s was %s, expected %s", enumID, *me.DeclData.FullIdentifier, fullIdentifier)
}
// Verify that the number of entries matches the expected ones.
@@ -91,6 +98,7 @@ func TestEnumType(t *testing.T) {
func TestStructType(t *testing.T) {
structID := test.ID_validation_test_interfaces_StructE__
shortName := "StructE"
+ fullIdentifier := "mojo.test.StructE"
fields := map[int]string{
0: "StructD",
1: "DataPipeConsumer",
@@ -116,7 +124,13 @@ func TestStructType(t *testing.T) {
t.Fatalf("Declaration Data's ShortName for %s is missing", structID)
}
if *ms.DeclData.ShortName != shortName {
- t.Fatalf("Declaration Data's ShortName for %s was not %s", structID, shortName)
+ t.Fatalf("Declaration Data's ShortName for %s was %s, expected %s", structID, *ms.DeclData.ShortName, shortName)
+ }
+ if ms.DeclData.FullIdentifier == nil {
+ t.Fatalf("Declaration Data's FullIdentifier for %s is missing", structID)
+ }
+ if *ms.DeclData.FullIdentifier != fullIdentifier {
+ t.Fatalf("Declaration Data's FullIdentifier for %s was %s, expected %s", structID, *ms.DeclData.FullIdentifier, fullIdentifier)
}
// Verify that the number of fields matches the expected ones.
@@ -172,6 +186,7 @@ func TestStructType(t *testing.T) {
func TestUnionType(t *testing.T) {
unionID := test.ID_validation_test_interfaces_UnionB__
shortName := "UnionB"
+ fullIdentifier := "mojo.test.UnionB"
fields := map[int]string{
0: "A",
1: "B",
@@ -199,7 +214,13 @@ func TestUnionType(t *testing.T) {
t.Fatalf("Declaration Data's ShortName for %s was missing", unionID)
}
if *mu.DeclData.ShortName != shortName {
- t.Fatalf("Declaration Data's ShortName for %s was not %s", unionID, shortName)
+ t.Fatalf("Declaration Data's ShortName for %s was %s, expected %s", unionID, *mu.DeclData.ShortName, shortName)
+ }
+ if mu.DeclData.FullIdentifier == nil {
+ t.Fatalf("Declaration Data's FullIdentifier for %s is missing", unionID)
+ }
+ if *mu.DeclData.FullIdentifier != fullIdentifier {
+ t.Fatalf("Declaration Data's FullIdentifier for %s was %s, expected %s", unionID, *mu.DeclData.FullIdentifier, fullIdentifier)
}
// Verify that the number of fields matches the expected ones.
@@ -250,6 +271,7 @@ func TestUnionType(t *testing.T) {
func TestStructWithImportType(t *testing.T) {
structID := test_unions.ID_test_unions_IncludingStruct__
shortName := "IncludingStruct"
+ fullIdentifier := "mojo.test.IncludingStruct"
fields := map[int]string{
0: "A",
}
@@ -274,7 +296,13 @@ func TestStructWithImportType(t *testing.T) {
t.Fatalf("Declaration Data's ShortName for %s is missing", structID)
}
if *ms.DeclData.ShortName != shortName {
- t.Fatalf("Declaration Data's ShortName for %s was not %s", structID, shortName)
+ t.Fatalf("Declaration Data's ShortName for %s was %s, expected %s", structID, *ms.DeclData.ShortName, shortName)
+ }
+ if ms.DeclData.FullIdentifier == nil {
+ t.Fatalf("Declaration Data's FullIdentifier for %s is missing", structID)
+ }
+ if *ms.DeclData.FullIdentifier != fullIdentifier {
+ t.Fatalf("Declaration Data's FullIdentifier for %s was %s, expected %s", structID, *ms.DeclData.FullIdentifier, fullIdentifier)
}
// Verify that the number of fields matches the expected ones.
@@ -324,6 +352,7 @@ func TestInterfaceType(t *testing.T) {
interfaceID := test.ID_validation_test_interfaces_BoundsCheckTestInterface__
shortName := "BoundsCheckTestInterface"
+ fullIdentifier := "mojo.test.BoundsCheckTestInterface"
methodMap := map[uint32]string{
0: "Method0",
1: "Method1",
@@ -343,24 +372,24 @@ func TestInterfaceType(t *testing.T) {
// The UserDefinedTypeInterfaceType has a MojomInterface inside.
mi := udit.Value
- checkMojomInterface(t, mi, interfaceID, shortName, methodMap)
+ checkMojomInterface(t, mi, interfaceID, shortName, fullIdentifier, methodMap)
// Now, we must check the ServiceDescription(s) exposed by the autogenerated
// ServiceRequest and ServiceFactory.
var bcti_r test.BoundsCheckTestInterface_Request
- checkServiceDescription(t, bcti_r.ServiceDescription(), interfaceID, shortName, methodMap)
+ checkServiceDescription(t, bcti_r.ServiceDescription(), interfaceID, shortName, fullIdentifier, methodMap)
var bcti_sf test.BoundsCheckTestInterface_ServiceFactory
- checkServiceDescription(t, bcti_sf.ServiceDescription(), interfaceID, shortName, methodMap)
+ checkServiceDescription(t, bcti_sf.ServiceDescription(), interfaceID, shortName, fullIdentifier, methodMap)
}
-func checkServiceDescription(t *testing.T, sd service_describer.ServiceDescription, interfaceID string, shortName string, methodMap map[uint32]string) {
+func checkServiceDescription(t *testing.T, sd service_describer.ServiceDescription, interfaceID, shortName, fullIdentifier string, methodMap map[uint32]string) {
// Check out the top level interface. This must pass checkMojomInterface.
mi, err := sd.GetTopLevelInterface()
if err != nil {
t.Fatalf("Unexpected error %s", err)
}
- checkMojomInterface(t, mi, interfaceID, shortName, methodMap)
+ checkMojomInterface(t, mi, interfaceID, shortName, fullIdentifier, methodMap)
// Try out sd.GetTypeDefinition. Pass in the interfaceID to see if you can get it out.
udt, err := sd.GetTypeDefinition(interfaceID)
@@ -370,7 +399,7 @@ func checkServiceDescription(t *testing.T, sd service_describer.ServiceDescripti
if udtit, ok := udt.(*mojom_types.UserDefinedTypeInterfaceType); !ok {
t.Fatalf("This type should be a *UserDefinedTypeInterfaceType")
} else {
- checkMojomInterface(t, udtit.Value, interfaceID, shortName, methodMap)
+ checkMojomInterface(t, udtit.Value, interfaceID, shortName, fullIdentifier, methodMap)
}
// Look at all the type definitions. Reflect-wise, all data inside should match the imported Descriptor.
@@ -383,13 +412,19 @@ func checkServiceDescription(t *testing.T, sd service_describer.ServiceDescripti
}
}
-func checkMojomInterface(t *testing.T, mi mojom_types.MojomInterface, interfaceID string, shortName string, methodMap map[uint32]string) {
+func checkMojomInterface(t *testing.T, mi mojom_types.MojomInterface, interfaceID, shortName, fullIdentifier string, methodMap map[uint32]string) {
// Check that the generator produced the short name.
if mi.DeclData == nil || mi.DeclData.ShortName == nil {
t.Fatalf("Declaration Data's ShortName for %s was missing", interfaceID)
}
if *mi.DeclData.ShortName != shortName {
- t.Fatalf("Declaration Data's ShortName for %s was not %s", interfaceID, shortName)
+ t.Fatalf("Declaration Data's ShortName for %s was %s, expected %s", interfaceID, *mi.DeclData.ShortName, shortName)
+ }
+ if mi.DeclData.FullIdentifier == nil {
+ t.Fatalf("Declaration Data's FullIdentifier for %s was missing", fullIdentifier)
+ }
+ if *mi.DeclData.FullIdentifier != fullIdentifier {
+ t.Fatalf("Declaration Data's FullIdentifier for %s was %s, expcected %s", interfaceID, *mi.DeclData.FullIdentifier, fullIdentifier)
}
// Verify that the number of methods matches the expected ones.
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/go_templates/mojom_type_macros.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698