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

Side by Side Diff: mojo/public/js/bindings/struct_unittests.js

Issue 595063002: Use a JS dictionary to initialize a the fields in a Mojo struct (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed console module test dependency Created 6 years, 2 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 | « no previous file | mojo/public/js/bindings/tests/run_js_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 define([
6 "gin/test/expect",
7 "mojo/public/interfaces/bindings/tests/rect.mojom",
8 "mojo/public/interfaces/bindings/tests/test_structs.mojom"
9 ], function(expect,
10 rect,
11 testStructs) {
12
13 function testConstructors() {
14 var r = new rect.Rect();
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}));
17
18 r.x = 10;
19 r.y = 20;
20 r.width = 30;
21 r.height = 40;
22 var rp = new testStructs.RectPair({first: r, second: r});
23 expect(rp.first).toEqual(r);
24 expect(rp.second).toEqual(r);
25
26 expect(new testStructs.RectPair({second: r}).first).toBeNull();
27
28 var nr = new testStructs.NamedRegion();
29 // TODO(hansmuller): nr.name should be null, see crbug.com/417039.
30 expect(nr.name).toBe("");
31 expect(nr.rects).toBeNull();
32 expect(nr).toEqual(new testStructs.NamedRegion({}));
33
34 nr.name = "foo";
35 nr.rects = [r, r, r];
36 expect(nr).toEqual(new testStructs.NamedRegion({
37 name: "foo",
38 rects: [r, r, r],
39 }));
40
41 var e = new testStructs.EmptyStruct();
42 expect(e).toEqual(new testStructs.EmptyStruct({foo:123}));
43 }
44
45 testConstructors();
46 this.result = "PASS";
47 });
OLDNEW
« no previous file with comments | « no previous file | mojo/public/js/bindings/tests/run_js_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698