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

Unified Diff: ui/views/test/scoped_views_test_helper.cc

Issue 1175783003: Split out Ash dependency in app info dialog unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ViewEventTestBase will not play nice Created 5 years, 6 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: ui/views/test/scoped_views_test_helper.cc
diff --git a/ui/views/test/scoped_views_test_helper.cc b/ui/views/test/scoped_views_test_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c765cc4f8eb4116dc9998327c563d24c0d60e7c2
--- /dev/null
+++ b/ui/views/test/scoped_views_test_helper.cc
@@ -0,0 +1,48 @@
+// Copyright 2015 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.
+
+#include "ui/views/test/scoped_views_test_helper.h"
+
+#include "base/message_loop/message_loop.h"
+#include "ui/base/ime/input_method_initializer.h"
+#include "ui/compositor/test/context_factories_for_test.h"
+#include "ui/views/test/test_views_delegate.h"
+#include "ui/views/test/views_test_helper.h"
+
+namespace views {
+
+ScopedViewsTestHelper::ScopedViewsTestHelper()
+ : ScopedViewsTestHelper(make_scoped_ptr(new TestViewsDelegate)) {
+}
+
+ScopedViewsTestHelper::ScopedViewsTestHelper(
+ scoped_ptr<TestViewsDelegate> views_delegate)
+ : views_delegate_(views_delegate.Pass()) {
+ // The ContextFactory must exist before any Compositors are created.
+ bool enable_pixel_output = false;
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
+ views_delegate_->set_context_factory(context_factory);
+
+ test_helper_.reset(ViewsTestHelper::Create(base::MessageLoopForUI::current(),
+ context_factory));
+ test_helper_->SetUp();
+
+ ui::InitializeInputMethodForTesting();
+}
+
+ScopedViewsTestHelper::~ScopedViewsTestHelper() {
+ ui::ShutdownInputMethodForTesting();
+ test_helper_->TearDown();
+ test_helper_.reset();
+
+ ui::TerminateContextFactoryForTests();
+ views_delegate_.reset();
+}
+
+gfx::NativeWindow ScopedViewsTestHelper::GetContext() {
+ return test_helper_->GetContext();
+}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698