Index: server/static/rpcexplorer/test/rpc-descriptor-util.html |
diff --git a/server/static/rpcexplorer/test/rpc-descriptor-util.html b/server/static/rpcexplorer/test/rpc-descriptor-util.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..71c9ae3cbd86438130738581d9c34c92cd887f6c |
--- /dev/null |
+++ b/server/static/rpcexplorer/test/rpc-descriptor-util.html |
@@ -0,0 +1,83 @@ |
+<!-- |
+ Copyright 2016 The Chromium Authors. All rights reserved. |
+ Use of this source code is governed by a BSD-style license that can be |
+ found in the LICENSE file. |
+ --> |
+ |
+<!doctype html> |
+<title>rpc-descriptor-util</title> |
+ |
+<script src="../../bower_components/web-component-tester/browser.js"></script> |
+<link rel="import" href="../rpc-descriptor-util.html"> |
+<link rel="import" href="descriptor.html"> |
+ |
+<script> |
+ suite('rpcExplorer.descUtil', function() { |
+ var util = rpcExplorer.descUtil; |
+ |
+ suite('resolve', function() { |
+ function testResolve(fullName, type, name) { |
+ test(fullName, function () { |
+ var result = util.resolve(discoveryDescriptor, fullName); |
+ expect(result).to.ok; |
+ expect(result.type).to.equal(type); |
+ expect(result.desc).to.ok; |
+ expect(result.desc.name).to.equal(name); |
+ }); |
+ } |
+ |
+ testResolve('discovery.Discovery', 'service', 'Discovery'); |
+ testResolve('discovery.Discovery.Describe', 'method', 'Describe'); |
+ testResolve( |
+ 'google.protobuf.FileDescriptorSet', |
+ 'messageType', |
+ 'FileDescriptorSet'); |
+ testResolve( |
+ 'google.protobuf.FileDescriptorSet.file', |
+ 'field', |
+ 'file'); |
+ testResolve( |
+ 'google.protobuf.FieldDescriptorProto.Type', |
+ 'enumType', |
+ 'Type'); |
+ testResolve( |
+ 'google.protobuf.FieldOptions.JSType.JS_NORMAL', |
+ 'enumValue', |
+ 'JS_NORMAL'); |
+ }); |
+ |
+ suite('annotate', function() { |
+ var descriptor = JSON.parse(JSON.stringify(discoveryDescriptor)); |
+ util.annotateSet(descriptor); |
+ |
+ function testAnnotate(name, comment) { |
+ test(name, function() { |
+ var desc = util.resolve(descriptor, name).desc; |
+ expect(desc).to.be.ok; |
+ expect(desc.source_code_info).to.be.ok; |
+ expect(desc.source_code_info.leading_comments).to.equal(comment); |
+ }); |
+ } |
+ |
+ testAnnotate( |
+ 'discovery.Discovery', |
+ ' Describes services.\n'); |
+ testAnnotate( |
+ 'discovery.Discovery.Describe', |
+ (' Returns a list of services and a\n' + |
+ ' descriptor.FileDescriptorSet that covers them all.\n')); |
+ testAnnotate( |
+ 'discovery.Void', |
+ ' Void is an empty message.\n'); |
+ testAnnotate( |
+ 'discovery.DescribeResponse.services', |
+ ' Services are service names provided by a server.\n'); |
+ testAnnotate( |
+ 'google.protobuf.FileOptions.OptimizeMode', |
+ ' Generated classes can be optimized for speed or code size.\n'); |
+ testAnnotate( |
+ 'google.protobuf.FieldOptions.JSType.JS_NORMAL', |
+ ' Use the default type.\n'); |
+ }); |
+ }); |
+</script> |