summaryrefslogtreecommitdiffstats
path: root/chrome/test/ui
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test/ui')
-rw-r--r--chrome/test/ui/ui_test.cc112
-rw-r--r--chrome/test/ui/ui_test.h12
-rw-r--r--chrome/test/ui/ui_tests.scons7
3 files changed, 58 insertions, 73 deletions
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 2ad0952..fdcad82 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -24,13 +24,14 @@
#include "chrome/common/debug_flags.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/json_value_serializer.h"
+#include "chrome/test/automation/automation_proxy.h"
+#include "chrome/test/automation/browser_proxy.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"
#endif
@@ -211,7 +212,6 @@ void UITest::InitializeTimeouts() {
}
void UITest::LaunchBrowserAndServer() {
-#if defined(OS_WIN)
// Set up IPC testing interface server.
server_.reset(new AutomationProxy(command_execution_timeout_ms_));
@@ -219,26 +219,17 @@ void UITest::LaunchBrowserAndServer() {
if (wait_for_initial_loads_)
ASSERT_TRUE(server_->WaitForInitialLoads());
else
- Sleep(2000);
+ PlatformThread::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 CommandLine& arguments, bool clear_profile) {
@@ -265,7 +256,6 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
if (dom_automation_enabled_)
command_line.AppendSwitch(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
@@ -280,10 +270,6 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
server_->channel_id());
}
}
-#else
- // TODO(port): depends on AutomationProxy.
- NOTIMPLEMENTED();
-#endif
if (!show_error_dialogs_ &&
!CommandLine::ForCurrentProcess()->HasSwitch(kEnableErrorDialogs)) {
@@ -346,7 +332,6 @@ void UITest::LaunchBrowser(const CommandLine& 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_,
@@ -355,13 +340,21 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
browser_launch_time_ = TimeTicks::Now();
+#if defined(OS_WIN)
bool started = base::LaunchApp(command_line,
false, // Don't wait for process object
// (doesn't work for us)
!show_window_,
&process_);
- ASSERT_EQ(started, true);
+#elif defined(OS_POSIX)
+ bool started = base::LaunchApp(command_line.argv(),
+ server_->fds_to_map(),
+ false, // Don't wait.
+ &process_);
+#endif
+ ASSERT_TRUE(started);
+#if defined(OS_WIN)
if (use_existing_browser_) {
DWORD pid = 0;
HWND hwnd = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass,
@@ -381,7 +374,6 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
}
void UITest::QuitBrowser() {
-#if defined(OS_WIN)
typedef std::vector<BrowserProxy*> BrowserVector;
// There's nothing to do here if the browser is not running.
@@ -416,7 +408,7 @@ void UITest::QuitBrowser() {
#ifdef WAIT_FOR_DEBUGGER_ON_OPEN
timeout = 500000;
#endif
- if (WAIT_TIMEOUT == WaitForSingleObject(process_, timeout)) {
+ if (!base::WaitForSingleProcess(process_, timeout)) {
// We need to force the browser to quit because it didn't quit fast
// enough. Take no chance and kill every chrome processes.
CleanupAppProcesses();
@@ -424,19 +416,15 @@ void UITest::QuitBrowser() {
}
// Don't forget to close the handle
- CloseHandle(process_);
+ base::CloseProcessHandle(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.
+ // TODO(port): Enable when chrome_process_filter is ported.
NOTIMPLEMENTED();
#endif
}
@@ -570,6 +558,7 @@ std::wstring UITest::GetActiveTabTitle() {
EXPECT_TRUE(tab_proxy->GetTabTitle(&title));
return title;
}
+#endif // defined(OS_WIN)
bool UITest::IsBrowserRunning() {
return CrashAwareSleep(0);
@@ -579,6 +568,9 @@ bool UITest::CrashAwareSleep(int time_out_ms) {
return base::CrashAwareSleep(process_, time_out_ms);
}
+#if defined(OS_WIN)
+// TODO(port): Port these.
+
/*static*/
int UITest::GetBrowserProcessCount() {
BrowserProcessFilter filter(L"");
@@ -724,37 +716,6 @@ bool UITest::CloseBrowser(BrowserProxy* browser,
return result;
}
-void UITest::PrintResult(const std::wstring& measurement,
- const std::wstring& modifier,
- const std::wstring& trace,
- size_t value,
- const std::wstring& units,
- bool important) {
- std::wstring value_str = StringPrintf(L"%d", value);
- PrintResultsImpl(measurement, modifier, trace, value_str,
- L"", L"", units, important);
-}
-
-void UITest::PrintResultMeanAndError(const std::wstring& measurement,
- const std::wstring& modifier,
- const std::wstring& trace,
- const std::wstring& mean_and_error,
- const std::wstring& units,
- bool important) {
- PrintResultsImpl(measurement, modifier, trace, mean_and_error,
- L"{", L"}", units, important);
-}
-
-void UITest::PrintResultList(const std::wstring& measurement,
- const std::wstring& modifier,
- const std::wstring& trace,
- const std::wstring& values,
- const std::wstring& units,
- bool important) {
- PrintResultsImpl(measurement, modifier, trace, values,
- L"[", L"]", units, important);
-}
-
GURL UITest::GetTestUrl(const std::wstring& test_directory,
const std::wstring &test_case) {
std::wstring path;
@@ -791,6 +752,39 @@ void UITest::WaitForFinish(const std::string &name,
EXPECT_EQ(true, test_result);
}
+#endif // OS_WIN
+
+void UITest::PrintResult(const std::wstring& measurement,
+ const std::wstring& modifier,
+ const std::wstring& trace,
+ size_t value,
+ const std::wstring& units,
+ bool important) {
+ std::wstring value_str = StringPrintf(L"%d", value);
+ PrintResultsImpl(measurement, modifier, trace, value_str,
+ L"", L"", units, important);
+}
+
+void UITest::PrintResultMeanAndError(const std::wstring& measurement,
+ const std::wstring& modifier,
+ const std::wstring& trace,
+ const std::wstring& mean_and_error,
+ const std::wstring& units,
+ bool important) {
+ PrintResultsImpl(measurement, modifier, trace, mean_and_error,
+ L"{", L"}", units, important);
+}
+
+void UITest::PrintResultList(const std::wstring& measurement,
+ const std::wstring& modifier,
+ const std::wstring& trace,
+ const std::wstring& values,
+ const std::wstring& units,
+ bool important) {
+ PrintResultsImpl(measurement, modifier, trace, values,
+ L"[", L"]", units, important);
+}
+
void UITest::PrintResultsImpl(const std::wstring& measurement,
const std::wstring& modifier,
const std::wstring& trace,
@@ -807,5 +801,3 @@ 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 a2f1ce8..794391b 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -30,12 +30,10 @@
#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;
@@ -361,14 +359,8 @@ 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,
@@ -438,10 +430,8 @@ class UITest : public testing::Test {
// for an test to finish.
static std::wstring js_flags_; // Flags passed to the JS engine.
static std::wstring log_level_; // Logging level.
-#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_tests.scons b/chrome/test/ui/ui_tests.scons
index ada6b90..9bf717a 100644
--- a/chrome/test/ui/ui_tests.scons
+++ b/chrome/test/ui/ui_tests.scons
@@ -12,6 +12,7 @@ env.SConscript([
'$BZIP2_DIR/using_bzip2.scons',
'$CHROME_DIR/third_party/wtl/using_wtl.scons',
'$CHROME_SRC_DIR/build/using_googleurl.scons',
+ '$CHROME_SRC_DIR/tools/grit/build/using_generated_resources.scons',
'$GTEST_DIR/../using_gtest.scons',
'$ICU38_DIR/using_icu38.scons',
'$LIBPNG_DIR/using_libpng.scons',
@@ -34,9 +35,13 @@ env.Prepend(
'UI_TEST',
],
LIBS = [
+ 'automation',
'browser',
'common',
+ 'glue',
+ 'port',
'sqlite',
+ 'WTF',
]
)
@@ -45,11 +50,9 @@ if env.Bit('windows'):
# lower env.Prepend (for win-specific libs).
env.Prepend(
LIBS = [
- 'automation',
'browser_views',
'npapi_layout_test_plugin',
'npapi_test_plugin',
- 'port',
'security_tests',
],
)