summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-12 16:41:31 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-12 16:41:31 +0000
commit7a38db66bdb64203e1322d777c7384cacd384496 (patch)
treee4baf501bfedd68e9f4e73ee4d5c0f0edfd3fa00 /chrome
parent8175e5a2570636d720e2e1edd84aa9c02938f22d (diff)
downloadchromium_src-7a38db66bdb64203e1322d777c7384cacd384496.zip
chromium_src-7a38db66bdb64203e1322d777c7384cacd384496.tar.gz
chromium_src-7a38db66bdb64203e1322d777c7384cacd384496.tar.bz2
Make the logging dir on mac write outside the bundle in debug, this makes the file easier to find, and for unittests that try to scan it (like tab_switching), they then don't have to walk into the bundle.
Compile tab_switching_test on mac/linux. Add a dep for app to tab_switching_test so building it also make sure the app is built (since it runs the app) Update tab_switching_test Use FilePath in all cases instead of wstring. Limit how long it will spin looking for the log log file so the test can't hang. TEST=the new test is built on mac/linux BUG=none Review URL: http://codereview.chromium.org/126049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18277 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/chrome.gyp82
-rw-r--r--chrome/common/chrome_paths.cc18
-rw-r--r--chrome/test/tab_switching/tab_switching_test.cc33
3 files changed, 82 insertions, 51 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index bcae8f0..e38dd99 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -3534,6 +3534,32 @@
}],
],
},
+ {
+ 'target_name': 'tab_switching_test',
+ 'type': 'executable',
+ 'msvs_guid': 'A34770EA-A574-43E8-9327-F79C04770E98',
+ 'dependencies': [
+ 'test_support_common',
+ 'test_support_ui',
+ 'theme_resources',
+ '../skia/skia.gyp:skia',
+ '../testing/gtest.gyp:gtest',
+ 'app',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'sources': [
+ 'test/tab_switching/tab_switching_test.cc',
+ ],
+ 'conditions': [
+ ['OS=="linux"', {
+ 'dependencies': [
+ '../build/linux/system.gyp:gtk',
+ ],
+ }],
+ ],
+ },
],
'conditions': [
# We set feature variables so the different parts that need to check for
@@ -3722,14 +3748,14 @@
'test/browser/run_all_unittests.cc',
'test/in_process_browser_test.cc',
'test/in_process_browser_test.h',
- 'test/browser/browser_test_launcher_out_of_proc.cc',
- 'test/browser/browser_test_runner.cc',
- 'test/browser/browser_test_runner.h',
+ 'test/browser/browser_test_launcher_out_of_proc.cc',
+ 'test/browser/browser_test_runner.cc',
+ 'test/browser/browser_test_runner.h',
'test/unit/chrome_test_suite.h',
'test/ui_test_utils.cc',
- # browser_tests_sources is defined in 'variables' at the top of the
- # file.
- '<@(browser_tests_sources)',
+ # browser_tests_sources is defined in 'variables' at the top of the
+ # file.
+ '<@(browser_tests_sources)',
],
'conditions': [
@@ -4070,7 +4096,7 @@
},
},
'sources': [
- 'test/browser/run_all_unittests.cc',
+ 'test/browser/run_all_unittests.cc',
'test/in_process_browser_test.cc',
'test/in_process_browser_test.h',
'test/unit/chrome_test_suite.h',
@@ -4083,10 +4109,10 @@
'<(SHARED_INTERMEDIATE_DIR)/chrome/browser_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/chrome_dll_version/chrome_dll_version.rc',
'<(SHARED_INTERMEDIATE_DIR)/chrome/common_resources.rc',
- # browser_tests_sources and browser_tests_source_win_specific are
- # defined in 'variables' at the top of the file.
- '<@(browser_tests_sources)',
- '<@(browser_tests_sources_win_specific)',
+ # browser_tests_sources and browser_tests_source_win_specific are
+ # defined in 'variables' at the top of the file.
+ '<@(browser_tests_sources)',
+ '<@(browser_tests_sources_win_specific)',
],
},
{
@@ -4095,20 +4121,20 @@
'type': 'executable',
'msvs_guid': '9B87804D-2502-480B-95AE-5A572CE91809',
'dependencies': [
- 'browser_tests_dll',
+ 'browser_tests_dll',
'../base/base.gyp:base',
],
'include_dirs': [
'..',
],
'sources': [
- 'test/browser/browser_test_launcher_in_proc.cc',
- 'test/browser/browser_test_runner.cc',
- 'test/browser/browser_test_runner.h',
+ 'test/browser/browser_test_launcher_in_proc.cc',
+ 'test/browser/browser_test_runner.cc',
+ 'test/browser/browser_test_runner.h',
],
'msvs_settings': {
'VCLinkerTool': {
- # Use a PDB name different than the one for the DLL.
+ # Use a PDB name different than the one for the DLL.
'ProgramDatabaseFile': '$(OutDir)\\browser_tests_exe.pdb',
},
},
@@ -4352,24 +4378,6 @@
},
},
{
- 'target_name': 'tab_switching_test',
- 'type': 'executable',
- 'msvs_guid': 'A34770EA-A574-43E8-9327-F79C04770E98',
- 'dependencies': [
- 'test_support_common',
- 'test_support_ui',
- 'theme_resources',
- '../skia/skia.gyp:skia',
- '../testing/gtest.gyp:gtest',
- ],
- 'include_dirs': [
- '..',
- ],
- 'sources': [
- 'test/tab_switching/tab_switching_test.cc',
- ],
- },
- {
'target_name': 'test_chrome_plugin',
'type': 'shared_library',
'msvs_guid': '7F0A70F6-BE3F-4C19-B435-956AB8F30BA4',
@@ -4491,14 +4499,14 @@
# In gyp, booleans are 0/1 not True/False.
'suppress_wildcard': 1,
'type': 'none',
- # If you add new tests here you may need to update the croc configs.
- # E.g. build/{linux|mac}/chrome_linux.croc
+ # If you add new tests here you may need to update the croc configs.
+ # E.g. build/{linux|mac}/chrome_linux.croc
'dependencies': [
'../base/base.gyp:base_unittests',
'../media/media.gyp:media_unittests',
'../net/net.gyp:net_unittests',
'../printing/printing.gyp:printing_unittests',
- 'unit_tests',
+ 'unit_tests',
],
'actions': [
{
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index 4645346..f8188c2 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -8,6 +8,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/mac_util.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/sys_info.h"
@@ -42,8 +43,23 @@ bool PathProvider(int key, FilePath* result) {
return PathService::Get(chrome::DIR_USER_DATA, result);
#else
// Debug builds write next to the binary (in the build tree)
+#if defined(OS_MACOSX)
+ if (!PathService::Get(base::DIR_EXE, result))
+ return false;
+ if (mac_util::AmIBundled()) {
+ // If we're called from chrome, dump it beside the app (outside the
+ // app bundle), if we're called from a unittest, we'll already
+ // outside the bundle so use the exe dir.
+ // exe_dir gave us .../Chromium.app/Contents/MacOS/Chromium.
+ *result = result->DirName();
+ *result = result->DirName();
+ *result = result->DirName();
+ }
+ return true;
+#else
return PathService::Get(base::DIR_EXE, result);
-#endif
+#endif // defined(OS_MACOSX)
+#endif // NDEBUG
case chrome::FILE_RESOURCE_MODULE:
return PathService::Get(base::FILE_MODULE, result);
}
diff --git a/chrome/test/tab_switching/tab_switching_test.cc b/chrome/test/tab_switching/tab_switching_test.cc
index 91423a6..876dd87 100644
--- a/chrome/test/tab_switching/tab_switching_test.cc
+++ b/chrome/test/tab_switching/tab_switching_test.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/platform_thread.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -28,11 +30,10 @@ class TabSwitchingUITest : public UITest {
public:
TabSwitchingUITest() {
PathService::Get(base::DIR_EXE, &path_prefix_);
- file_util::UpOneDirectory(&path_prefix_);
- file_util::UpOneDirectory(&path_prefix_);
- file_util::AppendToPath(&path_prefix_, L"data");
- file_util::AppendToPath(&path_prefix_, L"tab_switching");
- path_prefix_ += FilePath::kSeparators[0];
+ path_prefix_ = path_prefix_.DirName();
+ path_prefix_ = path_prefix_.DirName();
+ path_prefix_ = path_prefix_.AppendASCII("data");
+ path_prefix_ = path_prefix_.AppendASCII("tab_switching");
show_window_ = true;
}
@@ -63,16 +64,20 @@ class TabSwitchingUITest : public UITest {
// Now open the corresponding log file and collect average and std dev from
// the histogram stats generated for RenderWidgetHostHWND_WhiteoutDuration
- std::wstring log_file_name;
+ FilePath log_file_name;
PathService::Get(chrome::DIR_LOGS, &log_file_name);
- file_util::AppendToPath(&log_file_name, L"chrome_debug.log");
+ log_file_name = log_file_name.AppendASCII("chrome_debug.log");
bool log_has_been_dumped = false;
std::string contents;
+ int max_tries = 20;
do {
log_has_been_dumped = file_util::ReadFileToString(log_file_name,
&contents);
- } while (!log_has_been_dumped);
+ if (!log_has_been_dumped)
+ PlatformThread::Sleep(100);
+ } while (!log_has_been_dumped && max_tries--);
+ ASSERT_TRUE(log_has_been_dumped) << "Failed to read the log file";
// Parse the contents to get average and std deviation.
std::string average("0.0"), std_dev("0.0");
@@ -96,6 +101,8 @@ class TabSwitchingUITest : public UITest {
comma_pos = contents.find(" ", pos);
number_length = comma_pos - pos;
std_dev = contents.substr(pos, number_length);
+ } else {
+ LOG(WARNING) << "Histogram: MPArch.RWHH_WhiteoutDuration wasn't found";
}
// Print the average and standard deviation.
@@ -115,8 +122,8 @@ class TabSwitchingUITest : public UITest {
"126.com", "www.altavista.com"};
int number_of_new_tabs_opened = 0;
FilePath file_name;
- for (int i = 0; i < arraysize(files); ++i) {
- file_name = FilePath::FromWStringHack(path_prefix_);
+ for (size_t i = 0; i < arraysize(files); ++i) {
+ file_name = path_prefix_;
file_name = file_name.AppendASCII(files[i]);
file_name = file_name.AppendASCII("index.html");
browser_proxy_->AppendTab(net::FilePathToFileURL(file_name));
@@ -126,7 +133,7 @@ class TabSwitchingUITest : public UITest {
return number_of_new_tabs_opened;
}
- std::wstring path_prefix_;
+ FilePath path_prefix_;
int number_of_tabs_to_open_;
scoped_refptr<BrowserProxy> browser_proxy_;
@@ -134,8 +141,8 @@ class TabSwitchingUITest : public UITest {
DISALLOW_EVIL_CONSTRUCTORS(TabSwitchingUITest);
};
-} // namespace
-
TEST_F(TabSwitchingUITest, GenerateTabSwitchStats) {
RunTabSwitchingUITest();
}
+
+} // namespace