Index: chrome/test/base/in_process_browser_test.cc |
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc |
index 5cdbf8f4bc990029fbbc0421f4b26be7fefa57ef..a8342f867d345ace3e919f27ce603f92e147481d 100644 |
--- a/chrome/test/base/in_process_browser_test.cc |
+++ b/chrome/test/base/in_process_browser_test.cc |
@@ -36,6 +36,7 @@ |
#include "chrome/renderer/chrome_content_renderer_client.h" |
#include "chrome/test/base/chrome_test_suite.h" |
#include "chrome/test/base/test_launcher_utils.h" |
+#include "chrome/test/base/test_switches.h" |
#include "chrome/test/base/testing_browser_process.h" |
#include "chrome/test/base/ui_test_utils.h" |
#include "content/public/browser/notification_service.h" |
@@ -54,6 +55,15 @@ |
#include "base/mac/scoped_nsautorelease_pool.h" |
#endif |
+#if defined(OS_WIN) && defined(USE_AURA) |
+#include "base/win/scoped_com_initializer.h" |
+#include "base/win/windows_version.h" |
+#include "ui/base/win/atl_module.h" |
+#include "ui/compositor/compositor_setup.h" |
+#include "win8/test/metro_registration_helper.h" |
+#include "win8/test/test_registrar_constants.h" |
+#endif |
+ |
#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
#include "chrome/browser/captive_portal/captive_portal_service.h" |
#endif |
@@ -69,6 +79,11 @@ base::LazyInstance<chrome::ChromeContentRendererClient>::Leaky |
} // namespace |
+#if defined(OS_WIN) && defined(USE_AURA) |
+//static |
+base::win::ScopedCOMInitializer* InProcessBrowserTest::com_initializer_ = NULL; |
+#endif |
+ |
InProcessBrowserTest::InProcessBrowserTest() |
: browser_(NULL), |
exit_when_last_browser_closes_(true) |
@@ -94,6 +109,32 @@ InProcessBrowserTest::InProcessBrowserTest() |
InProcessBrowserTest::~InProcessBrowserTest() { |
} |
+//static |
+void InProcessBrowserTest::SetUpTestCase() { |
jam
2013/06/21 16:32:05
I'm not sure I understand the usage of this static
gab
2013/06/21 16:47:00
Ah ok, sounds good, I had noticed this was the cas
|
+ BrowserTestBase::SetUpTestCase(); |
+ |
+#if defined(OS_WIN) && defined(USE_AURA) |
+ if (base::win::GetVersion() >= base::win::VERSION_WIN8 && |
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) { |
+ com_initializer_ = new base::win::ScopedCOMInitializer(); |
+ ui::win::CreateATLModuleIfNeeded(); |
+ ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously()); |
+ |
+ // Ash browser tests need the real compositor. |
+ ui::DisableTestCompositor(); |
+ } |
+#endif |
+} |
+ |
+//static |
+void InProcessBrowserTest::TearDownTestCase() { |
+#if defined(OS_WIN) && defined(USE_AURA) |
+ delete com_initializer_; |
+ com_initializer_ = NULL; |
+#endif |
+ BrowserTestBase::TearDownTestCase(); |
+} |
+ |
void InProcessBrowserTest::SetUp() { |
// Undo TestingBrowserProcess creation in ChromeTestSuite. |
// TODO(phajdan.jr): Extract a smaller test suite so we don't need this. |
@@ -169,6 +210,13 @@ void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { |
// This is a Browser test. |
command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType); |
+#if defined(OS_WIN) && defined(USE_AURA) |
+ if (command_line->HasSwitch(switches::kAshBrowserTests)) { |
+ command_line->AppendSwitchNative(switches::kViewerLaunchViaAppId, |
+ win8::test::kDefaultTestAppUserModelId); |
+ } |
+#endif |
+ |
#if defined(OS_MACOSX) |
// Explicitly set the path of the binary used for child processes, otherwise |
// they'll try to use browser_tests which doesn't contain ChromeMain. |