summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 21:13:54 +0000
committerevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 21:13:54 +0000
commit5e767712d2ebec5966472021c90f9700a8a6eda1 (patch)
tree4a72db9d768a5c5390654473f6036096db1db8f2 /chrome/test
parentb8a0e36face3f8835bbf2efeb97502bc9bb50a1e (diff)
downloadchromium_src-5e767712d2ebec5966472021c90f9700a8a6eda1.zip
chromium_src-5e767712d2ebec5966472021c90f9700a8a6eda1.tar.gz
chromium_src-5e767712d2ebec5966472021c90f9700a8a6eda1.tar.bz2
Butcher some files to make ui_tests run 0 tests on Linux.
Review URL: http://codereview.chromium.org/16545 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/ui/ui_test.cc77
-rw-r--r--chrome/test/ui/ui_test.h41
-rw-r--r--chrome/test/ui/ui_test_suite.h4
-rw-r--r--chrome/test/ui/ui_tests.scons45
4 files changed, 137 insertions, 30 deletions
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index e1bea1b..4963a87 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -10,6 +10,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/file_util.h"
+#include "base/platform_thread.h"
#include "base/process_util.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
@@ -19,19 +20,29 @@
#include "chrome/browser/url_fixer_upper.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_process_filter.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/debug_flags.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/json_value_serializer.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/net_util.h"
+
+#if defined(OS_WIN)
+// TODO(port): these just need to be ported.
+#include "chrome/common/chrome_process_filter.h"
#include "chrome/test/automation/browser_proxy.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/automation/window_proxy.h"
-#include "googleurl/src/gurl.h"
-#include "net/base/net_util.h"
+#endif
using base::TimeTicks;
+// Delay to let browser complete a requested action.
+const int UITest::kWaitForActionMsec = 2000;
+const int UITest::kWaitForActionMaxMsec = 10000;
+// Delay to let the browser complete the test.
+const int UITest::kMaxTestExecutionTime = 30000;
+
const wchar_t UITest::kFailedNoCrashService[] =
L"NOTE: This test is expected to fail if crash_service.exe is not "
L"running. Start it manually before running this test (see the build "
@@ -73,7 +84,7 @@ bool UITest::DieFileDie(const std::wstring& file, bool recurse) {
for (int i = 0; i < 10; ++i) {
if (file_util::Delete(file, recurse))
return true;
- Sleep(kWaitForActionMaxMsec / 10);
+ PlatformThread::Sleep(kWaitForActionMaxMsec / 10);
}
return false;
}
@@ -82,10 +93,10 @@ UITest::UITest()
: testing::Test(),
expected_errors_(0),
expected_crashes_(0),
- wait_for_initial_loads_(true),
homepage_(L"about:blank"),
+ wait_for_initial_loads_(true),
dom_automation_enabled_(false),
- process_(NULL),
+ process_(0), // NULL on Windows, 0 PID on POSIX.
show_window_(false),
clear_profile_(true),
include_testing_id_(true),
@@ -95,7 +106,11 @@ UITest::UITest()
action_max_timeout_ms_(kWaitForActionMaxMsec) {
PathService::Get(chrome::DIR_APP, &browser_directory_);
PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_);
+#if defined(OS_WIN)
GetSystemTimeAsFileTime(&test_start_time_);
+#else
+ NOTIMPLEMENTED();
+#endif
}
void UITest::SetUp() {
@@ -118,7 +133,7 @@ void UITest::TearDown() {
// If there were errors, get all the error strings for display.
std::wstring failures =
L"The following error(s) occurred in the application during this test:";
- if (static_cast<int>(assertions.size()) > expected_errors_) {
+ if (assertions.size() > expected_errors_) {
logging::AssertionList::const_iterator iter = assertions.begin();
for (; iter != assertions.end(); ++iter) {
failures.append(L"\n\n");
@@ -127,6 +142,7 @@ void UITest::TearDown() {
}
EXPECT_EQ(expected_errors_, assertions.size()) << failures;
+#if defined(OS_WIN)
// Check for crashes during the test
std::wstring crash_dump_path;
PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path);
@@ -140,6 +156,10 @@ void UITest::TearDown() {
error_msg += kFailedNoCrashService;
}
EXPECT_EQ(expected_crashes_, actual_crashes) << error_msg;
+#else
+ // TODO(port): we don't catch crashes, nor have CountFilesCreatedAfter.
+ NOTIMPLEMENTED();
+#endif
}
// Pick up the various test time out values from the command line.
@@ -165,6 +185,7 @@ void UITest::InitializeTimeouts() {
}
void UITest::LaunchBrowserAndServer() {
+#if defined(OS_WIN)
// Set up IPC testing interface server.
server_.reset(new AutomationProxy(command_execution_timeout_ms_));
@@ -175,14 +196,23 @@ void UITest::LaunchBrowserAndServer() {
Sleep(2000);
automation()->SetFilteredInet(true);
+#else
+ // TODO(port): depends on AutomationProxy.
+ NOTIMPLEMENTED();
+#endif
}
void UITest::CloseBrowserAndServer() {
QuitBrowser();
CleanupAppProcesses();
+#if defined(OS_WIN)
// Shut down IPC testing interface.
server_.reset();
+#else
+ // TODO(port): depends on AutomationProxy.
+ NOTIMPLEMENTED();
+#endif
}
void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) {
@@ -203,6 +233,7 @@ void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) {
CommandLine::AppendSwitch(&command_line,
switches::kDomAutomationController);
+#if defined(OS_WIN)
if (include_testing_id_) {
if (use_existing_browser_) {
// TODO(erikkay): The new switch depends on a browser instance already
@@ -219,6 +250,10 @@ void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) {
server_->channel_id());
}
}
+#else
+ // TODO(port): depends on AutomationProxy.
+ NOTIMPLEMENTED();
+#endif
if (!show_error_dialogs_)
CommandLine::AppendSwitch(&command_line, switches::kNoErrorDialogs);
@@ -277,6 +312,7 @@ void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) {
if (clear_profile)
ASSERT_TRUE(DieFileDie(user_data_dir_, true));
+#if defined(OS_WIN)
if (!template_user_data_.empty()) {
// Recursively copy the template directory to the user_data_dir.
ASSERT_TRUE(file_util::CopyRecursiveDirNoCache(template_user_data_,
@@ -302,9 +338,16 @@ void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) {
CloseHandle(process_);
process_ = OpenProcess(SYNCHRONIZE, false, pid);
}
+#else
+ // TODO(port): above code is very Windows-specific; we need to
+ // figure out and abstract out how we'll handle finding any existing
+ // running process, etc. on other platforms.
+ NOTIMPLEMENTED();
+#endif
}
void UITest::QuitBrowser() {
+#if defined(OS_WIN)
typedef std::vector<BrowserProxy*> BrowserVector;
// There's nothing to do here if the browser is not running.
@@ -350,13 +393,23 @@ void UITest::QuitBrowser() {
// Don't forget to close the handle
CloseHandle(process_);
process_ = NULL;
+#else
+ // TODO(port): depends on AutomationProxy.
+ NOTIMPLEMENTED();
+#endif // OS_WIN
}
void UITest::AssertAppNotRunning(const std::wstring& error_message) {
+#if defined(OS_WIN)
ASSERT_EQ(0, GetBrowserProcessCount()) << error_message;
+#else
+ // TODO(port): depends on AutomationProxy.
+ NOTIMPLEMENTED();
+#endif
}
void UITest::CleanupAppProcesses() {
+#if defined(OS_WIN)
BrowserProcessFilter filter(L"");
// Make sure that no instances of the browser remain.
@@ -372,8 +425,16 @@ void UITest::CleanupAppProcesses() {
if (!in_process_renderer_) {
AssertAppNotRunning(L"Unable to quit all browser processes.");
}
+#else
+ // TODO(port): depends on BrowserProcessFilter.
+ NOTIMPLEMENTED();
+#endif
}
+// TODO(port): this #if effectively cuts out half of this file on
+// non-Windows platforms, and is a temporary hack to get things
+// building.
+#if defined(OS_WIN)
TabProxy* UITest::GetActiveTab() {
scoped_ptr<BrowserProxy> window_proxy(automation()->GetBrowserWindow(0));
if (!window_proxy.get())
@@ -719,3 +780,5 @@ void UITest::PrintResultsImpl(const std::wstring& measurement,
trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(),
units.c_str());
}
+
+#endif // OS_WIN
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 8601bb8..1a355bf 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -17,15 +17,28 @@
// Tests which need to launch the browser with a particular set of command-line
// arguments should set the value of launch_arguments_ in their constructors.
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
#include <windows.h>
+#endif
#include <string>
+#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/process.h"
#include "base/scoped_ptr.h"
#include "base/time.h"
+#if defined(OS_WIN)
+// TODO(evanm): we should be able to just forward-declare
+// AutomationProxy here, but many files that #include this one don't
+// themselves #include automation_proxy.h.
#include "chrome/test/automation/automation_proxy.h"
+#endif
#include "testing/gtest/include/gtest/gtest.h"
+class AutomationProxy;
+class BrowserProxy;
class DictionaryValue;
class GURL;
class TabProxy;
@@ -33,10 +46,10 @@ class TabProxy;
class UITest : public testing::Test {
protected:
// Delay to let browser complete a requested action.
- static const int kWaitForActionMsec = 2000;
- static const int kWaitForActionMaxMsec = 10000;
+ static const int kWaitForActionMsec;
+ static const int kWaitForActionMaxMsec;
// Delay to let the browser complete the test.
- static const int kMaxTestExecutionTime = 30000;
+ static const int kMaxTestExecutionTime;
// String to display when a test fails because the crash service isn't
// running.
@@ -205,7 +218,7 @@ class UITest : public testing::Test {
// Get the handle of browser process connected to the automation. This
// function only retruns a reference to the handle so the caller does not
// own the handle returned.
- HANDLE process() { return process_; }
+ base::ProcessHandle process() { return process_; }
public:
// Get/Set a flag to run the renderer in process when running the
@@ -351,8 +364,14 @@ class UITest : public testing::Test {
protected:
AutomationProxy* automation() {
+#if defined(OS_WIN)
EXPECT_TRUE(server_.get());
return server_.get();
+#else
+ // TODO(port): restore when AutomationProxy bits work.
+ NOTIMPLEMENTED();
+ return NULL;
+#endif
}
// Wait a certain amount of time for all the app processes to exit,
@@ -373,7 +392,7 @@ class UITest : public testing::Test {
std::wstring test_data_directory_; // Path to the unit test data,
// with no trailing slash
std::wstring launch_arguments_; // Arguments to the browser on launch.
- int expected_errors_; // The number of errors expected during
+ size_t expected_errors_; // The number of errors expected during
// the run (generally 0).
int expected_crashes_; // The number of crashes expected during
// the run (generally 0).
@@ -384,7 +403,7 @@ class UITest : public testing::Test {
bool dom_automation_enabled_; // This can be set to true to have the
// test run the dom automation case.
std::wstring template_user_data_; // See set_template_user_data().
- HANDLE process_; // Handle the the first Chrome process.
+ base::ProcessHandle process_; // Handle to the first Chrome process.
std::wstring user_data_dir_; // User data directory used for the test
static bool in_process_renderer_; // true if we're in single process mode
bool show_window_; // Determines if the window is shown or
@@ -398,8 +417,13 @@ class UITest : public testing::Test {
// Default value comes from static.
private:
+#if defined(OS_WIN)
+ // TODO(port): make this use base::Time instead. It would seem easy, but
+ // the code also depends on file_util::CountFilesCreatedAfter which hasn't
+ // yet been made portable.
FILETIME test_start_time_; // Time the test was started
// (so we can check for new crash dumps)
+#endif
static bool in_process_plugins_;
static bool no_sandbox_;
static bool safe_plugins_;
@@ -417,7 +441,10 @@ class UITest : public testing::Test {
static int timeout_ms_; // Timeout in milliseconds to wait
// for an test to finish.
static std::wstring js_flags_; // Flags passed to the JS engine.
- ::scoped_ptr<AutomationProxy> server_;
+#if defined(OS_WIN)
+ // TODO(port): restore me after AutomationProxy works.
+ scoped_ptr<AutomationProxy> server_;
+#endif
MessageLoop message_loop_; // Enables PostTask to main thread.
diff --git a/chrome/test/ui/ui_test_suite.h b/chrome/test/ui/ui_test_suite.h
index e2976412e..b3d609f 100644
--- a/chrome/test/ui/ui_test_suite.h
+++ b/chrome/test/ui/ui_test_suite.h
@@ -42,7 +42,7 @@ class UITestSuite : public ChromeTestSuite {
std::wstring test_timeout =
parsed_command_line.GetSwitchValue(UITestSuite::kTestTimeout);
if (!test_timeout.empty()) {
- UITest::set_test_timeout_ms(_wtoi(test_timeout.c_str()));
+ UITest::set_test_timeout_ms(StringToInt(test_timeout));
}
std::wstring js_flags =
parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags);
@@ -52,7 +52,9 @@ class UITestSuite : public ChromeTestSuite {
}
virtual void SuppressErrorDialogs() {
+#if defined(OS_WIN)
TestSuite::SuppressErrorDialogs();
+#endif
UITest::set_show_error_dialogs(false);
}
diff --git a/chrome/test/ui/ui_tests.scons b/chrome/test/ui/ui_tests.scons
index 0654579..cdd9367 100644
--- a/chrome/test/ui/ui_tests.scons
+++ b/chrome/test/ui/ui_tests.scons
@@ -34,18 +34,27 @@ env.Prepend(
'UI_TEST',
],
LIBS = [
- 'automation',
'browser',
- 'browser_views',
'common',
- 'npapi_layout_test_plugin',
- 'npapi_test_plugin',
- 'port',
- 'security_tests',
- ],
+ 'sqlite',
+ ]
)
if env.Bit('windows'):
+ # TODO(port): split these into upper env.Prepend (for portable libs) and
+ # lower env.Prepend (for win-specific libs).
+ env.Prepend(
+ LIBS = [
+ 'automation',
+ 'browser_views',
+ 'npapi_layout_test_plugin',
+ 'npapi_test_plugin',
+ 'port',
+ 'security_tests',
+ ],
+ )
+
+if env.Bit('windows'):
env.Prepend(
CPPPATH = [
'$CHROME_DIR/tools/build/win',
@@ -76,16 +85,22 @@ if env.Bit('windows'):
)
ui_test_files = [
- 'inspector_controller_uitest.cc',
- 'layout_plugin_uitest.cpp',
- 'npapi_uitest.cpp',
- 'omnibox_uitest.cc',
'run_all_unittests.cc',
- 'sandbox_uitests.cc',
'ui_test.cc',
'ui_test_suite.cc',
+]
+
+if env.Bit('windows'):
+ # TODO(port): mark which of these work and which don't.
+ ui_test_files.extend([
'history_uitest.cc',
+ 'inspector_controller_uitest.cc',
+ 'layout_plugin_uitest.cpp',
'npapi_test_helper.cc',
+ 'npapi_uitest.cpp',
+ 'omnibox_uitest.cc',
+
+ 'sandbox_uitests.cc',
'$CHROME_DIR/app/chrome_main_uitest.cc',
'$CHROME_DIR/browser/browser_uitest.cc',
@@ -121,15 +136,15 @@ ui_test_files = [
'$CHROME_DIR/test/perf/mem_usage.cc',
'$CHROME_DIR/test/reliability/page_load_test$OBJSUFFIX',
'$NET_DIR/url_request/url_request_test_job$OBJSUFFIX',
-]
+ ])
-if env.Bit('windows'):
+ # Windows-specific tests.
ui_test_files.extend([
'$CHROME_DIR/browser/views/find_bar_win_interactive_uitest.cc',
'$CHROME_DIR/browser/views/find_bar_win_uitest.cc',
])
- env.ChromeTestProgram('ui_tests', ui_test_files)
+env.ChromeTestProgram('ui_tests', ui_test_files)
env.ChromeMSVSProject('$CHROME_DIR/test/ui/ui_tests.vcproj',
dependencies = [