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

Unified Diff: extensions/test/data/unit_test_environment_specific_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/test/data/unit_test_environment_specific_bindings.js
diff --git a/extensions/test/data/unit_test_environment_specific_bindings.js b/extensions/test/data/unit_test_environment_specific_bindings.js
new file mode 100644
index 0000000000000000000000000000000000000000..c7b7f43620b786c516bea37f1641bb35f2c912d7
--- /dev/null
+++ b/extensions/test/data/unit_test_environment_specific_bindings.js
@@ -0,0 +1,78 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var nativesPromise = requireAsync('testNatives');
+
+function registerHooks(api) {
+ var chromeTest = api.compiledApi;
+ var apiFunctions = api.apiFunctions;
+
+ apiFunctions.setHandleRequest('notifyPass', function() {
+ nativesPromise.then(function(natives) {
+ natives.NotifyPass();
+ });
+ });
+
+ apiFunctions.setHandleRequest('notifyFail', function(message) {
+ nativesPromise.then(function(natives) {
+ natives.NotifyFail(message);
+ });
+ });
+
+ apiFunctions.setHandleRequest('log', function() {
+ nativesPromise.then(function(natives) {
+ natives.Log($Array.join(arguments, ' '));
+ });
+ });
+
+ apiFunctions.setHandleRequest('runWithModuleSystem', function(callback) {
+ throw new Error('Not implemented');
+ });
+
+ apiFunctions.setHandleRequest('getApiDefinitions', function() {
+ throw new Error('Not implemented');
+ });
+
+ apiFunctions.setHandleRequest('getApiFeatures', function() {
+ throw new Error('Not implemented');
+ });
+
+ apiFunctions.setHandleRequest('isProcessingUserGesture', function() {
+ throw new Error('Not implemented');
+ });
+
+ apiFunctions.setHandleRequest('runWithUserGesture', function(callback) {
+ throw new Error('Not implemented');
+ });
+
+ apiFunctions.setHandleRequest('runWithoutUserGesture', function(callback) {
+ throw new Error('Not implemented');
+ });
+
+ apiFunctions.setHandleRequest('setExceptionHandler', function(callback) {
+ chromeTest.assertEq(typeof(callback), 'function');
+ uncaughtExceptionHandler.setHandler(callback);
+ });
+}
+
+function testDone(runNextTest) {
+ // Use a promise here to allow previous test contexts to be eligible for
+ // garbage collection.
+ Promise.resolve().then(function() {
+ runNextTest();
+ });
+}
+
+function exportTests(tests, runTests, exports) {
+ $Array.forEach(tests, function(test) {
+ exports[test.name] = function() {
+ runTests([test]);
+ return true;
+ }
+ });
+}
+
+exports.registerHooks = registerHooks;
+exports.testDone = testDone;
+exports.exportTests = exportTests;

Powered by Google App Engine
This is Rietveld 408576698