Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4553)

Unified Diff: chrome/test/base/view_event_test_base.cc

Issue 273073002: Changes code using Compositor to pass in ContextFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tooltip on chromeos Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/view_event_test_base.cc
diff --git a/chrome/test/base/view_event_test_base.cc b/chrome/test/base/view_event_test_base.cc
index 2d64c5d408c07be184b86a8d40b21c808205ad9a..b2d252f246d103efd7dbb33239f1c87c005c6b7a 100644
--- a/chrome/test/base/view_event_test_base.cc
+++ b/chrome/test/base/view_event_test_base.cc
@@ -44,6 +44,30 @@
namespace {
+class ViewEventTestBaseViewsDelegate : public ChromeViewsDelegate {
+ public:
+ ViewEventTestBaseViewsDelegate() : context_factory_(NULL) {
+ views::ViewsDelegate::views_delegate = this;
+ }
+ virtual ~ViewEventTestBaseViewsDelegate() {
+ views::ViewsDelegate::views_delegate = NULL;
+ }
+
+ void set_context_factory(ui::ContextFactory* context_factory) {
+ context_factory_ = context_factory;
+ }
+
+ // ChromeViewsDelegate:
+ virtual ui::ContextFactory* GetContextFactory() OVERRIDE {
+ return context_factory_;
+ }
+
+ private:
+ ui::ContextFactory* context_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ViewEventTestBaseViewsDelegate);
+};
+
// View subclass that allows you to specify the preferred size.
class TestView : public views::View {
public:
@@ -103,13 +127,18 @@ void ViewEventTestBase::SetUpTestCase() {
void ViewEventTestBase::SetUp() {
wm_state_.reset(new wm::WMState);
- views::ViewsDelegate::views_delegate = &views_delegate_;
+ ViewEventTestBaseViewsDelegate* views_delegate =
+ new ViewEventTestBaseViewsDelegate;
+ views_delegate_.reset(views_delegate);
+
ui::InitializeInputMethodForTesting();
gfx::NativeView context = NULL;
// The ContextFactory must exist before any Compositors are created.
bool enable_pixel_output = false;
- ui::InitializeContextFactoryForTests(enable_pixel_output);
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
+ views_delegate->set_context_factory(context_factory);
#if defined(USE_ASH)
#if defined(OS_WIN)
@@ -131,6 +160,7 @@ void ViewEventTestBase::SetUp() {
new ash::test::TestShellDelegate();
ash::ShellInitParams init_params;
init_params.delegate = shell_delegate;
+ init_params.context_factory = context_factory;
ash::Shell::CreateInstance(init_params);
shell_delegate->test_session_state_delegate()
->SetActiveUserSessionStarted(true);
@@ -143,7 +173,7 @@ void ViewEventTestBase::SetUp() {
// the test screen.
aura_test_helper_.reset(
new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
- aura_test_helper_->SetUp();
+ aura_test_helper_->SetUp(context_factory);
new wm::DefaultActivationClient(aura_test_helper_->root_window());
context = aura_test_helper_->root_window();
#endif // !USE_ASH && USE_AURA
@@ -180,7 +210,8 @@ void ViewEventTestBase::TearDown() {
ui::TerminateContextFactoryForTests();
ui::ShutdownInputMethodForTesting();
- views::ViewsDelegate::views_delegate = NULL;
+
+ views_delegate_.reset();
wm_state_.reset();
}

Powered by Google App Engine
This is Rietveld 408576698