Commit 5e4c8757 authored by gab@chromium.org's avatar gab@chromium.org

Base for Ash browser_tests on Win8.

For now, although the --ash-browsertests switch will launch browser_tests in Ash in Metro, most tests are still hardcoded to open browsers on the native desktop (HOST_DESKTOP_TYPE_NATIVE) -- follow-up CLs will be required to have all tests use GetActiveDesktop() instead and then add some checks to make sure no browsers are left on the wrong desktop when tests complete.

I'm not making this the default browser_tests on Windows 8 because regular Desktop browser_tests should still be runnable, testable, debuggable, etc. on Win8 machines.

BUG=179830
TEST="browser_tests.exe --ash-browsertests" should launch Ash in Metro for every test, each test should pass and exit (although most tests will no open browsers in Ash itself for now -- no checks is currently added to make sure of that so they should pass).

Review URL: https://chromiumcodereview.appspot.com/16022003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207936 0039d316-1c4b-4281-b951-d872f2087c98
parent 315e47b2
......@@ -24,11 +24,23 @@ void BrowserProcessPlatformPart::OnMetroViewerProcessTerminated() {
void BrowserProcessPlatformPart::PlatformSpecificCommandLineProcessing(
const CommandLine& command_line) {
if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
command_line.HasSwitch(switches::kViewerConnect) &&
!metro_viewer_process_host_.get()) {
// Check for Windows 8 specific commandlines requesting that this process
// either connect to an existing viewer or launch a new viewer and
// synchronously wait for it to connect.
if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
bool launch = command_line.HasSwitch(switches::kViewerLaunchViaAppId);
bool connect = (launch ||
(command_line.HasSwitch(switches::kViewerConnect) &&
!metro_viewer_process_host_.get()));
if (connect) {
// Create a host to connect to the Metro viewer process over IPC.
metro_viewer_process_host_.reset(new ChromeMetroViewerProcessHost());
if (launch) {
CHECK(metro_viewer_process_host_->LaunchViewerAndWaitForConnection(
command_line.GetSwitchValueNative(
switches::kViewerLaunchViaAppId)));
}
}
}
}
......
......@@ -377,6 +377,14 @@
'include_dirs': [
'<(DEPTH)/third_party/wtl/include',
],
'conditions': [
['use_aura==1', {
'dependencies': [
'../win8/win8.gyp:test_registrar_constants',
'../win8/win8.gyp:test_support_win8',
],
}],
],
}],
],
},
......
......@@ -1600,6 +1600,11 @@ const char kWindows8Search[] = "windows8-search";
#if defined(OS_WIN) && defined(USE_AURA)
// Requests that Chrome connect to the running Metro viewer process.
const char kViewerConnect[] = "viewer-connect";
// Requests that Chrome launch the Metro viewer process via the given appid
// (which is assumed to be registered as default browser) and synchronously
// connect to it.
const char kViewerLaunchViaAppId[] = "viewer-launch-via-appid";
#endif
#ifndef NDEBUG
......
......@@ -448,6 +448,7 @@ extern const char kWindows8Search[];
#if defined(OS_WIN) && defined(USE_AURA)
extern const char kViewerConnect[];
extern const char kViewerLaunchViaAppId[];
#endif
#ifndef NDEBUG
......
......@@ -20,4 +20,5 @@ include_rules = [
"+sandbox/win/tests",
"+webkit/glue",
"+webkit/plugins",
"+win8/test",
]
......@@ -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
......@@ -159,6 +169,18 @@ void InProcessBrowserTest::SetUp() {
google_util::SetMockLinkDoctorBaseURLForTesting();
#if defined(OS_WIN) && defined(USE_AURA)
if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) {
com_initializer_.reset(new base::win::ScopedCOMInitializer());
ui::win::CreateATLModuleIfNeeded();
ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously());
// Ash browser tests need the real compositor.
ui::DisableTestCompositor();
}
#endif
BrowserTestBase::SetUp();
}
......@@ -169,6 +191,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.
......@@ -212,6 +241,9 @@ bool InProcessBrowserTest::CreateUserDataDirectory() {
void InProcessBrowserTest::TearDown() {
DCHECK(!g_browser_process);
#if defined(OS_WIN) && defined(USE_AURA)
com_initializer_.reset();
#endif
BrowserTestBase::TearDown();
}
......
......@@ -18,13 +18,19 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
#endif // defined(OS_CHROMEOS)
#if defined(OS_MACOSX)
namespace base {
#if defined(OS_MACOSX)
namespace mac {
class ScopedNSAutoreleasePool;
} // namespace mac
#endif // defined(OS_MACOSX)
#if defined(OS_WIN) && defined(USE_AURA)
namespace win {
class ScopedCOMInitializer;
}
#endif // defined(OS_WIN) && defined(USE_AURA)
} // namespace base
#endif // OS_MACOSX
class Browser;
class CommandLine;
......@@ -209,6 +215,10 @@ class InProcessBrowserTest : public content::BrowserTestBase {
#if defined(OS_MACOSX)
base::mac::ScopedNSAutoreleasePool* autorelease_pool_;
#endif // OS_MACOSX
#if defined(OS_WIN) && defined(USE_AURA)
scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_;
#endif
};
#endif // CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_
......@@ -4,22 +4,30 @@
#include "chrome/test/base/test_switches.h"
namespace switches {
// Also emit full event trace logs for successful tests.
const char switches::kAlsoEmitSuccessLogs[] = "also-emit-success-logs";
const char kAlsoEmitSuccessLogs[] = "also-emit-success-logs";
// Extra flags that the test should pass to launched browser process.
const char switches::kExtraChromeFlags[] = "extra-chrome-flags";
const char kExtraChromeFlags[] = "extra-chrome-flags";
// Enable Chromium branding of the executable.
const char switches::kEnableChromiumBranding[] = "enable-chromium-branding";
const char kEnableChromiumBranding[] = "enable-chromium-branding";
// Enable displaying error dialogs (for debugging).
const char switches::kEnableErrorDialogs[] = "enable-errdialogs";
const char kEnableErrorDialogs[] = "enable-errdialogs";
// Number of iterations that page cycler tests will run.
const char switches::kPageCyclerIterations[] = "page-cycler-iterations";
const char kPageCyclerIterations[] = "page-cycler-iterations";
// Name of channel used to connect to Chrome
// when using the named testing interface.
const char switches::kTestingChannel[] = "testing-channel";
const char kTestingChannel[] = "testing-channel";
#if defined(OS_WIN) && defined(USE_AURA)
// Force browser tests to run in Ash/Metro on Windows 8.
const char kAshBrowserTests[] = "ash-browsertests";
#endif
} // namespace switches
......@@ -5,6 +5,8 @@
#ifndef CHROME_TEST_BASE_TEST_SWITCHES_H_
#define CHROME_TEST_BASE_TEST_SWITCHES_H_
#include "build/build_config.h"
namespace switches {
// All switches in alphabetical order. The switches should be documented
......@@ -16,6 +18,10 @@ extern const char kEnableErrorDialogs[];
extern const char kPageCyclerIterations[];
extern const char kTestingChannel[];
#if defined(OS_WIN) && defined(USE_AURA)
extern const char kAshBrowserTests[];
#endif
} // namespace switches
#endif // CHROME_TEST_BASE_TEST_SWITCHES_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment