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

Unified Diff: extensions/test/data/api_test_base_unittest.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: 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
« no previous file with comments | « extensions/test/DEPS ('k') | extensions/test/data/unit_test_environment_specific_bindings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/test/data/api_test_base_unittest.js
diff --git a/extensions/test/data/api_test_base_unittest.js b/extensions/test/data/api_test_base_unittest.js
new file mode 100644
index 0000000000000000000000000000000000000000..c402d59bbc9a1cff021b77d4d3218c57031a4c7d
--- /dev/null
+++ b/extensions/test/data/api_test_base_unittest.js
@@ -0,0 +1,65 @@
+// 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 test = require('test').binding;
+var unittestBindings = require('test_environment_specific_bindings');
+
+unittestBindings.exportTests([
+ function testEnvironment() {
+ test.assertTrue(!!$Array);
+ test.assertTrue(!!$Function);
+ test.assertTrue(!!$JSON);
+ test.assertTrue(!!$Object);
+ test.assertTrue(!!$RegExp);
+ test.assertTrue(!!$String);
+ test.assertTrue(!!privates);
+ test.assertTrue(!!define);
+ test.assertTrue(!!require);
+ test.assertTrue(!!requireNative);
+ test.assertTrue(!!requireAsync);
+ test.assertEq(undefined, chrome.runtime.lastError);
+ test.assertEq(undefined, chrome.extension.lastError);
+ test.succeed();
+ },
+ function testPromisesRun() {
+ Promise.resolve().then(test.callbackPass());
+ },
+ function testCommonModulesAreAvailable() {
+ var binding = require('binding');
+ var sendRequest = require('sendRequest');
+ var lastError = require('lastError');
+ test.assertTrue(!!binding);
+ test.assertTrue(!!sendRequest);
+ test.assertTrue(!!lastError);
+ test.succeed();
+ },
+ function testMojoModulesAreAvailable() {
+ Promise.all([
+ requireAsync('mojo/public/js/bindings/connection'),
+ requireAsync('mojo/public/js/bindings/core'),
+ requireAsync('content/public/renderer/service_provider'),
+ ]).then(test.callback(function(modules) {
+ var connection = modules[0];
+ var core = modules[1];
+ var serviceProvider = modules[2];
+ test.assertTrue(!!connection.Connection);
+ test.assertTrue(!!core.createMessagePipe);
+ test.assertTrue(!!serviceProvider.connectToService);
+ }));
+ },
+ function testTestBindings() {
+ var counter = 0;
+ function increment() {
+ counter++;
+ }
+ test.runWithUserGesture(increment);
+ test.runWithoutUserGesture(increment);
+ test.runWithModuleSystem(increment);
+ test.assertEq(3, counter);
+ test.assertFalse(test.isProcessingUserGesture());
+ test.assertTrue(!!test.getApiFeatures());
+ test.assertEq(0, test.getApiDefinitions().length);
+ test.succeed();
+ }
+], test.runTests, exports);
« no previous file with comments | « extensions/test/DEPS ('k') | extensions/test/data/unit_test_environment_specific_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698