diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-21 18:46:05 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-21 18:46:05 +0000 |
commit | 1c3f7002d91087f655dc805ac115e69ce1dc02fb (patch) | |
tree | 5ab0a121c2901bbcd16731c8236b6db527024833 /ash/test/test_metro_viewer_process_host.h | |
parent | 345f3919f5b66370ddc2152468286b381ffb5bbb (diff) | |
download | chromium_src-1c3f7002d91087f655dc805ac115e69ce1dc02fb.zip chromium_src-1c3f7002d91087f655dc805ac115e69ce1dc02fb.tar.gz chromium_src-1c3f7002d91087f655dc805ac115e69ce1dc02fb.tar.bz2 |
Initial whack at getting ash_unittests to connect to a viewer process on Win/Metro.
This adds a test viewer process host to the ash unittests that starts and connects to the viewer process, using the provided hwnd as a backing surface for the tests.
This approach allows most of the ash unittests to pass except for two categories:
1) Tests that spin up more than one ash display. These don't work since each RootWindowHost thus created would require a remote connection and there is only one Metro viewer process.
2) Some number of tests seem to tickle a crash in shader.cc. These are short-circuited on Win8 with a TODO.
Some limitations:
1) The tests require chrome.exe to be registered as the default browser on Windows 8 to be used as a viewer process. This could be fixed in a future CL by creating a minimal viewer process for tests.
2) To register chrome.exe as the default browser, setup.exe needs to be built and run with
setup.exe --register-dev-chrome --register-dev-chrome-suffix=.test
This will be fixed in a future CL by extracting the registration code.
The interesting parts are in ash/test/test_metro_viewer_process_host.h
ash/test/test_metro_viewer_process_host.cc
Most of the rest is test disabling or calling the above.
BUG=154081
TEST=ash_unittests.exe on win8.
Review URL: https://chromiumcodereview.appspot.com/11830038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177946 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/test/test_metro_viewer_process_host.h')
-rw-r--r-- | ash/test/test_metro_viewer_process_host.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/ash/test/test_metro_viewer_process_host.h b/ash/test/test_metro_viewer_process_host.h new file mode 100644 index 0000000..2662390 --- /dev/null +++ b/ash/test/test_metro_viewer_process_host.h @@ -0,0 +1,88 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_ +#define ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_ + +#include <string> + +#include "base/memory/scoped_ptr.h" +#include "base/synchronization/waitable_event.h" +#include "base/threading/non_thread_safe.h" +#include "base/threading/thread.h" +#include "ipc/ipc_channel_proxy.h" +#include "ipc/ipc_listener.h" +#include "ipc/ipc_sender.h" +#include "ui/gfx/native_widget_types.h" + +class AcceleratedSurface; + +namespace ash { +namespace test { + +class TestMetroViewerProcessHost : public IPC::Listener, + public IPC::Sender, + public base::NonThreadSafe { + public: + explicit TestMetroViewerProcessHost(const std::string& ipc_channel_name); + virtual ~TestMetroViewerProcessHost(); + + // Launches the Chrome viewer process and blocks until that viewer process + // connects or until a timeout is reached. Returns true if the viewer process + // connects before the timeout is reached. + // TODO(robertshield): This creates a run-time dependency on chrome.exe as the + // viewer process and, indirectly, setup.exe as the only thing that can + // correctly register a program as the default browser on metro. Investigate + // extracting the registration code and the metro init code and building them + // into a standalone viewer process. + bool LaunchImmersiveChromeAndWaitForConnection(); + + // IPC::Sender implementation: + virtual bool Send(IPC::Message* msg) OVERRIDE; + + // IPC::Listener implementation: + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + virtual void OnChannelError() OVERRIDE; + + bool closed_unexpectedly() { return closed_unexpectedly_; } + + private: + void OnSetTargetSurface(gfx::NativeViewId target_surface); + + void NotifyChannelConnected(); + + // Inner message filter used to handle connection event on the IPC channel + // proxy's background thread. This prevents consumers of + // TestMetroViewerProcessHost from having to pump messages on their own + // message loop. + class InternalMessageFilter : public IPC::ChannelProxy::MessageFilter { + public: + InternalMessageFilter(TestMetroViewerProcessHost* owner); + + // IPC::ChannelProxy::MessageFilter implementation. + virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; + + private: + TestMetroViewerProcessHost* owner_; + DISALLOW_COPY_AND_ASSIGN(InternalMessageFilter); + }; + + // Members related to the IPC channel. Note that the order is important + // here as ipc_thread_ should be destroyed after channel_. + base::Thread ipc_thread_; + scoped_ptr<IPC::ChannelProxy> channel_; + base::WaitableEvent channel_connected_event_; + + scoped_ptr<AcceleratedSurface> backing_surface; + + bool closed_unexpectedly_; + + DISALLOW_COPY_AND_ASSIGN(TestMetroViewerProcessHost); +}; + + +} // namespace test +} // namespace ash + +#endif // ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_ |