summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 22:06:22 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 22:06:22 +0000
commit50613309535025abb3bb030d5f13fac2fff235c6 (patch)
tree987484cd98074d92b5a4a7876bd1928bd643c7f7 /chrome/test
parentd5c4f386029ab19cec0f4d76bede0c4d2975d431 (diff)
downloadchromium_src-50613309535025abb3bb030d5f13fac2fff235c6.zip
chromium_src-50613309535025abb3bb030d5f13fac2fff235c6.tar.gz
chromium_src-50613309535025abb3bb030d5f13fac2fff235c6.tar.bz2
Converted the browser focus interactive ui tests to be in process.
Some testing I did as part of my in-progress focus refactoring seemed to indicate they are flacky. With this CL, they now mostly use the blocking calls when simulating UI actions (instead of relying on timers). BUG=None TEST=Run the tests BrowserFocusTest.* in the interactive tests. Review URL: http://codereview.chromium.org/27083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10295 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/in_process_browser_test.cc16
-rw-r--r--chrome/test/in_process_browser_test.h14
-rw-r--r--chrome/test/interactive_ui/interactive_ui.vcproj110
-rw-r--r--chrome/test/ui_test_utils.cc4
-rw-r--r--chrome/test/unit/chrome_test_suite.h4
5 files changed, 141 insertions, 7 deletions
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index dd1f919..aae695b 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/profile_manager.h"
+#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
@@ -43,7 +44,10 @@ bool DieFileDie(const std::wstring& file, bool recurse) {
} // namespace
-InProcessBrowserTest::InProcessBrowserTest() : browser_(NULL) {
+InProcessBrowserTest::InProcessBrowserTest()
+ : browser_(NULL),
+ show_window_(false),
+ dom_automation_enabled_(false) {
}
void InProcessBrowserTest::SetUp() {
@@ -68,15 +72,23 @@ void InProcessBrowserTest::SetUp() {
CommandLine* command_line = CommandLine::ForCurrentProcessMutable();
// Hide windows on show.
- if (!command_line->HasSwitch(kUnitTestShowWindows))
+ if (!command_line->HasSwitch(kUnitTestShowWindows) && !show_window_)
BrowserView::SetShowState(SW_HIDE);
+ if (dom_automation_enabled_)
+ command_line->AppendSwitch(switches::kDomAutomationController);
+
command_line->AppendSwitchWithValue(switches::kUserDataDir, user_data_dir);
// For some reason the sandbox wasn't happy running in test mode. These
// tests aren't intended to test the sandbox, so we turn it off.
command_line->AppendSwitch(switches::kNoSandbox);
+ // Single-process mode is not set in BrowserMain so it needs to be processed
+ // explicitlty.
+ if (command_line->HasSwitch(switches::kSingleProcess))
+ RenderProcessHost::set_run_renderer_in_process(true);
+
// Explicitly set the path of the exe used for the renderer, otherwise it'll
// try to use unit_test.exe.
std::wstring renderer_path;
diff --git a/chrome/test/in_process_browser_test.h b/chrome/test/in_process_browser_test.h
index 230b8df..90dcdc9 100644
--- a/chrome/test/in_process_browser_test.h
+++ b/chrome/test/in_process_browser_test.h
@@ -5,7 +5,6 @@
#ifndef CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_
#define CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_
-#include "chrome/app/scoped_ole_initializer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_observer.h"
#include "net/url_request/url_request_unittest.h"
@@ -74,6 +73,11 @@ class InProcessBrowserTest : public testing::Test, public NotificationObserver {
// This is invoked from Setup.
virtual Browser* CreateBrowser(Profile* profile);
+ // Sets some test states (see below for comments). Call this in your test
+ // constructor.
+ void set_show_window(bool show) { show_window_ = show; }
+ void EnableDOMAutomation() { dom_automation_enabled_ = true; }
+
private:
// Invokes CreateBrowser to create a browser, then RunTestOnMainThread, and
// destroys the browser.
@@ -88,7 +92,13 @@ class InProcessBrowserTest : public testing::Test, public NotificationObserver {
// HTTPServer, created when StartHTTPServer is invoked.
scoped_refptr<HTTPTestServer> http_server_;
- ScopedOleInitializer ole_initializer_;
+ // Whether this test requires the browser windows to be shown (interactive
+ // tests for example need the windows shown).
+ bool show_window_;
+
+ // Whether the JavaScript can access the DOMAutomationController (a JS object
+ // that can send messages back to the browser).
+ bool dom_automation_enabled_;
DISALLOW_COPY_AND_ASSIGN(InProcessBrowserTest);
};
diff --git a/chrome/test/interactive_ui/interactive_ui.vcproj b/chrome/test/interactive_ui/interactive_ui.vcproj
index a4863ee..5047175 100644
--- a/chrome/test/interactive_ui/interactive_ui.vcproj
+++ b/chrome/test/interactive_ui/interactive_ui.vcproj
@@ -12,12 +12,16 @@
/>
</Platforms>
<ToolFiles>
+ <ToolFile
+ RelativePath="..\..\tools\build\win\version.rules"
+ />
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
ConfigurationType="1"
- InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;..\..\tools\build\win\precompiled_wtl.vsprops;..\..\tools\build\win\unit_test.vsprops;$(SolutionDir)..\third_party\libpng\using_libpng.vsprops;$(SolutionDir)..\third_party\zlib\using_zlib.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\third_party\libxml\build\using_libxml.vsprops;..\..\..\third_party\icu38\build\using_icu.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops;..\..\third_party\hunspell\using_hunspell.vsprops"
+ InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;..\..\tools\build\win\precompiled_wtl.vsprops;..\..\tools\build\win\unit_test.vsprops;$(SolutionDir)..\third_party\libpng\using_libpng.vsprops;$(SolutionDir)..\third_party\zlib\using_zlib.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\third_party\libxml\build\using_libxml.vsprops;$(SolutionDir)..\third_party\icu38\build\using_icu.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops;..\..\third_party\hunspell\using_hunspell.vsprops;..\..\installer\util\using_util.vsprops;..\..\..\third_party\npapi\using_npapi.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
@@ -26,6 +30,9 @@
Name="VCCustomBuildTool"
/>
<Tool
+ Name="Version"
+ />
+ <Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
@@ -42,12 +49,14 @@
/>
<Tool
Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(SolutionDir)..;&quot;$(IntDir)&quot;;&quot;$(IntDir)&quot;;&quot;$(SolutionDir)&quot;;&quot;$(IntDir)\..\&quot;"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
/>
<Tool
Name="VCALinkTool"
@@ -86,6 +95,9 @@
Name="VCCustomBuildTool"
/>
<Tool
+ Name="Version"
+ />
+ <Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
@@ -143,6 +155,14 @@
Name="Common"
>
<File
+ RelativePath="..\in_process_browser_test.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\in_process_browser_test.h"
+ >
+ </File>
+ <File
RelativePath="..\ui\npapi_test_helper.cc"
>
</File>
@@ -191,6 +211,14 @@
>
</File>
<File
+ RelativePath="..\ui_test_utils.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\ui_test_utils.h"
+ >
+ </File>
+ <File
RelativePath=".\view_event_test_base.cc"
>
</File>
@@ -200,6 +228,86 @@
</File>
</Filter>
<Filter
+ Name="resources"
+ >
+ <File
+ RelativePath="..\..\..\webkit\glue\resources\aliasb.cur"
+ >
+ </File>
+ <File
+ RelativePath="$(OutDir)\grit_derived_sources\browser_resources.rc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\webkit\glue\resources\cell.cur"
+ >
+ </File>
+ <File
+ RelativePath="..\..\app\chrome_dll.rc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\app\chrome_dll_resource.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\app\chrome_dll_version.rc.version"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\webkit\glue\resources\col_resize.cur"
+ >
+ </File>
+ <File
+ RelativePath="$(OutDir)\grit_derived_sources\common_resources.rc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\webkit\glue\resources\copy.cur"
+ >
+ </File>
+ <File
+ RelativePath="$(OutDir)\grit_derived_sources\debugger_resources.rc"
+ >
+ </File>
+ <File
+ RelativePath="$(OutDir)\grit_derived_sources\net_resources.rc"
+ >
+ </File>
+ <File
+ RelativePath="$(OutDir)\grit_derived_sources\renderer_resources.rc"
+ >
+ </File>
+ <File
+ RelativePath="..\data\resource.h"
+ >
+ </File>
+ <File
+ RelativePath="..\data\resource.rc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\webkit\glue\resources\row_resize.cur"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\webkit\glue\resources\vertical_text.cur"
+ >
+ </File>
+ <File
+ RelativePath="$(OutDir)\grit_derived_sources\webkit_resources.rc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\webkit\glue\resources\zoom_in.cur"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\webkit\glue\resources\zoom_out.cur"
+ >
+ </File>
+ </Filter>
+ <Filter
Name="TestBookmarkBarView"
>
<File
diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc
index 1293f72..7471711 100644
--- a/chrome/test/ui_test_utils.cc
+++ b/chrome/test/ui_test_utils.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
+#include "chrome/views/accelerator_handler.h"
#include "googleurl/src/gurl.h"
namespace ui_test_utils {
@@ -59,7 +60,8 @@ void RunMessageLoop() {
MessageLoopForUI* loop = MessageLoopForUI::current();
bool did_allow_task_nesting = loop->NestableTasksAllowed();
loop->SetNestableTasksAllowed(true);
- loop->Run(NULL);
+ views::AcceleratorHandler handler;
+ loop->Run(&handler);
loop->SetNestableTasksAllowed(did_allow_task_nesting);
}
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index 79c5e19..3382d972 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -12,6 +12,7 @@
#include "base/path_service.h"
#include "base/scoped_nsautorelease_pool.h"
#include "base/test_suite.h"
+#include "chrome/app/scoped_ole_initializer.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -78,11 +79,12 @@ protected:
// Tear down shared StatsTable; prevents unit_tests from leaking it.
StatsTable::set_current(NULL);
delete stats_table_;
-
+
TestSuite::Shutdown();
}
StatsTable* stats_table_;
+ ScopedOleInitializer ole_initializer_;
};
#endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_