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

Side by Side Diff: mojo/dart/test/validation_test.dart

Issue 982673002: Dart: Removes need to call listen(). (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge and Format Created 5 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 | « mojo/dart/test/interface_test.dart ('k') | mojo/public/dart/src/application.dart » ('j') | 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 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:typed_data'; 8 import 'dart:typed_data';
9 import 'mojo:bindings'; 9 import 'mojo:bindings';
10 import 'mojo:builtin' as builtin; 10 import 'mojo:builtin' as builtin;
11 import 'mojo:core'; 11 import 'mojo:core';
12 12
13 import 'package:mojo/dart/testing/validation_test_input_parser.dart' as parser; 13 import 'package:mojo/dart/testing/validation_test_input_parser.dart' as parser;
14 import 'package:mojo/public/interfaces/bindings/tests/validation_test_interfaces .mojom.dart'; 14 import 'package:mojo/public/interfaces/bindings/tests/validation_test_interfaces .mojom.dart';
15 15
16 class ConformanceTestInterfaceImpl implements ConformanceTestInterface { 16 class ConformanceTestInterfaceImpl implements ConformanceTestInterface {
17 ConformanceTestInterfaceStub _stub; 17 ConformanceTestInterfaceStub _stub;
18 Completer _completer; 18 Completer _completer;
19 19
20 ConformanceTestInterfaceImpl(this._completer, 20 ConformanceTestInterfaceImpl(
21 MojoMessagePipeEndpoint endpoint) { 21 this._completer, MojoMessagePipeEndpoint endpoint) {
22 _stub = new ConformanceTestInterfaceStub.fromEndpoint(endpoint, impl: this); 22 _stub = new ConformanceTestInterfaceStub.fromEndpoint(endpoint, this);
23 } 23 }
24 24
25 void _complete() => _completer.complete(null); 25 void _complete() => _completer.complete(null);
26 26
27 method0(double param0) => _complete(); 27 method0(double param0) => _complete();
28 method1(StructA param0) => _complete(); 28 method1(StructA param0) => _complete();
29 method2(StructB param0, StructA param1) => _complete(); 29 method2(StructB param0, StructA param1) => _complete();
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();
(...skipping 12 matching lines...) Expand all
45 return parser.parse(input); 45 return parser.parse(input);
46 } 46 }
47 47
48 String expectedResult(String test) { 48 String expectedResult(String test) {
49 List<int> data = builtin.readSync("${test}.expected"); 49 List<int> data = builtin.readSync("${test}.expected");
50 return new Utf8Decoder().convert(data).trim(); 50 return new Utf8Decoder().convert(data).trim();
51 } 51 }
52 52
53 runTest(String name, parser.ValidationParseResult test, String expected) { 53 runTest(String name, parser.ValidationParseResult test, String expected) {
54 var handles = new List.generate( 54 var handles = new List.generate(
55 test.numHandles, 55 test.numHandles, (_) => new MojoSharedBuffer.create(10).handle);
56 (_) => new MojoSharedBuffer.create(10).handle);
57 var pipe = new MojoMessagePipe(); 56 var pipe = new MojoMessagePipe();
58 var completer = new Completer(); 57 var completer = new Completer();
59 var conformanceImpl; 58 var conformanceImpl;
60 59
61 runZoned(() { 60 runZoned(() {
62 conformanceImpl = 61 conformanceImpl =
63 new ConformanceTestInterfaceImpl(completer, pipe.endpoints[0]); 62 new ConformanceTestInterfaceImpl(completer, pipe.endpoints[0]);
64 }, onError: (e, stackTrace) { 63 }, onError: (e, stackTrace) {
65 assert(e is MojoCodecError); 64 assert(e is MojoCodecError);
66 // TODO(zra): Make the error messages conform? 65 // TODO(zra): Make the error messages conform?
(...skipping 10 matching lines...) Expand all
77 completer.future.then((_) { 76 completer.future.then((_) {
78 assert(expected == "PASS"); 77 assert(expected == "PASS");
79 conformanceImpl.close(); 78 conformanceImpl.close();
80 pipe.endpoints[0].handle.close(); 79 pipe.endpoints[0].handle.close();
81 handles.forEach((h) => h.close()); 80 handles.forEach((h) => h.close());
82 }); 81 });
83 } 82 }
84 83
85 // TODO(zra, yzshen): Some struct versioning tests (with "mthd11" in their 84 // TODO(zra, yzshen): Some struct versioning tests (with "mthd11" in their
86 // names) are skipped. 85 // names) are skipped.
87 Iterable<String> getTestFiles(String path, String prefix) => 86 Iterable<String> getTestFiles(String path, String prefix) => builtin
88 builtin.enumerateFiles( 87 .enumerateFiles(path)
89 path).where( 88 .where((s) =>
90 (s) => 89 s.startsWith(prefix) && s.endsWith(".data") && !s.contains("mthd11"))
91 s.startsWith(prefix) && 90 .map((s) => s.replaceFirst('.data', ''));
92 s.endsWith(".data") &&
93 !s.contains("mthd11")).map((s) => s.replaceFirst('.data', '' ));
94 91
95 main(List args) { 92 main(List args) {
96 int handle = args[0]; 93 int handle = args[0];
97 String path = args[1]; 94 String path = args[1];
98 95
99 // First test the parser. 96 // First test the parser.
100 parser.parserTests(); 97 parser.parserTests();
101 98
102 // Then run the conformance tests. 99 // Then run the conformance tests.
103 getTestFiles(path, "$path/conformance_").forEach((test) { 100 getTestFiles(path, "$path/conformance_").forEach((test) {
104 runTest(test, readAndParseTest(test), expectedResult(test)); 101 runTest(test, readAndParseTest(test), expectedResult(test));
105 }); 102 });
106 // TODO(zra): Add integration tests when they no longer rely on Client=. 103 // TODO(zra): Add integration tests when they no longer rely on Client=.
107 } 104 }
OLDNEW
« no previous file with comments | « mojo/dart/test/interface_test.dart ('k') | mojo/public/dart/src/application.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698