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

Unified Diff: extensions/renderer/resources/test_custom_bindings.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: rebase 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 side-by-side diff with in-line comments
Download patch
Index: extensions/renderer/resources/test_custom_bindings.js
diff --git a/extensions/renderer/resources/test_custom_bindings.js b/extensions/renderer/resources/test_custom_bindings.js
index 5fd45495247c5def8a319ef9895dd59d07155640..0b955c7bb6c089f78caad2097ca558798787e674 100644
--- a/extensions/renderer/resources/test_custom_bindings.js
+++ b/extensions/renderer/resources/test_custom_bindings.js
@@ -7,16 +7,8 @@
var binding = require('binding').Binding.create('test');
-var chrome = requireNative('chrome').GetChrome();
-var GetExtensionAPIDefinitionsForTest =
- requireNative('apiDefinitions').GetExtensionAPIDefinitionsForTest;
-var GetAvailability = requireNative('v8_context').GetAvailability;
-var GetAPIFeatures = requireNative('test_features').GetAPIFeatures;
+var environmentSpecificBindings = require('test_environment_specific_bindings');
var uncaughtExceptionHandler = require('uncaught_exception_handler');
-var userGestures = requireNative('user_gestures');
-
-var RunWithNativesEnabledModuleSystem =
- requireNative('v8_context').RunWithNativesEnabledModuleSystem;
binding.registerCustomHook(function(api) {
var chromeTest = api.compiledApi;
@@ -37,9 +29,7 @@ binding.registerCustomHook(function(api) {
}
function testDone() {
- // Use setTimeout here to allow previous test contexts to be
- // eligible for garbage collection.
- setTimeout(chromeTest.runNextTest, 0);
+ environmentSpecificBindings.testDone(chromeTest.runNextTest);
}
function allTestsDone() {
@@ -60,7 +50,7 @@ binding.registerCustomHook(function(api) {
return function() {
if (called != null) {
var redundantPrefix = 'Error\n';
- chrome.test.fail(
+ chromeTest.fail(
'Callback has already been run. ' +
'First call:\n' +
$String.slice(called, redundantPrefix.length) + '\n' +
@@ -125,10 +115,6 @@ binding.registerCustomHook(function(api) {
testDone();
});
- apiFunctions.setHandleRequest('runWithModuleSystem', function(callback) {
- RunWithNativesEnabledModuleSystem(callback);
- });
-
apiFunctions.setHandleRequest('assertTrue', function(test, message) {
chromeTest.assertBool(test, true, message);
});
@@ -329,32 +315,12 @@ binding.registerCustomHook(function(api) {
chromeTest.runNextTest();
});
- apiFunctions.setHandleRequest('getApiDefinitions', function() {
- return GetExtensionAPIDefinitionsForTest();
- });
-
- apiFunctions.setHandleRequest('getApiFeatures', function() {
- return GetAPIFeatures();
- });
-
- apiFunctions.setHandleRequest('isProcessingUserGesture', function() {
- return userGestures.IsProcessingUserGesture();
- });
-
- apiFunctions.setHandleRequest('runWithUserGesture', function(callback) {
not at google - send to devlin 2014/07/25 00:17:57 I guess you need to pull these out because userGes
Sam McNally 2014/07/25 07:38:59 Done, except for getApiFeatures which requires a r
- chromeTest.assertEq(typeof(callback), 'function');
- return userGestures.RunWithUserGesture(callback);
- });
-
- apiFunctions.setHandleRequest('runWithoutUserGesture', function(callback) {
- chromeTest.assertEq(typeof(callback), 'function');
- return userGestures.RunWithoutUserGesture(callback);
- });
-
apiFunctions.setHandleRequest('setExceptionHandler', function(callback) {
chromeTest.assertEq(typeof(callback), 'function');
uncaughtExceptionHandler.setHandler(callback);
});
+
+ environmentSpecificBindings.registerHooks(api);
});
exports.binding = binding.generate();

Powered by Google App Engine
This is Rietveld 408576698