Skip to content

Commit

Permalink
Setup JS unittests for Chromoting
Browse files Browse the repository at this point in the history
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
  • Loading branch information
garykac@chromium.org committed Nov 30, 2011
1 parent 1b99ff1 commit 37794d0
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 103 deletions.
64 changes: 32 additions & 32 deletions chrome/chrome_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@
# TODO(gregoryd): chrome_resources and chrome_strings could be
# shared with the 64-bit target, but it does not work due to a gyp
# 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_net',
'common_version',
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../base/base.gyp:base_static',
'../build/temp_gyp/googleurl.gyp:googleurl',
'../content/content.gyp:content_common',
'../ipc/ipc.gyp:ipc',
'../net/net.gyp:net',
'../printing/printing.gyp:printing',
'../skia/skia.gyp:skia',
'../third_party/bzip2/bzip2.gyp:bzip2',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
'../third_party/libxml/libxml.gyp:libxml',
'../third_party/sqlite/sqlite.gyp:sqlite',
'../third_party/zlib/zlib.gyp:zlib',
'../ui/ui.gyp:ui_resources',
'../ui/ui.gyp:ui_resources_standard',
'../webkit/support/webkit_support.gyp:glue',
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/base/base.gyp:base_i18n',
'<(DEPTH)/base/base.gyp:base_static',
'<(DEPTH)/build/temp_gyp/googleurl.gyp:googleurl',
'<(DEPTH)/chrome/app/policy/cloud_policy_codegen.gyp:policy',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_strings',
'<(DEPTH)/chrome/chrome_resources.gyp:theme_resources',
'<(DEPTH)/content/content.gyp:content_common',
'<(DEPTH)/ipc/ipc.gyp:ipc',
'<(DEPTH)/net/net.gyp:net',
'<(DEPTH)/printing/printing.gyp:printing',
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/third_party/bzip2/bzip2.gyp:bzip2',
'<(DEPTH)/third_party/icu/icu.gyp:icui18n',
'<(DEPTH)/third_party/icu/icu.gyp:icuuc',
'<(DEPTH)/third_party/libxml/libxml.gyp:libxml',
'<(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': [
'common/about_handler.cc',
Expand Down Expand Up @@ -251,7 +251,7 @@
}],
['OS=="win" and use_aura==0', {
'dependencies': [
'default_plugin/default_plugin.gyp:default_plugin',
'<(DEPTH)/chrome/default_plugin/default_plugin.gyp:default_plugin',
]
}],
['toolkit_uses_gtk == 1', {
Expand Down Expand Up @@ -384,15 +384,15 @@
'common/net/x509_certificate_model.h',
],
'dependencies': [
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
'../base/base.gyp:base',
'../crypto/crypto.gyp:crypto',
'../gpu/gpu.gyp:gpu_ipc',
'../net/net.gyp:net_resources',
'../net/net.gyp:net',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_strings',
'<(DEPTH)/crypto/crypto.gyp:crypto',
'<(DEPTH)/gpu/gpu.gyp:gpu_ipc',
'<(DEPTH)/net/net.gyp:net_resources',
'<(DEPTH)/net/net.gyp:net',
'<(DEPTH)/third_party/icu/icu.gyp:icui18n',
'<(DEPTH)/third_party/icu/icu.gyp:icuuc',
],
'conditions': [
['os_posix == 1 and OS != "mac"', {
Expand Down
2 changes: 1 addition & 1 deletion chrome/chrome_installer.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
'dependencies': [
'installer_util',
'installer_util_strings',
'../content/content.gyp:content_common',
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/base/base.gyp:base_i18n',
'<(DEPTH)/base/base.gyp:test_support_base',
'<(DEPTH)/build/temp_gyp/googleurl.gyp:googleurl',
'<(DEPTH)/content/content.gyp:content_common',
'<(DEPTH)/testing/gmock.gyp:gmock',
'<(DEPTH)/testing/gtest.gyp:gtest',
],
Expand Down
8 changes: 4 additions & 4 deletions chrome/chrome_installer_util.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@
'dependencies': [
'installer_util_strings',
'common_constants',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
'<(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)/courgette/courgette.gyp:courgette_lib',
'<(DEPTH)/third_party/bspatch/bspatch.gyp:bspatch',
Expand Down Expand Up @@ -182,8 +182,8 @@
'type': 'static_library',
'dependencies': [
'common_constants',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_strings',
],
'sources': [
'installer/util/master_preferences.cc',
Expand Down
57 changes: 7 additions & 50 deletions chrome/chrome_tests.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
# found in the LICENSE file.
{
'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': [
'app/chrome_command_ids.h',
'app/chrome_dll_resource.h',
Expand All @@ -32,6 +26,9 @@
}],
],
},
'includes': [
'js_unittest_vars.gypi',
],
'targets': [
{
# This target contains mocks and test utilities that don't belong in
Expand Down Expand Up @@ -1180,6 +1177,10 @@
'include_dirs': [
'..',
],
# TODO(scr): Use this in browser_tests too.
'includes': [
'js_unittest_rules.gypi',
],
'defines': [
'CLD_WINDOWS',
],
Expand Down Expand Up @@ -2023,50 +2024,6 @@
'../webkit/quota/mock_storage_client.cc',
'../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': [
['target_arch!="arm"', {
'dependencies': [
Expand Down
77 changes: 77 additions & 0 deletions chrome/js_unittest_rules.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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)',
],
},
],
}
12 changes: 12 additions & 0 deletions chrome/js_unittest_vars.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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',
},
}
21 changes: 21 additions & 0 deletions chrome/test/base/run_all_remoting_unittests.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.

// A basic testrunner that supports JavaScript unittests.
// This lives in src/chrome/test/base so that it can include chrome_paths.h
// (required for JS unittests) without updating the DEPS file for each
// subproject.


#include "base/test/test_suite.h"
#include "chrome/common/chrome_paths.h"

int main(int argc, char** argv) {
base::TestSuite test_suite(argc, argv);

// This is required for the JavaScript unittests.
chrome::RegisterPathProvider();

return test_suite.Run();
}
Loading

0 comments on commit 37794d0

Please sign in to comment.