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

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 test fields with type double 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..2583a86da16a7f55c522c4251209e48b189b44ed 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 testDefaultFieldValues() {
+ var s = new testStructs.DefaultFieldValues();
+ expect(s.f0).toEqual(false);
+
+ // f1 - f9, number type fields
+ for (var i = 1; i <= 8; i++)
+ expect(s["f" + i]).toEqual(0);
+
+ // f10,11 strings, f12-17 handles, f18-f21 arrays, f22,23 structs
+ for (var i = 10; i <= 23; i++)
+ expect(s["f" + i]).toBeNull();
+ }
+
+ function testExplicitFieldValues() {
yzshen1 2014/09/24 22:49:25 nit: because we usually refer to "explicit field v
hansmuller 2014/09/24 23:33:11 OK. I've called the two structs and test functions
+ var s = new testStructs.ExplicitFieldValues();
+ expect(s.f0).toEqual(true);
+
+ // f1 - f11, number type fields
+ for (var i = 1; i <= 11; i++)
+ expect(s["f" + i]).toEqual(100);
+
+ // f12,13 "foo"
+ for (var i = 12; i <= 13; i++)
+ expect(s["f" + i]).toEqual("foo");
+
+ // f14,15 a default instance of Rect
+ var r = new rect.Rect();
+ expect(s.f14).toEqual(r);
+ expect(s.f15).toEqual(r);
+ }
+
testConstructors();
+ testDefaultFieldValues();
+ testExplicitFieldValues();
this.result = "PASS";
});

Powered by Google App Engine
This is Rietveld 408576698