OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "gin/test/expect", | 6 "gin/test/expect", |
7 "mojo/public/interfaces/bindings/tests/rect.mojom", | 7 "mojo/public/interfaces/bindings/tests/rect.mojom", |
8 "mojo/public/interfaces/bindings/tests/test_structs.mojom" | 8 "mojo/public/interfaces/bindings/tests/test_structs.mojom" |
9 ], function(expect, | 9 ], function(expect, |
10 rect, | 10 rect, |
11 testStructs) { | 11 testStructs) { |
12 | 12 |
13 function testConstructors() { | 13 function testConstructors() { |
14 var r = new rect.Rect(); | 14 var r = new rect.Rect(); |
15 expect(r).toEqual(new rect.Rect({x:0, y:0, width:0, height:0})); | 15 expect(r).toEqual(new rect.Rect({x:0, y:0, width:0, height:0})); |
16 expect(r).toEqual(new rect.Rect({foo:100, bar:200})); | 16 expect(r).toEqual(new rect.Rect({foo:100, bar:200})); |
17 | 17 |
18 r.x = 10; | 18 r.x = 10; |
19 r.y = 20; | 19 r.y = 20; |
20 r.width = 30; | 20 r.width = 30; |
21 r.height = 40; | 21 r.height = 40; |
22 var rp = new testStructs.RectPair({first: r, second: r}); | 22 var rp = new testStructs.RectPair({first: r, second: r}); |
23 expect(rp.first).toEqual(r); | 23 expect(rp.first).toEqual(r); |
24 expect(rp.second).toEqual(r); | 24 expect(rp.second).toEqual(r); |
25 | 25 |
26 expect(new testStructs.RectPair({second: r}).first).toBeNull(); | 26 expect(new testStructs.RectPair({second: r}).first).toBeNull(); |
27 | 27 |
28 var nr = new testStructs.NamedRegion(); | 28 var nr = new testStructs.NamedRegion(); |
29 // TODO(hansmuller): nr.name should be null, see crbug.com/417039. | 29 expect(nr.name).toBeNull(); |
30 expect(nr.name).toBe(""); | |
31 expect(nr.rects).toBeNull(); | 30 expect(nr.rects).toBeNull(); |
32 expect(nr).toEqual(new testStructs.NamedRegion({})); | 31 expect(nr).toEqual(new testStructs.NamedRegion({})); |
33 | 32 |
34 nr.name = "foo"; | 33 nr.name = "foo"; |
35 nr.rects = [r, r, r]; | 34 nr.rects = [r, r, r]; |
36 expect(nr).toEqual(new testStructs.NamedRegion({ | 35 expect(nr).toEqual(new testStructs.NamedRegion({ |
37 name: "foo", | 36 name: "foo", |
38 rects: [r, r, r], | 37 rects: [r, r, r], |
39 })); | 38 })); |
40 | 39 |
41 var e = new testStructs.EmptyStruct(); | 40 var e = new testStructs.EmptyStruct(); |
42 expect(e).toEqual(new testStructs.EmptyStruct({foo:123})); | 41 expect(e).toEqual(new testStructs.EmptyStruct({foo:123})); |
43 } | 42 } |
44 | 43 |
45 testConstructors(); | 44 testConstructors(); |
46 this.result = "PASS"; | 45 this.result = "PASS"; |
47 }); | 46 }); |
OLD | NEW |