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

Unified Diff: mojo/edk/js/tests/binding_tests.js

Issue 2578333002: Mojo JS bindings: BindingSet support. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | mojo/edk/js/tests/interface_ptr_tests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/js/tests/binding_tests.js
diff --git a/mojo/edk/js/tests/binding_tests.js b/mojo/edk/js/tests/binding_tests.js
index 3b90cf7b8cea03b7f90d7ddf9d499bbf7c6e62eb..7bf9a89e3c405c41eb4517708f1747d806c1533d 100644
--- a/mojo/edk/js/tests/binding_tests.js
+++ b/mojo/edk/js/tests/binding_tests.js
@@ -17,6 +17,7 @@ define([
.then(testReusable)
.then(testConnectionError)
.then(testUnbind)
+ .then(testBindingSet)
.then(function() {
this.result = "PASS";
gc.collectGarbage(); // should not crash
@@ -118,4 +119,41 @@ define([
return promise;
}
+
+ function testBindingSet() {
+ var calc1 = new math.CalculatorPtr();
+ var calc2 = new math.CalculatorPtr();
+ var calcImpl = new CalculatorImpl();
+
+ var bindingSet = new bindings.BindingSet(math.Calculator);
+ expect(bindingSet.isEmpty()).toBeTruthy();
+ bindingSet.addBinding(calcImpl, bindings.makeRequest(calc1));
+ bindingSet.addBinding(calcImpl, bindings.makeRequest(calc2));
+ expect(bindingSet.isEmpty()).toBeFalsy();
+
+ var promise = calc1.add(3).then(function(response) {
+ expect(response.value).toBe(3);
+ return calc2.add(4);
+ }).then(function(response) {
+ expect(response.value).toBe(7);
+
+ var promiseOfConnectionError = new Promise(function(resolve, reject) {
+ bindingSet.setConnectionErrorHandler(function() {
+ resolve();
+ });
+ });
+ calc1.ptr.reset();
+ return promiseOfConnectionError;
+ }).then(function() {
+ return calc2.add(5);
+ }).then(function(response) {
+ expect(response.value).toBe(12);
+
+ bindingSet.closeAllBindings();
+ expect(bindingSet.isEmpty()).toBeTruthy();
+ return Promise.resolve();
+ });
+
+ return promise;
+ }
});
« no previous file with comments | « no previous file | mojo/edk/js/tests/interface_ptr_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698