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

Side by Side Diff: extensions/test/data/keep_alive_client_unittest.js

Issue 669303002: Add an extensions keep-alive client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@keep-alive-service
Patch Set: keep alive client tests Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « extensions/renderer/resources/keep_alive.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 /**
6 * Unit tests for the keep-alive client.
7 *
8 * They are launched by extensions/renderer/mojo/keep_alive_client_unittest.cc.
9 */
10
11 var test = require('test').binding;
12 var unittestBindings = require('test_environment_specific_bindings');
13 var utils = require('utils');
14
15 var shouldSucceed;
16
17 // We need to set custom bindings for a real API and serial.getDevices has a
18 // simple signature.
19 var binding = require('binding').Binding.create('serial');
20 binding.registerCustomHook(function(bindingsAPI) {
21 bindingsAPI.apiFunctions.setHandleRequestWithPromise('getDevices',
22 function() {
23 if (shouldSucceed)
24 return Promise.resolve([]);
25 else
26 return Promise.reject();
27 });
28 });
29 var apiFunction = binding.generate().getDevices;
30
31 unittestBindings.exportTests([
32 // Test that a keep alive is created and destroyed for a successful API call.
33 function testKeepAliveWithSuccessfulCall() {
34 shouldSucceed = true;
35 utils.promise(apiFunction).then(test.succeed, test.fail);
36 },
37
38 // Test that a keep alive is created and destroyed for an unsuccessful API
39 // call.
40 function testKeepAliveWithError() {
41 shouldSucceed = false;
42 utils.promise(apiFunction).then(test.fail, test.succeed);
43 },
44 ], test.runTests, exports);
OLDNEW
« no previous file with comments | « extensions/renderer/resources/keep_alive.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698