summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorscr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-22 01:46:03 +0000
committerscr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-22 01:46:03 +0000
commit4ba1dbcc38a8843703a3494eef053644c00d813c (patch)
treeb411df17bd40c08df07653931356459dfa1d40f3 /chrome
parent3eb8314456f9c3aa5c791db67cb71718e4dd9c66 (diff)
downloadchromium_src-4ba1dbcc38a8843703a3494eef053644c00d813c.zip
chromium_src-4ba1dbcc38a8843703a3494eef053644c00d813c.tar.gz
chromium_src-4ba1dbcc38a8843703a3494eef053644c00d813c.tar.bz2
Allow generator javascript test files to go anywhere in the source tree
- Allow javascript files anywhere in the source tree - specifically in the same directory as the implementation files. - Copy the files to '<(PRODUCT_DIR)/test_data/...' so that cros can copy these where they need to go for cross-platform testing using 'ebuild' R=jhawkins@chromium.org BUG=90907,89337 TEST=browser_tests --gtest_filter=OptionsWebUITest.* Review URL: http://codereview.chromium.org/8333013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106833 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/ui/webui/javascript2webui.js3
-rw-r--r--chrome/browser/ui/webui/options/options_browsertest.js (renamed from chrome/test/data/webui/options.js)0
-rw-r--r--chrome/browser/ui/webui/web_ui_browsertest.cc14
-rw-r--r--chrome/browser/ui/webui/web_ui_browsertest.h3
-rw-r--r--chrome/chrome_tests.gypi15
-rw-r--r--chrome/common/chrome_paths.cc13
-rw-r--r--chrome/common/chrome_paths.h1
7 files changed, 38 insertions, 11 deletions
diff --git a/chrome/browser/ui/webui/javascript2webui.js b/chrome/browser/ui/webui/javascript2webui.js
index 731ec72..e1e380f 100644
--- a/chrome/browser/ui/webui/javascript2webui.js
+++ b/chrome/browser/ui/webui/javascript2webui.js
@@ -44,7 +44,8 @@ function TEST_F(testFixture, testFunction, testBody) {
print('IN_PROC_BROWSER_TEST_F(' + testFixture + ', ' + testFunction + ') {');
if (testGenPreamble)
testGenPreamble(testFixture, testFunction);
- print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + jsFileBase + '")));');
+ print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' +
+ jsFileBase.replace(/\\/g, '/') + '")));');
if (browsePreload) {
print(' BrowsePreload(GURL("' + browsePreload + '"), "' + testFixture +
'", "' + testFunction + '");');
diff --git a/chrome/test/data/webui/options.js b/chrome/browser/ui/webui/options/options_browsertest.js
index e3ec6ab..e3ec6ab 100644
--- a/chrome/test/data/webui/options.js
+++ b/chrome/browser/ui/webui/options/options_browsertest.js
diff --git a/chrome/browser/ui/webui/web_ui_browsertest.cc b/chrome/browser/ui/webui/web_ui_browsertest.cc
index e0a058b..2c84f2df 100644
--- a/chrome/browser/ui/webui/web_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/web_ui_browsertest.cc
@@ -251,6 +251,8 @@ void WebUIBrowserTest::SetUpInProcessBrowserTestFixture() {
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_));
test_data_directory_ = test_data_directory_.Append(kWebUITestFolder);
+ ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA,
+ &gen_test_data_directory_));
// TODO(dtseng): should this be part of every BrowserTest or just WebUI test.
FilePath resources_pack_path;
@@ -307,9 +309,15 @@ void WebUIBrowserTest::BuildJavascriptLibraries(string16* content) {
&library_content))
<< user_libraries_iterator->value();
} else {
- ASSERT_TRUE(file_util::ReadFileToString(
- test_data_directory_.Append(*user_libraries_iterator),
- &library_content)) << user_libraries_iterator->value();
+ bool ok = file_util::ReadFileToString(
+ gen_test_data_directory_.Append(*user_libraries_iterator),
+ &library_content);
+ if (!ok) {
+ ok = file_util::ReadFileToString(
+ test_data_directory_.Append(*user_libraries_iterator),
+ &library_content);
+ }
+ ASSERT_TRUE(ok) << user_libraries_iterator->value();
}
utf8_content.append(library_content);
utf8_content.append(";\n");
diff --git a/chrome/browser/ui/webui/web_ui_browsertest.h b/chrome/browser/ui/webui/web_ui_browsertest.h
index e308a2b..99f086a 100644
--- a/chrome/browser/ui/webui/web_ui_browsertest.h
+++ b/chrome/browser/ui/webui/web_ui_browsertest.h
@@ -174,6 +174,9 @@ class WebUIBrowserTest
// Location of test data (currently test/data/webui).
FilePath test_data_directory_;
+ // Location of generated test data (<(PROGRAM_DIR)/test_data).
+ FilePath gen_test_data_directory_;
+
// User added libraries
std::vector<FilePath> user_libraries_;
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index bc8ee41..b07f990 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2232,12 +2232,13 @@
# Executable that runs each browser test in a new process.
'target_name': 'browser_tests',
'type': 'executable',
+ 'msvs_cygwin_shell': 0,
+ 'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
'variables': {
'gypv8sh': '../tools/gypv8sh.py',
'js2webui': 'browser/ui/webui/javascript2webui.js',
'js2webui_out_dir': '<(SHARED_INTERMEDIATE_DIR)/js2webui',
'mock_js': 'third_party/mock4js/mock4js.js',
- 'rule_input_relpath': 'test/data/webui',
'test_api_js': 'test/data/webui/test_api.js',
},
'dependencies': [
@@ -2508,6 +2509,7 @@
'browser/ui/webui/bidi_checker_web_ui_test.cc',
'browser/ui/webui/bidi_checker_web_ui_test.h',
'browser/ui/webui/net_internals_ui_browsertest.cc',
+ 'browser/ui/webui/options/options_browsertest.js',
'browser/ui/webui/web_ui_browsertest.cc',
'browser/ui/webui/web_ui_browsertest.h',
'browser/ui/webui/web_ui_test_handler.cc',
@@ -2537,7 +2539,6 @@
'test/data/webui/certificate_viewer_dialog_test.js',
'test/data/webui/certificate_viewer_ui_test-inl.h',
'test/data/webui/ntp4.js',
- 'test/data/webui/options.js',
'test/data/webui/print_preview.js',
# TODO(craig): Rename this and run from base_unittests when the test
# is safe to run there. See http://crbug.com/78722 for details.
@@ -2567,6 +2568,7 @@
{
'rule_name': 'js2webui',
'extension': 'js',
+ 'msvs_external_rule': 1,
'inputs': [
'<(gypv8sh)',
'<(PRODUCT_DIR)/v8_shell<(EXECUTABLE_SUFFIX)',
@@ -2575,11 +2577,16 @@
'<(js2webui)',
],
'outputs': [
- '<(js2webui_out_dir)/chrome/<(rule_input_relpath)/<(RULE_INPUT_ROOT).cc',
+ '<(js2webui_out_dir)/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).cc',
+ '<(PRODUCT_DIR)/test_data/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
],
'process_outputs_as_sources': 1,
'action': [
- 'python', '<@(_inputs)', '<(RULE_INPUT_PATH)', '<@(_outputs)',
+ 'python',
+ '<@(_inputs)',
+ '<(RULE_INPUT_PATH)',
+ 'chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
+ '<@(_outputs)',
],
},
],
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index cfd6058..eff54b3 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -280,13 +280,20 @@ bool PathProvider(int key, FilePath* result) {
// The following are only valid in the development environment, and
// will fail if executed from an installed executable (because the
// generated path won't exist).
+ case chrome::DIR_GEN_TEST_DATA:
+ if (!PathService::Get(base::DIR_MODULE, &cur))
+ return false;
+ cur = cur.Append(FILE_PATH_LITERAL("test_data"));
+ if (!file_util::PathExists(cur)) // We don't want to create this.
+ return false;
+ break;
case chrome::DIR_TEST_DATA:
if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("chrome"));
cur = cur.Append(FILE_PATH_LITERAL("test"));
cur = cur.Append(FILE_PATH_LITERAL("data"));
- if (!file_util::PathExists(cur)) // we don't want to create this
+ if (!file_util::PathExists(cur)) // We don't want to create this.
return false;
break;
case chrome::DIR_TEST_TOOLS:
@@ -295,7 +302,7 @@ bool PathProvider(int key, FilePath* result) {
cur = cur.Append(FILE_PATH_LITERAL("chrome"));
cur = cur.Append(FILE_PATH_LITERAL("tools"));
cur = cur.Append(FILE_PATH_LITERAL("test"));
- if (!file_util::PathExists(cur)) // we don't want to create this
+ if (!file_util::PathExists(cur)) // We don't want to create this
return false;
break;
#if defined(OS_POSIX) && !defined(OS_MACOSX)
@@ -317,7 +324,7 @@ bool PathProvider(int key, FilePath* result) {
if (!login)
return false;
cur = cur.AppendASCII(login);
- if (!file_util::PathExists(cur)) // we don't want to create this
+ if (!file_util::PathExists(cur)) // We don't want to create this.
return false;
break;
}
diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h
index 5e7f4b7..b3b6877 100644
--- a/chrome/common/chrome_paths.h
+++ b/chrome/common/chrome_paths.h
@@ -96,6 +96,7 @@ enum {
#endif
// Valid only in development environment; TODO(darin): move these
+ DIR_GEN_TEST_DATA, // Directory where generated test data resides.
DIR_TEST_DATA, // Directory where unit test data resides.
DIR_TEST_TOOLS, // Directory where unit test tools reside.