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

Side by Side 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, 4 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
« no previous file with comments | « extensions/test/DEPS ('k') | extensions/test/data/unit_test_environment_specific_bindings.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 test = require('test').binding;
6 var unittestBindings = require('test_environment_specific_bindings');
7
8 unittestBindings.exportTests([
9 function testEnvironment() {
10 test.assertTrue(!!$Array);
11 test.assertTrue(!!$Function);
12 test.assertTrue(!!$JSON);
13 test.assertTrue(!!$Object);
14 test.assertTrue(!!$RegExp);
15 test.assertTrue(!!$String);
16 test.assertTrue(!!privates);
17 test.assertTrue(!!define);
18 test.assertTrue(!!require);
19 test.assertTrue(!!requireNative);
20 test.assertTrue(!!requireAsync);
21 test.assertEq(undefined, chrome.runtime.lastError);
22 test.assertEq(undefined, chrome.extension.lastError);
23 test.succeed();
24 },
25 function testPromisesRun() {
26 Promise.resolve().then(test.callbackPass());
27 },
28 function testCommonModulesAreAvailable() {
29 var binding = require('binding');
30 var sendRequest = require('sendRequest');
31 var lastError = require('lastError');
32 test.assertTrue(!!binding);
33 test.assertTrue(!!sendRequest);
34 test.assertTrue(!!lastError);
35 test.succeed();
36 },
37 function testMojoModulesAreAvailable() {
38 Promise.all([
39 requireAsync('mojo/public/js/bindings/connection'),
40 requireAsync('mojo/public/js/bindings/core'),
41 requireAsync('content/public/renderer/service_provider'),
42 ]).then(test.callback(function(modules) {
43 var connection = modules[0];
44 var core = modules[1];
45 var serviceProvider = modules[2];
46 test.assertTrue(!!connection.Connection);
47 test.assertTrue(!!core.createMessagePipe);
48 test.assertTrue(!!serviceProvider.connectToService);
49 }));
50 },
51 function testTestBindings() {
52 var counter = 0;
53 function increment() {
54 counter++;
55 }
56 test.runWithUserGesture(increment);
57 test.runWithoutUserGesture(increment);
58 test.runWithModuleSystem(increment);
59 test.assertEq(3, counter);
60 test.assertFalse(test.isProcessingUserGesture());
61 test.assertTrue(!!test.getApiFeatures());
62 test.assertEq(0, test.getApiDefinitions().length);
63 test.succeed();
64 }
65 ], test.runTests, exports);
OLDNEW
« 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