Commit 37794d09 authored by garykac@chromium.org's avatar garykac@chromium.org

Setup JS unittests for Chromoting

BUG=none
TEST=remoting_unittests --gtest_filter=DebugLogUnitTest.*


Review URL: http://codereview.chromium.org/8599010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112252 0039d316-1c4b-4281-b951-d872f2087c98
parent 1b99ff18
...@@ -25,31 +25,31 @@ ...@@ -25,31 +25,31 @@
# TODO(gregoryd): chrome_resources and chrome_strings could be # TODO(gregoryd): chrome_resources and chrome_strings could be
# shared with the 64-bit target, but it does not work due to a gyp # shared with the 64-bit target, but it does not work due to a gyp
# issue. # issue.
'app/policy/cloud_policy_codegen.gyp:policy',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
'chrome_resources.gyp:theme_resources',
'common_constants', 'common_constants',
'common_net', 'common_net',
'common_version', 'common_version',
'../base/base.gyp:base', '<(DEPTH)/base/base.gyp:base',
'../base/base.gyp:base_i18n', '<(DEPTH)/base/base.gyp:base_i18n',
'../base/base.gyp:base_static', '<(DEPTH)/base/base.gyp:base_static',
'../build/temp_gyp/googleurl.gyp:googleurl', '<(DEPTH)/build/temp_gyp/googleurl.gyp:googleurl',
'../content/content.gyp:content_common', '<(DEPTH)/chrome/app/policy/cloud_policy_codegen.gyp:policy',
'../ipc/ipc.gyp:ipc', '<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources',
'../net/net.gyp:net', '<(DEPTH)/chrome/chrome_resources.gyp:chrome_strings',
'../printing/printing.gyp:printing', '<(DEPTH)/chrome/chrome_resources.gyp:theme_resources',
'../skia/skia.gyp:skia', '<(DEPTH)/content/content.gyp:content_common',
'../third_party/bzip2/bzip2.gyp:bzip2', '<(DEPTH)/ipc/ipc.gyp:ipc',
'../third_party/icu/icu.gyp:icui18n', '<(DEPTH)/net/net.gyp:net',
'../third_party/icu/icu.gyp:icuuc', '<(DEPTH)/printing/printing.gyp:printing',
'../third_party/libxml/libxml.gyp:libxml', '<(DEPTH)/skia/skia.gyp:skia',
'../third_party/sqlite/sqlite.gyp:sqlite', '<(DEPTH)/third_party/bzip2/bzip2.gyp:bzip2',
'../third_party/zlib/zlib.gyp:zlib', '<(DEPTH)/third_party/icu/icu.gyp:icui18n',
'../ui/ui.gyp:ui_resources', '<(DEPTH)/third_party/icu/icu.gyp:icuuc',
'../ui/ui.gyp:ui_resources_standard', '<(DEPTH)/third_party/libxml/libxml.gyp:libxml',
'../webkit/support/webkit_support.gyp:glue', '<(DEPTH)/third_party/sqlite/sqlite.gyp:sqlite',
'<(DEPTH)/third_party/zlib/zlib.gyp:zlib',
'<(DEPTH)/ui/ui.gyp:ui_resources',
'<(DEPTH)/ui/ui.gyp:ui_resources_standard',
'<(DEPTH)/webkit/support/webkit_support.gyp:glue',
], ],
'sources': [ 'sources': [
'common/about_handler.cc', 'common/about_handler.cc',
...@@ -251,7 +251,7 @@ ...@@ -251,7 +251,7 @@
}], }],
['OS=="win" and use_aura==0', { ['OS=="win" and use_aura==0', {
'dependencies': [ 'dependencies': [
'default_plugin/default_plugin.gyp:default_plugin', '<(DEPTH)/chrome/default_plugin/default_plugin.gyp:default_plugin',
] ]
}], }],
['toolkit_uses_gtk == 1', { ['toolkit_uses_gtk == 1', {
...@@ -384,15 +384,15 @@ ...@@ -384,15 +384,15 @@
'common/net/x509_certificate_model.h', 'common/net/x509_certificate_model.h',
], ],
'dependencies': [ 'dependencies': [
'chrome_resources.gyp:chrome_resources', '<(DEPTH)/base/base.gyp:base',
'chrome_resources.gyp:chrome_strings', '<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources',
'../base/base.gyp:base', '<(DEPTH)/chrome/chrome_resources.gyp:chrome_strings',
'../crypto/crypto.gyp:crypto', '<(DEPTH)/crypto/crypto.gyp:crypto',
'../gpu/gpu.gyp:gpu_ipc', '<(DEPTH)/gpu/gpu.gyp:gpu_ipc',
'../net/net.gyp:net_resources', '<(DEPTH)/net/net.gyp:net_resources',
'../net/net.gyp:net', '<(DEPTH)/net/net.gyp:net',
'../third_party/icu/icu.gyp:icui18n', '<(DEPTH)/third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc', '<(DEPTH)/third_party/icu/icu.gyp:icuuc',
], ],
'conditions': [ 'conditions': [
['os_posix == 1 and OS != "mac"', { ['os_posix == 1 and OS != "mac"', {
......
...@@ -71,11 +71,11 @@ ...@@ -71,11 +71,11 @@
'dependencies': [ 'dependencies': [
'installer_util', 'installer_util',
'installer_util_strings', 'installer_util_strings',
'../content/content.gyp:content_common',
'<(DEPTH)/base/base.gyp:base', '<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/base/base.gyp:base_i18n', '<(DEPTH)/base/base.gyp:base_i18n',
'<(DEPTH)/base/base.gyp:test_support_base', '<(DEPTH)/base/base.gyp:test_support_base',
'<(DEPTH)/build/temp_gyp/googleurl.gyp:googleurl', '<(DEPTH)/build/temp_gyp/googleurl.gyp:googleurl',
'<(DEPTH)/content/content.gyp:content_common',
'<(DEPTH)/testing/gmock.gyp:gmock', '<(DEPTH)/testing/gmock.gyp:gmock',
'<(DEPTH)/testing/gtest.gyp:gtest', '<(DEPTH)/testing/gtest.gyp:gtest',
], ],
......
...@@ -98,11 +98,11 @@ ...@@ -98,11 +98,11 @@
'dependencies': [ 'dependencies': [
'installer_util_strings', 'installer_util_strings',
'common_constants', 'common_constants',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
'<(DEPTH)/base/base.gyp:base', '<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
'<(DEPTH)/build/temp_gyp/googleurl.gyp:googleurl', '<(DEPTH)/build/temp_gyp/googleurl.gyp:googleurl',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_strings',
'<(DEPTH)/content/content.gyp:content_common', '<(DEPTH)/content/content.gyp:content_common',
'<(DEPTH)/courgette/courgette.gyp:courgette_lib', '<(DEPTH)/courgette/courgette.gyp:courgette_lib',
'<(DEPTH)/third_party/bspatch/bspatch.gyp:bspatch', '<(DEPTH)/third_party/bspatch/bspatch.gyp:bspatch',
...@@ -182,8 +182,8 @@ ...@@ -182,8 +182,8 @@
'type': 'static_library', 'type': 'static_library',
'dependencies': [ 'dependencies': [
'common_constants', 'common_constants',
'chrome_resources.gyp:chrome_resources', '<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings', '<(DEPTH)/chrome/chrome_resources.gyp:chrome_strings',
], ],
'sources': [ 'sources': [
'installer/util/master_preferences.cc', 'installer/util/master_preferences.cc',
......
...@@ -3,12 +3,6 @@ ...@@ -3,12 +3,6 @@
# found in the LICENSE file. # found in the LICENSE file.
{ {
'variables' : { 'variables' : {
# Variables for js2gtest rules
'gypv8sh': '../tools/gypv8sh.py',
'js2gtest': 'test/base/js2gtest.js',
'mock_js': 'third_party/mock4js/mock4js.js',
'test_api_js': 'test/data/webui/test_api.js',
'pyautolib_sources': [ 'pyautolib_sources': [
'app/chrome_command_ids.h', 'app/chrome_command_ids.h',
'app/chrome_dll_resource.h', 'app/chrome_dll_resource.h',
...@@ -32,6 +26,9 @@ ...@@ -32,6 +26,9 @@
}], }],
], ],
}, },
'includes': [
'js_unittest_vars.gypi',
],
'targets': [ 'targets': [
{ {
# This target contains mocks and test utilities that don't belong in # This target contains mocks and test utilities that don't belong in
...@@ -1180,6 +1177,10 @@ ...@@ -1180,6 +1177,10 @@
'include_dirs': [ 'include_dirs': [
'..', '..',
], ],
# TODO(scr): Use this in browser_tests too.
'includes': [
'js_unittest_rules.gypi',
],
'defines': [ 'defines': [
'CLD_WINDOWS', 'CLD_WINDOWS',
], ],
...@@ -2023,50 +2024,6 @@ ...@@ -2023,50 +2024,6 @@
'../webkit/quota/mock_storage_client.cc', '../webkit/quota/mock_storage_client.cc',
'../webkit/quota/mock_storage_client.h', '../webkit/quota/mock_storage_client.h',
], ],
'rules': [
{
'rule_name': 'copyjs',
'extension': 'js',
'msvs_external_rule': 1,
'inputs': [
'../build/cp.py',
],
'outputs': [
'<(PRODUCT_DIR)/test_data/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).<(_extension)',
],
'action': [
'python',
'<@(_inputs)',
'<(RULE_INPUT_PATH)',
'<@(_outputs)',
],
},
{
'rule_name': 'js2unit',
'extension': 'gtestjs',
'msvs_external_rule': 1,
'inputs': [
'<(gypv8sh)',
'<(PRODUCT_DIR)/v8_shell<(EXECUTABLE_SUFFIX)',
'<(mock_js)',
'<(test_api_js)',
'<(js2gtest)',
],
'outputs': [
'<(INTERMEDIATE_DIR)/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT)-gen.cc',
'<(PRODUCT_DIR)/test_data/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).<(_extension)',
],
'process_outputs_as_sources': 1,
'action': [
'python',
'<@(_inputs)',
'unit',
'<(RULE_INPUT_PATH)',
'chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).<(_extension)',
'<@(_outputs)',
],
},
],
'conditions': [ 'conditions': [
['target_arch!="arm"', { ['target_arch!="arm"', {
'dependencies': [ 'dependencies': [
......
# Copyright (c) 2011 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.
# This file defines rules that allow you to include JavaScript tests in
# your unittests target.
# To add JS unittests to an existing unittest target, first include
# 'js_unittest_vars.gypi' at the top of your GYP file to define the required
# variables:
#
# 'includes': [
# '<(DEPTH)/chrome/js_unittest_vars.gypi',
# ],
#
# Then include this rule file in each of your unittest targets:
#
# {
# 'target_name': 'my_unittests',
# ...
# 'includes': [
# '<(DEPTH)/chrome/js_unittest_rules.gypi',
# ],
# }
#
# Note that when you run your TestSuite, you'll need to call
# chrome::RegisterPathProvider(). These path providers are required by
# src/chrome/test/base/v8_unit_test.cc to setup and run the tests.
#
# See src/chrome/test/base/run_all_remoting_unittests.cc for an example.
{
'rules': [
{
'rule_name': 'copyjs',
'extension': 'js',
'msvs_external_rule': 1,
'inputs': [
'<(DEPTH)/build/cp.py',
],
'outputs': [
'<(PRODUCT_DIR)/test_data/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).<(_extension)',
],
'action': [
'python',
'<@(_inputs)',
'<(RULE_INPUT_PATH)',
'<@(_outputs)',
],
},
{
'rule_name': 'js2unit',
'extension': 'gtestjs',
'msvs_external_rule': 1,
'inputs': [
'<(gypv8sh)',
'<(PRODUCT_DIR)/v8_shell<(EXECUTABLE_SUFFIX)',
'<(mock_js)',
'<(test_api_js)',
'<(js2gtest)',
],
'outputs': [
'<(INTERMEDIATE_DIR)/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT)-gen.cc',
'<(PRODUCT_DIR)/test_data/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).<(_extension)',
],
'process_outputs_as_sources': 1,
'action': [
'python',
'<@(_inputs)',
'unit',
'<(RULE_INPUT_PATH)',
'chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).<(_extension)',
'<@(_outputs)',
],
},
],
}
# Copyright (c) 2011 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.
{
'variables' : {
'gypv8sh': '<(DEPTH)/tools/gypv8sh.py',
'js2gtest': '<(DEPTH)/chrome/test/base/js2gtest.js',
'mock_js': '<(DEPTH)/chrome/third_party/mock4js/mock4js.js',
'test_api_js': '<(DEPTH)/chrome/test/data/webui/test_api.js',
},
}
...@@ -2,12 +2,20 @@ ...@@ -2,12 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/file_path.h" // A basic testrunner that supports JavaScript unittests.
#include "base/logging.h" // This lives in src/chrome/test/base so that it can include chrome_paths.h
#include "base/path_service.h" // (required for JS unittests) without updating the DEPS file for each
// subproject.
#include "base/test/test_suite.h" #include "base/test/test_suite.h"
#include "chrome/common/chrome_paths.h"
int main(int argc, char** argv) { int main(int argc, char** argv) {
base::TestSuite test_suite(argc, argv); base::TestSuite test_suite(argc, argv);
// This is required for the JavaScript unittests.
chrome::RegisterPathProvider();
return test_suite.Run(); return test_suite.Run();
} }
...@@ -11,6 +11,17 @@ ...@@ -11,6 +11,17 @@
# is brand-dependent and is defined further down. # is brand-dependent and is defined further down.
'host_plugin_mime_type': 'application/vnd.chromium.remoting-host', 'host_plugin_mime_type': 'application/vnd.chromium.remoting-host',
'host_plugin_description': 'Allow another user to access your computer securely over the Internet.', 'host_plugin_description': 'Allow another user to access your computer securely over the Internet.',
# Variables for common_constants (used by JS unittests).
'variables': {
'version_py_path': '../chrome/tools/build/version.py',
'version_path': '../chrome/VERSION',
},
'version_py_path': '<(version_py_path)',
'version_path': '<(version_path)',
'version_full':
'<!(python <(version_py_path) -f <(version_path) -t "@MAJOR@.@MINOR@.@BUILD@.@PATCH@")',
'conditions': [ 'conditions': [
['OS=="mac"', { ['OS=="mac"', {
'conditions': [ 'conditions': [
...@@ -138,6 +149,12 @@ ...@@ -138,6 +149,12 @@
], ],
}, },
'includes': [
# The common_constants target is needed for the JS unittests.
'../chrome/common_constants.gypi',
'../chrome/js_unittest_vars.gypi',
],
'target_defaults': { 'target_defaults': {
'defines': [ 'defines': [
], ],
...@@ -147,6 +164,14 @@ ...@@ -147,6 +164,14 @@
}, },
'conditions': [ 'conditions': [
['OS == "win"', {
'includes': [
# Required for JS unittests.
'../chrome/chrome_common.gypi',
'../chrome/chrome_installer.gypi',
'../chrome/chrome_installer_util.gypi',
],
}], # 'OS == "win"'
['os_posix == 1', { ['os_posix == 1', {
'targets': [ 'targets': [
# Simple webserver for testing remoting client plugin. # Simple webserver for testing remoting client plugin.
...@@ -158,7 +183,7 @@ ...@@ -158,7 +183,7 @@
], ],
} }
], # end of target 'remoting_client_test_webserver' ], # end of target 'remoting_client_test_webserver'
}], }], # 'os_posix == 1'
['OS=="linux"', { ['OS=="linux"', {
'targets': [ 'targets': [
# Linux breakpad processing # Linux breakpad processing
...@@ -865,6 +890,7 @@ ...@@ -865,6 +890,7 @@
'target_name': 'remoting_unittests', 'target_name': 'remoting_unittests',
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'common_constants', # from common_constants.gypi
'remoting_base', 'remoting_base',
'remoting_client', 'remoting_client',
'remoting_host', 'remoting_host',
...@@ -874,14 +900,21 @@ ...@@ -874,14 +900,21 @@
'../base/base.gyp:base_i18n', '../base/base.gyp:base_i18n',
'../base/base.gyp:test_support_base', '../base/base.gyp:test_support_base',
'../media/media.gyp:media', '../media/media.gyp:media',
'../ui/ui.gyp:ui',
'../testing/gmock.gyp:gmock', '../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest', '../testing/gtest.gyp:gtest',
'../ui/ui.gyp:ui',
'../v8/tools/gyp/v8.gyp:v8',
], ],
'include_dirs': [ 'include_dirs': [
'../testing/gmock/include', '../testing/gmock/include',
], ],
'includes': [
'../chrome/js_unittest_rules.gypi',
],
'sources': [ 'sources': [
'../chrome/test/base/v8_unit_test.cc',
'../chrome/test/base/v8_unit_test.h',
'../chrome/test/base/run_all_remoting_unittests.cc',
'base/auth_token_util_unittest.cc', 'base/auth_token_util_unittest.cc',
'base/codec_test.cc', 'base/codec_test.cc',
'base/codec_test.h', 'base/codec_test.h',
...@@ -931,7 +964,8 @@ ...@@ -931,7 +964,8 @@
'protocol/rtp_video_reader_unittest.cc', 'protocol/rtp_video_reader_unittest.cc',
'protocol/rtp_video_writer_unittest.cc', 'protocol/rtp_video_writer_unittest.cc',
'protocol/v1_authenticator_unittest.cc', 'protocol/v1_authenticator_unittest.cc',
'run_all_unittests.cc', 'webapp/me2mom/debug_log.gtestjs',
'webapp/me2mom/debug_log.js',
], ],
'conditions': [ 'conditions': [
['toolkit_uses_gtk == 1', { ['toolkit_uses_gtk == 1', {
...@@ -952,6 +986,12 @@ ...@@ -952,6 +986,12 @@
], ],
], ],
}], }],
['OS == "win"', {
'dependencies': [
# Required for JS unittests.
'installer_util',
],
}], # 'OS == "win"'
], # end of 'conditions' ], # end of 'conditions'
}, # end of target 'remoting_unittests' }, # end of target 'remoting_unittests'
], # end of targets ], # end of targets
......
// Copyright (c) 2011 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.
/**
* Test fixture for debug logging routines.
* @constructor
* @extends {testing.Test}
*/
function DebugLogUnitTest () {}
DebugLogUnitTest.prototype = {
__proto__: testing.Test.prototype,
/** @inheritDoc */
extraLibraries: [
'debug_log.js',
],
};
// Dummy test to verify that the JS Unittest framework is working and that
// debug_log.js loads without console errors.
// TODO(garykac): Replace this with real tests.
TEST_F('DebugLogUnitTest', 'TestJsLoad', function() {
assertTrue(true);
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment