| 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;
|
| + }
|
| });
|
|
|