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

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

Issue 2645873003: Cleanup mojo-js tests. (Closed)
Patch Set: more deps fixes Created 3 years, 11 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
« no previous file with comments | « mojo/edk/js/tests/connection_tests.js ('k') | mojo/edk/js/tests/js_to_cpp_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/js/tests/interface_ptr_tests.js
diff --git a/mojo/edk/js/tests/interface_ptr_tests.js b/mojo/edk/js/tests/interface_ptr_tests.js
deleted file mode 100644
index 22e0d6f15f3db3e3d1291050cbb8b9bb8adc028a..0000000000000000000000000000000000000000
--- a/mojo/edk/js/tests/interface_ptr_tests.js
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-define([
- "gin/test/expect",
- "mojo/public/js/bindings",
- "mojo/public/js/core",
- "mojo/public/interfaces/bindings/tests/math_calculator.mojom",
- "mojo/public/js/threading",
- "gc",
-], function(expect,
- bindings,
- core,
- math,
- threading,
- gc) {
- testIsBound()
- .then(testEndToEnd)
- .then(testReusable)
- .then(testConnectionError)
- .then(testPassInterface)
- .then(testBindRawHandle)
- .then(function() {
- this.result = "PASS";
- gc.collectGarbage(); // should not crash
- threading.quit();
- }.bind(this)).catch(function(e) {
- this.result = "FAIL: " + (e.stack || e);
- threading.quit();
- }.bind(this));
-
- function CalculatorImpl() {
- this.total = 0;
- }
-
- CalculatorImpl.prototype.clear = function() {
- this.total = 0;
- return Promise.resolve({value: this.total});
- };
-
- CalculatorImpl.prototype.add = function(value) {
- this.total += value;
- return Promise.resolve({value: this.total});
- };
-
- CalculatorImpl.prototype.multiply = function(value) {
- this.total *= value;
- return Promise.resolve({value: this.total});
- };
-
- function testIsBound() {
- var calc = new math.CalculatorPtr();
- expect(calc.ptr.isBound()).toBeFalsy();
-
- var request = bindings.makeRequest(calc);
- expect(calc.ptr.isBound()).toBeTruthy();
-
- calc.ptr.reset();
- expect(calc.ptr.isBound()).toBeFalsy();
-
- return Promise.resolve();
- }
-
- function testEndToEnd() {
- var calc = new math.CalculatorPtr();
- var calcBinding = new bindings.Binding(math.Calculator,
- new CalculatorImpl(),
- bindings.makeRequest(calc));
-
- var promise = calc.add(2).then(function(response) {
- expect(response.value).toBe(2);
- return calc.multiply(5);
- }).then(function(response) {
- expect(response.value).toBe(10);
- return calc.clear();
- }).then(function(response) {
- expect(response.value).toBe(0);
- return Promise.resolve();
- });
-
- return promise;
- }
-
- function testReusable() {
- var calc = new math.CalculatorPtr();
- var calcImpl1 = new CalculatorImpl();
- var calcBinding1 = new bindings.Binding(math.Calculator,
- calcImpl1,
- bindings.makeRequest(calc));
- var calcImpl2 = new CalculatorImpl();
- var calcBinding2 = new bindings.Binding(math.Calculator, calcImpl2);
-
- var promise = calc.add(2).then(function(response) {
- expect(response.value).toBe(2);
- calcBinding2.bind(bindings.makeRequest(calc));
- return calc.add(2);
- }).then(function(response) {
- expect(response.value).toBe(2);
- expect(calcImpl1.total).toBe(2);
- expect(calcImpl2.total).toBe(2);
- return Promise.resolve();
- });
-
- return promise;
- }
-
- function testConnectionError() {
- var calc = new math.CalculatorPtr();
- var calcBinding = new bindings.Binding(math.Calculator,
- new CalculatorImpl(),
- bindings.makeRequest(calc));
-
- var promise = new Promise(function(resolve, reject) {
- calc.ptr.setConnectionErrorHandler(function() {
- resolve();
- });
- calcBinding.close();
- });
-
- return promise;
- }
-
- function testPassInterface() {
- var calc = new math.CalculatorPtr();
- var newCalc = null;
- var calcBinding = new bindings.Binding(math.Calculator,
- new CalculatorImpl(),
- bindings.makeRequest(calc));
-
- var promise = calc.add(2).then(function(response) {
- expect(response.value).toBe(2);
- newCalc = new math.CalculatorPtr();
- newCalc.ptr.bind(calc.ptr.passInterface());
- expect(calc.ptr.isBound()).toBeFalsy();
- return newCalc.add(2);
- }).then(function(response) {
- expect(response.value).toBe(4);
- return Promise.resolve();
- });
-
- return promise;
- }
-
- function testBindRawHandle() {
- var pipe = core.createMessagePipe();
- var calc = new math.CalculatorPtr(pipe.handle0);
- var newCalc = null;
- var calcBinding = new bindings.Binding(math.Calculator,
- new CalculatorImpl(),
- pipe.handle1);
-
- var promise = calc.add(2).then(function(response) {
- expect(response.value).toBe(2);
- return Promise.resolve();
- });
-
- return promise;
- }
-});
« no previous file with comments | « mojo/edk/js/tests/connection_tests.js ('k') | mojo/edk/js/tests/js_to_cpp_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698