1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * Unit tests for the keep-alive client.
8 * They are launched by extensions/renderer/mojo/keep_alive_client_unittest.cc.
11 var test
= require('test').binding
;
12 var unittestBindings
= require('test_environment_specific_bindings');
13 var utils
= require('utils');
17 // We need to set custom bindings for a real API and serial.getDevices has a
19 var binding
= require('binding').Binding
.create('serial');
20 binding
.registerCustomHook(function(bindingsAPI
) {
21 bindingsAPI
.apiFunctions
.setHandleRequestWithPromise('getDevices',
24 return Promise
.resolve([]);
26 return Promise
.reject();
29 var apiFunction
= binding
.generate().getDevices
;
31 unittestBindings
.exportTests([
32 // Test that a keep alive is created and destroyed for a successful API call.
33 function testKeepAliveWithSuccessfulCall() {
35 utils
.promise(apiFunction
).then(test
.succeed
, test
.fail
);
38 // Test that a keep alive is created and destroyed for an unsuccessful API
40 function testKeepAliveWithError() {
41 shouldSucceed
= false;
42 utils
.promise(apiFunction
).then(test
.fail
, test
.succeed
);
44 ], test
.runTests
, exports
);