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

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

Issue 399363002: Add support for writing unit tests for Mojo-backed apps/extensions APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years, 5 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 unified diff | Download patch
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 var nativesPromise = requireAsync('testNatives');
6
7 function registerHooks(api, runTests, testName) {
8 var chromeTest = api.compiledApi;
9 var apiFunctions = api.apiFunctions;
10
11 apiFunctions.setHandleRequest('notifyPass', function() {
12 nativesPromise.then(function(natives) {
13 natives.NotifyPass();
14 });
15 });
16
17 apiFunctions.setHandleRequest('notifyFail', function(message) {
18 nativesPromise.then(function(natives) {
19 natives.NotifyFail(message);
20 });
21 });
22
23 apiFunctions.setHandleRequest('log', function() {
24 nativesPromise.then(function(natives) {
25 natives.Log($Array.join(arguments, ' '));
26 });
27 });
28
29 apiFunctions.setHandleRequest('runTests', function(tests) {
30 var testWrappers = {};
31 $Array.forEach(tests, function(test) {
32 testWrappers[testName(test)] = function() {
33 runTests([test]);
34 return true;
35 }
36 });
37 return testWrappers;
38 });
39
40 apiFunctions.setHandleRequest('runWithModuleSystem', function(callback) {
41 throw new Error('Not implemented');
42 });
43
44 apiFunctions.setHandleRequest('getApiDefinitions', function() {
45 throw new Error('Not implemented');
46 });
47
48 apiFunctions.setHandleRequest('getApiFeatures', function() {
49 throw new Error('Not implemented');
50 });
51
52 apiFunctions.setHandleRequest('isProcessingUserGesture', function() {
53 throw new Error('Not implemented');
54 });
55
56 apiFunctions.setHandleRequest('runWithUserGesture', function(callback) {
57 throw new Error('Not implemented');
58 });
59
60 apiFunctions.setHandleRequest('runWithoutUserGesture', function(callback) {
61 throw new Error('Not implemented');
62 });
63
64 apiFunctions.setHandleRequest('setExceptionHandler', function(callback) {
65 chromeTest.assertEq(typeof(callback), 'function');
66 uncaughtExceptionHandler.setHandler(callback);
67 });
68 }
69
70 function testDone(runNextTest) {
71 // Use a promise here to allow previous test contexts to be eligible for
72 // garbage collection.
73 Promise.resolve().then(function() {
74 runNextTest();
75 });
76 }
77
78 exports.registerHooks = registerHooks;
79 exports.testDone = testDone;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698