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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
8 import 'dart:mojo.builtin' as builtin; | 8 import 'dart:mojo.builtin' as builtin; |
9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 method3(List<bool> param0) => _complete(); | 30 method3(List<bool> param0) => _complete(); |
31 method4(StructC param0, List<int> param1) => _complete(); | 31 method4(StructC param0, List<int> param1) => _complete(); |
32 method5(StructE param0, MojoDataPipeProducer param1) => _complete(); | 32 method5(StructE param0, MojoDataPipeProducer param1) => _complete(); |
33 method6(List<List<int>> param0) => _complete(); | 33 method6(List<List<int>> param0) => _complete(); |
34 method7(StructF param0, List<List<int>> param1) => _complete(); | 34 method7(StructF param0, List<List<int>> param1) => _complete(); |
35 method8(List<List<String>> param0) => _complete(); | 35 method8(List<List<String>> param0) => _complete(); |
36 method9(List<List<MojoHandle>> param0) => _complete(); | 36 method9(List<List<MojoHandle>> param0) => _complete(); |
37 method10(Map<String, int> param0) => _complete(); | 37 method10(Map<String, int> param0) => _complete(); |
38 method11(StructG param0) => _complete(); | 38 method11(StructG param0) => _complete(); |
39 | 39 |
40 Future close({bool nodefer: false}) => _stub.close(nodefer: nodefer); | 40 Future close({bool immediate: false}) => _stub.close(immediate: immediate); |
41 } | 41 } |
42 | 42 |
43 parser.ValidationParseResult readAndParseTest(String test) { | 43 parser.ValidationParseResult readAndParseTest(String test) { |
44 List<int> data = builtin.readSync("${test}.data"); | 44 List<int> data = builtin.readSync("${test}.data"); |
45 String input = new Utf8Decoder().convert(data).trim(); | 45 String input = new Utf8Decoder().convert(data).trim(); |
46 return parser.parse(input); | 46 return parser.parse(input); |
47 } | 47 } |
48 | 48 |
49 String expectedResult(String test) { | 49 String expectedResult(String test) { |
50 List<int> data = builtin.readSync("${test}.expected"); | 50 List<int> data = builtin.readSync("${test}.expected"); |
51 return new Utf8Decoder().convert(data).trim(); | 51 return new Utf8Decoder().convert(data).trim(); |
52 } | 52 } |
53 | 53 |
54 runTest(String name, parser.ValidationParseResult test, String expected) { | 54 runTest(String name, parser.ValidationParseResult test, String expected) { |
55 var handles = new List.generate( | 55 var handles = new List.generate( |
56 test.numHandles, (_) => new MojoSharedBuffer.create(10).handle); | 56 test.numHandles, (_) => new MojoSharedBuffer.create(10).handle); |
57 var pipe = new MojoMessagePipe(); | 57 var pipe = new MojoMessagePipe(); |
58 var completer = new Completer(); | 58 var completer = new Completer(); |
59 var conformanceImpl; | 59 var conformanceImpl; |
60 | 60 |
61 runZoned(() { | 61 runZoned(() { |
62 conformanceImpl = | 62 conformanceImpl = |
63 new ConformanceTestInterfaceImpl(completer, pipe.endpoints[0]); | 63 new ConformanceTestInterfaceImpl(completer, pipe.endpoints[0]); |
64 }, onError: (e, stackTrace) { | 64 }, onError: (e, stackTrace) { |
65 assert(e is MojoCodecError); | 65 assert(e is MojoCodecError); |
66 // TODO(zra): Make the error messages conform? | 66 // TODO(zra): Make the error messages conform? |
67 // assert(e == expected); | 67 // assert(e == expected); |
68 conformanceImpl.close(nodefer: true); | 68 conformanceImpl.close(immediate: true); |
69 pipe.endpoints[0].handle.close(); | 69 pipe.endpoints[0].handle.close(); |
70 handles.forEach((h) => h.close()); | 70 handles.forEach((h) => h.close()); |
71 }); | 71 }); |
72 | 72 |
73 var length = (test.data == null) ? 0 : test.data.lengthInBytes; | 73 var length = (test.data == null) ? 0 : test.data.lengthInBytes; |
74 var r = pipe.endpoints[1].write(test.data, length, handles); | 74 var r = pipe.endpoints[1].write(test.data, length, handles); |
75 assert(r.isOk); | 75 assert(r.isOk); |
76 | 76 |
77 completer.future.then((_) { | 77 completer.future.then((_) { |
78 assert(expected == "PASS"); | 78 assert(expected == "PASS"); |
(...skipping 14 matching lines...) Expand all Loading... |
93 | 93 |
94 // First test the parser. | 94 // First test the parser. |
95 parser.parserTests(); | 95 parser.parserTests(); |
96 | 96 |
97 // Then run the conformance tests. | 97 // Then run the conformance tests. |
98 getTestFiles(path, "$path/conformance_").forEach((test) { | 98 getTestFiles(path, "$path/conformance_").forEach((test) { |
99 runTest(test, readAndParseTest(test), expectedResult(test)); | 99 runTest(test, readAndParseTest(test), expectedResult(test)); |
100 }); | 100 }); |
101 // TODO(zra): Add integration tests when they no longer rely on Client=. | 101 // TODO(zra): Add integration tests when they no longer rely on Client=. |
102 } | 102 } |
OLD | NEW |