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

Side by Side Diff: mojo/dart/apptests/dart_apptests/lib/src/service_describer_apptests.dart

Issue 1964193002: Dart: Refactors Proxies (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address comments Created 4 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 library service_describer_apptests; 5 library service_describer_apptests;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:mojo_apptest/apptest.dart'; 9 import 'package:mojo_apptest/apptest.dart';
10 import 'package:mojo/application.dart'; 10 import 'package:mojo/application.dart';
11 import 'package:mojo/bindings.dart'; 11 import 'package:mojo/bindings.dart';
12 import 'package:mojo/core.dart'; 12 import 'package:mojo/core.dart';
13 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types; 13 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types;
14 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' 14 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart'
15 as service_describer; 15 as service_describer;
16 import 'package:_mojo_for_test_only/test/pingpong_service.mojom.dart' 16 import 'package:_mojo_for_test_only/test/pingpong_service.mojom.dart'
17 as pingpong_service; 17 as pingpong_service;
18 18
19 // Tests that demonstrate that a service describer is able to obtain the same 19 // Tests that demonstrate that a service describer is able to obtain the same
20 // mojom type information present in a service's service description. 20 // mojom type information present in a service's service description.
21 // If the descriptions match, it means that you can see what services are 21 // If the descriptions match, it means that you can see what services are
22 // described by a mojo application without importing any of their mojom files. 22 // described by a mojo application without importing any of their mojom files.
23 tests(Application application, String url) { 23 tests(Application application, String url) {
24 group('Service Describer Apptests', () { 24 group('Service Describer Apptests', () {
25 test('PingPong Service Verification', () async { 25 test('PingPong Service Verification', () async {
26 var serviceDescriberProxy = new service_describer.ServiceDescriberProxy. 26 var serviceDescriberProxy = new service_describer.ServiceDescriberProxy.
27 unbound(); 27 unbound();
28 serviceDescriberProxy.errorFuture.then((v) => 28 serviceDescriberProxy.ctrl.errorFuture.then((v) =>
29 fail('There was an error $v')); 29 fail('There was an error $v'));
30 application.connectToService("mojo:dart_pingpong", serviceDescriberProxy); 30 application.connectToService("mojo:dart_pingpong", serviceDescriberProxy);
31 31
32 var serviceDescriptionProxy = 32 var serviceDescriptionProxy =
33 new service_describer.ServiceDescriptionProxy.unbound(); 33 new service_describer.ServiceDescriptionProxy.unbound();
34 serviceDescriptionProxy.errorFuture.then( 34 serviceDescriptionProxy.ctrl.errorFuture.then(
35 (v) => fail('There was an error $v')); 35 (v) => fail('There was an error $v'));
36 36
37 serviceDescriberProxy.ptr.describeService( 37 serviceDescriberProxy.describeService(
38 "test::PingPongService", serviceDescriptionProxy); 38 "test::PingPongService", serviceDescriptionProxy);
39 39
40 // Compare the service description obtained by the service describer and 40 // Compare the service description obtained by the service describer and
41 // the expected description taken from the pingpong service import. 41 // the expected description taken from the pingpong service import.
42 var serviceDescription = serviceDescriptionProxy.ptr; 42 var serviceDescription = serviceDescriptionProxy;
43 var serviceDescription2 = pingpong_service.PingPongServiceStub. 43 var serviceDescription2 = pingpong_service.PingPongServiceStub.
44 serviceDescription; 44 serviceDescription;
45 45
46 Function identity = (v) => v; 46 Function identity = (v) => v;
47 47
48
49 // Top-level Mojom Interfaces must match. 48 // Top-level Mojom Interfaces must match.
50 mojom_types.MojomInterface interfaceA = 49 mojom_types.MojomInterface interfaceA =
51 (await serviceDescriptionProxy.responseOrError( 50 (await serviceDescriptionProxy.responseOrError(
52 serviceDescription.getTopLevelInterface())).mojomInterface; 51 serviceDescription.getTopLevelInterface())).mojomInterface;
53 52
54 mojom_types.MojomInterface interfaceB = serviceDescription2. 53 mojom_types.MojomInterface interfaceB = serviceDescription2.
55 getTopLevelInterface(identity); 54 getTopLevelInterface(identity);
56 _compare(interfaceA, interfaceB); 55 _compare(interfaceA, interfaceB);
57 56
58 // Get the type key for the type of the first parameter of the 57 // Get the type key for the type of the first parameter of the
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 expect(methodA.parameters.fields.length, 113 expect(methodA.parameters.fields.length,
115 equals(methodB.parameters.fields.length)); 114 equals(methodB.parameters.fields.length));
116 mojom_types.MojomStruct responseA = methodA.responseParams; 115 mojom_types.MojomStruct responseA = methodA.responseParams;
117 mojom_types.MojomStruct responseB = methodB.responseParams; 116 mojom_types.MojomStruct responseB = methodB.responseParams;
118 expect(responseA == null, equals(responseB == null)); 117 expect(responseA == null, equals(responseB == null));
119 if (responseA != null) { 118 if (responseA != null) {
120 expect(responseA.fields.length, equals(responseB.fields.length)); 119 expect(responseA.fields.length, equals(responseB.fields.length));
121 } 120 }
122 }); 121 });
123 } 122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698