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

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

Issue 1677343002: mojom_types.mojom: Changes the name |interface_name| to |service_name| in struct MojomInterface. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Responds to code review. Created 4 years, 10 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/serialization/serialization.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 "fmt" 8 "fmt"
9 "mojo/public/go/bindings" 9 "mojo/public/go/bindings"
10 "mojom/mojom_parser/generated/mojom_files" 10 "mojom/mojom_parser/generated/mojom_files"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 438
439 test.addTestCase("test", contents) 439 test.addTestCase("test", contents)
440 440
441 // DeclaredMojomObjects 441 // DeclaredMojomObjects
442 test.expectedFile().DeclaredMojomObjects.Interfaces = &[]string{ "TYPE_KEY:test.EchoService"} 442 test.expectedFile().DeclaredMojomObjects.Interfaces = &[]string{ "TYPE_KEY:test.EchoService"}
443 443
444 // ResolvedTypes 444 // ResolvedTypes
445 445
446 // interface EchoService 446 // interface EchoService
447 test.expectedGraph().ResolvedTypes["TYPE_KEY:test.EchoService"] = &mojom_types.UserDefinedTypeInterfaceType{mojom_types.MojomInterface{ 447 test.expectedGraph().ResolvedTypes["TYPE_KEY:test.EchoService"] = &mojom_types.UserDefinedTypeInterfaceType{mojom_types.MojomInterface{
448 » » » DeclData: test.newDeclData("EchoService", "test.Ech oService"), 448 » » » DeclData: test.newDeclData("EchoService", "test.EchoServ ice"),
449 » » » InterfaceName: "EchoService",
450 Methods: map[uint32]mojom_types.MojomMethod{ 449 Methods: map[uint32]mojom_types.MojomMethod{
451 0: mojom_types.MojomMethod{ 450 0: mojom_types.MojomMethod{
452 DeclData: test.newDeclData("EchoString", ""), 451 DeclData: test.newDeclData("EchoString", ""),
453 Parameters: mojom_types.MojomStruct{ 452 Parameters: mojom_types.MojomStruct{
454 DeclData: test.newDeclData("Echo String-request", ""), 453 DeclData: test.newDeclData("Echo String-request", ""),
455 Fields: []mojom_types.StructFiel d{ 454 Fields: []mojom_types.StructFiel d{
456 mojom_types.StructField{ 455 mojom_types.StructField{
457 DeclData: test.n ewDeclData("value", ""), 456 DeclData: test.n ewDeclData("value", ""),
458 Type: &mojom _types.TypeStringType{mojom_types.StringType{true}}, 457 Type: &mojom _types.TypeStringType{mojom_types.StringType{true}},
459 }, 458 },
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 }, 494 },
496 Ordinal: 1, 495 Ordinal: 1,
497 }, 496 },
498 }, 497 },
499 }} 498 }}
500 499
501 test.endTestCase() 500 test.endTestCase()
502 } 501 }
503 502
504 //////////////////////////////////////////////////////////// 503 ////////////////////////////////////////////////////////////
504 // Test Case: Use of the ServiceName attribute
505 ////////////////////////////////////////////////////////////
506 {
507
508 contents := `
509 module test;
510
511 [ServiceName = "my.test.EchoService"]
512 interface EchoService {
513 EchoString(string? value) => (string? value);
514 };`
515
516 test.addTestCase("test", contents)
517
518 // DeclaredMojomObjects
519 test.expectedFile().DeclaredMojomObjects.Interfaces = &[]string{ "TYPE_KEY:test.EchoService"}
520
521 // ResolvedTypes
522
523 // interface EchoService
524 test.expectedGraph().ResolvedTypes["TYPE_KEY:test.EchoService"] = &mojom_types.UserDefinedTypeInterfaceType{mojom_types.MojomInterface{
525 DeclData: test.newDeclDataA("EchoService", "test.Echo Service", &[]mojom_types.Attribute{{"ServiceName", &mojom_types.LiteralValueStri ngValue{"my.test.EchoService"}}}),
526 ServiceName: stringPointer("my.test.EchoService"),
527 Methods: map[uint32]mojom_types.MojomMethod{
528 0: mojom_types.MojomMethod{
529 DeclData: test.newDeclData("EchoString", ""),
530 Parameters: mojom_types.MojomStruct{
531 DeclData: test.newDeclData("Echo String-request", ""),
532 Fields: []mojom_types.StructFiel d{
533 mojom_types.StructField{
534 DeclData: test.n ewDeclData("value", ""),
535 Type: &mojom _types.TypeStringType{mojom_types.StringType{true}},
536 },
537 },
538 },
539 ResponseParams: &mojom_types.MojomStruct {
540 DeclData: test.newDeclData("Echo String-response", ""),
541 Fields: []mojom_types.StructFiel d{
542 mojom_types.StructField{
543 DeclData: test.n ewDeclData("value", ""),
544 Type: &mojom _types.TypeStringType{mojom_types.StringType{true}},
545 },
546 },
547 },
548 },
549 },
550 }}
551
552 test.endTestCase()
553 }
554
555 ////////////////////////////////////////////////////////////
505 // Test Case: Integer constants 556 // Test Case: Integer constants
506 //////////////////////////////////////////////////////////// 557 ////////////////////////////////////////////////////////////
507 { 558 {
508 559
509 contents := ` 560 contents := `
510 const uint8 xu8 = 255; 561 const uint8 xu8 = 255;
511 const int8 x8 = -127; 562 const int8 x8 = -127;
512 const uint16 xu16 = 0xFFFF; 563 const uint16 xu16 = 0xFFFF;
513 const int16 x16 = -0x7FFF; 564 const int16 x16 = -0x7FFF;
514 const uint32 xu32 = 4294967295; 565 const uint32 xu32 = 4294967295;
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 } 1200 }
1150 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na ctual=\n*****\n%q\n*****\n"+ 1201 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na ctual=\n*****\n%q\n*****\n"+
1151 "match failed at position %d: expected=\n*****\n %q\n******\nactual=\n*****\n%q\n******\n", 1202 "match failed at position %d: expected=\n*****\n %q\n******\nactual=\n*****\n%q\n******\n",
1152 expectedString, actualString, diffPos, mismatchE xpected, mismatchActual) 1203 expectedString, actualString, diffPos, mismatchE xpected, mismatchActual)
1153 } else { 1204 } else {
1154 return fmt.Errorf("expected != actual but the two printe d equal.") 1205 return fmt.Errorf("expected != actual but the two printe d equal.")
1155 } 1206 }
1156 } 1207 }
1157 return nil 1208 return nil
1158 } 1209 }
OLDNEW
« no previous file with comments | « mojom/mojom_parser/serialization/serialization.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698