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

Side by Side Diff: extensions/renderer/resources/test_custom_bindings_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 chrome = requireNative('chrome').GetChrome();
6 var GetExtensionAPIDefinitionsForTest =
7 requireNative('apiDefinitions').GetExtensionAPIDefinitionsForTest;
8 var GetAPIFeatures = requireNative('test_features').GetAPIFeatures;
9 var userGestures = requireNative('user_gestures');
10
11 var RunWithNativesEnabledModuleSystem =
12 requireNative('v8_context').RunWithNativesEnabledModuleSystem;
13
14 function registerHooks(api, runTests) {
15 var chromeTest = api.compiledApi;
16 var apiFunctions = api.apiFunctions;
17
18 apiFunctions.setHandleRequest('runTests', function(tests) {
19 runTests(tests);
20 });
21
22 apiFunctions.setHandleRequest('runWithModuleSystem', function(callback) {
23 RunWithNativesEnabledModuleSystem(callback);
24 });
25
26 apiFunctions.setHandleRequest('getApiDefinitions', function() {
27 return GetExtensionAPIDefinitionsForTest();
28 });
29
30 apiFunctions.setHandleRequest('getApiFeatures', function() {
31 return GetAPIFeatures();
32 });
33
34 apiFunctions.setHandleRequest('isProcessingUserGesture', function() {
35 return userGestures.IsProcessingUserGesture();
36 });
37
38 apiFunctions.setHandleRequest('runWithUserGesture', function(callback) {
39 chromeTest.assertEq(typeof(callback), 'function');
40 return userGestures.RunWithUserGesture(callback);
41 });
42
43 apiFunctions.setHandleRequest('runWithoutUserGesture', function(callback) {
44 chromeTest.assertEq(typeof(callback), 'function');
45 return userGestures.RunWithoutUserGesture(callback);
46 });
47
48 }
49
50 function testDone(runNextTest) {
51 // Use setTimeout here to allow previous test contexts to be
52 // eligible for garbage collection.
53 setTimeout(runNextTest, 0);
54 }
55
56 exports.registerHooks = registerHooks;
57 exports.testDone = testDone;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698