| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 define([ | 5 define([ |
| 6 "console", | 6 "console", |
| 7 "mojo/apps/js/test/hexdump", | 7 "mojo/apps/js/test/hexdump", |
| 8 "gin/test/expect", | 8 "gin/test/expect", |
| 9 "mojo/public/interfaces/bindings/tests/sample_service.mojom", | 9 "mojo/public/interfaces/bindings/tests/sample_service.mojom", |
| 10 "mojo/public/interfaces/bindings/tests/sample_import.mojom", | 10 "mojo/public/interfaces/bindings/tests/sample_import.mojom", |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Check that values are set to the defaults if we don't override them. | 90 // Check that values are set to the defaults if we don't override them. |
| 91 function checkDefaultValues() { | 91 function checkDefaultValues() { |
| 92 var bar = new sample.Bar(); | 92 var bar = new sample.Bar(); |
| 93 expect(bar.alpha).toBe(255); | 93 expect(bar.alpha).toBe(255); |
| 94 | 94 |
| 95 var foo = new sample.Foo(); | 95 var foo = new sample.Foo(); |
| 96 expect(foo.name).toBe("Fooby"); | 96 expect(foo.name).toBe("Fooby"); |
| 97 expect(foo.a).toBeTruthy(); | 97 expect(foo.a).toBeTruthy(); |
| 98 | 98 // TODO(vtl): crbug.com/375845 |
| 99 expect(foo.data.length).toBe(3); | 99 // expect(foo.data).toBeNull(); |
| 100 expect(foo.data[0]).toBe(1); | |
| 101 expect(foo.data[1]).toBe(2); | |
| 102 expect(foo.data[2]).toBe(3); | |
| 103 | |
| 104 var inner = new sample.DefaultsTestInner(); | |
| 105 expect(inner.names.length).toBe(1); | |
| 106 expect(inner.names[0]).toBe("Jim"); | |
| 107 expect(inner.height).toBe(6*12); | |
| 108 | 100 |
| 109 var full = new sample.DefaultsTest(); | 101 var full = new sample.DefaultsTest(); |
| 110 expect(full.people.length).toBe(1); | 102 expect(full.a0).toBe(-12); |
| 111 expect(full.people[0].age).toBe(32); | 103 expect(full.a1).toBe(12); |
| 112 expect(full.people[0].names.length).toBe(2); | 104 expect(full.a2).toBe(1234); |
| 113 expect(full.people[0].names[0]).toBe("Bob"); | 105 expect(full.a3).toBe(34567); |
| 114 expect(full.people[0].names[1]).toBe("Bobby"); | 106 expect(full.a4).toBe(123456); |
| 115 expect(full.people[0].height).toBe(6*12); | 107 // TODO(vtl): crbug.com/375522 |
| 116 | 108 // expect(full.a5).toBe(3456789012); |
| 117 expect(full.point.x).toBe(7); | 109 expect(full.a6).toBe(111111111111); |
| 118 expect(full.point.y).toBe(15); | 110 // TODO(vtl): crbug.com/375522 (Also, can we get exact values for large |
| 119 | 111 // int64/uint64's in JS?) |
| 120 expect(full.shape_masks.length).toBe(1); | 112 // expect(full.a7).toBe(9999999999999999999); |
| 121 expect(full.shape_masks[0]).toBe(1 << imported.Shape.SHAPE_RECTANGLE); | 113 expect(full.a8).toBe(0x12345); |
| 122 | 114 expect(full.a9).toBe(-0x12345); |
| 123 expect(full.thing.shape).toBe(imported.Shape.SHAPE_CIRCLE); | 115 // TODO(vtl): crbug.com/375829 |
| 124 expect(full.thing.color).toBe(imported2.Color.COLOR_BLACK); | 116 // expect(full.a10).toBe(8); |
| 117 // expect(full.a11).toBe(-8); |
| 118 expect(full.a12).toBe(1234); |
| 119 expect(full.a13).toBe(true); |
| 120 expect(full.a14).toBe(false); |
| 121 expect(full.a15).toBe(123.25); |
| 122 expect(full.a16).toBe(1234567890.123); |
| 123 expect(full.a17).toBe(1E10); |
| 124 expect(full.a18).toBe(-1.2E+20); |
| 125 expect(full.a19).toBe(1.23E-20); |
| 126 expect(full.a20).toBeNull(); |
| 127 // TODO(vtl): crbug.com/375845 |
| 128 // expect(full.a21).toBeNull(); |
| 129 // expect(full.a22).toBeNull(); |
| 125 } | 130 } |
| 126 | 131 |
| 127 function ServiceImpl() { | 132 function ServiceImpl() { |
| 128 } | 133 } |
| 129 | 134 |
| 130 ServiceImpl.prototype = Object.create(sample.ServiceStub.prototype); | 135 ServiceImpl.prototype = Object.create(sample.ServiceStub.prototype); |
| 131 | 136 |
| 132 ServiceImpl.prototype.frobinate = function(foo, baz, port) { | 137 ServiceImpl.prototype.frobinate = function(foo, baz, port) { |
| 133 checkFoo(foo); | 138 checkFoo(foo); |
| 134 expect(baz).toBe(sample.ServiceStub.BazOptions.BAZ_EXTRA); | 139 expect(baz).toBe(sample.ServiceStub.BazOptions.BAZ_EXTRA); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 153 var serviceProxy = new sample.ServiceProxy(receiver); | 158 var serviceProxy = new sample.ServiceProxy(receiver); |
| 154 | 159 |
| 155 checkDefaultValues(); | 160 checkDefaultValues(); |
| 156 | 161 |
| 157 var foo = makeFoo(); | 162 var foo = makeFoo(); |
| 158 checkFoo(foo); | 163 checkFoo(foo); |
| 159 | 164 |
| 160 var port = 10; | 165 var port = 10; |
| 161 serviceProxy.frobinate(foo, sample.ServiceProxy.BazOptions.BAZ_EXTRA, port); | 166 serviceProxy.frobinate(foo, sample.ServiceProxy.BazOptions.BAZ_EXTRA, port); |
| 162 }); | 167 }); |
| OLD | NEW |