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

Unified Diff: mojo/public/js/bindings/struct_unittests.js

Issue 605443002: The default value for NullableString should be null (was "") (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing types, renamed test functions and struct types Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/js/bindings/struct_unittests.js
diff --git a/mojo/public/js/bindings/struct_unittests.js b/mojo/public/js/bindings/struct_unittests.js
index d4a568ccf41f8bde7995025345535ed3d791a2fa..b9948a93d6e41b065d1f1e5c41976f82109c4b6b 100644
--- a/mojo/public/js/bindings/struct_unittests.js
+++ b/mojo/public/js/bindings/struct_unittests.js
@@ -26,8 +26,7 @@ define([
expect(new testStructs.RectPair({second: r}).first).toBeNull();
var nr = new testStructs.NamedRegion();
- // TODO(hansmuller): nr.name should be null, see crbug.com/417039.
- expect(nr.name).toBe("");
+ expect(nr.name).toBeNull();
expect(nr.rects).toBeNull();
expect(nr).toEqual(new testStructs.NamedRegion({}));
@@ -42,6 +41,39 @@ define([
expect(e).toEqual(new testStructs.EmptyStruct({foo:123}));
}
+ function testNoDefaultFieldValues() {
+ var s = new testStructs.NoDefaultFieldValues();
+ expect(s.f0).toEqual(false);
+
+ // f1 - f10, number type fields
+ for (var i = 1; i <= 10; i++)
+ expect(s["f" + i]).toEqual(0);
+
+ // f11,12 strings, f13-22 handles, f23-f26 arrays, f27,28 structs
+ for (var i = 11; i <= 28; i++)
+ expect(s["f" + i]).toBeNull();
+ }
+
+ function testDefaultFieldValues() {
+ var s = new testStructs.DefaultFieldValues();
+ expect(s.f0).toEqual(true);
+
+ // f1 - f12, number type fields
+ for (var i = 1; i <= 12; i++)
+ expect(s["f" + i]).toEqual(100);
+
+ // f13,14 "foo"
+ for (var i = 13; i <= 14; i++)
+ expect(s["f" + i]).toEqual("foo");
+
+ // f15,16 a default instance of Rect
+ var r = new rect.Rect();
+ expect(s.f15).toEqual(r);
+ expect(s.f16).toEqual(r);
+ }
+
testConstructors();
+ testNoDefaultFieldValues();
+ testDefaultFieldValues();
this.result = "PASS";
});
« no previous file with comments | « mojo/public/js/bindings/codec_unittests.js ('k') | mojo/public/tools/bindings/generators/mojom_cpp_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698