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

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

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.h
diff --git a/ui/views/test/scoped_views_test_helper.h b/ui/views/test/scoped_views_test_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..f2693ab7c149aee7709355da4d7966ea8b516ee2
--- /dev/null
+++ b/ui/views/test/scoped_views_test_helper.h
@@ -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.
+
+#ifndef UI_VIEWS_TEST_SCOPED_VIEWS_TEST_HELPER_H_
+#define UI_VIEWS_TEST_SCOPED_VIEWS_TEST_HELPER_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace views {
+
+class TestViewsDelegate;
+class ViewsTestHelper;
+
+// Creates a ViewsTestHelper that is released automatically. Acts like
+// ViewsTestBase but allows a test harness to use a different base class, or
+// make use of a TestBrowserThreadBundle, rather than the MessageLoop provided
+// by ViewsTestBase.
+class ScopedViewsTestHelper {
+ public:
+ // Initialize with the default TestViewsDelegate, MessageLoopForUI::current()
+ // and the default test ContextFactory.
+ ScopedViewsTestHelper();
+
+ // Initialize with the given TestViewsDelegate instance, after setting the
+ // ContextFactory.
+ explicit ScopedViewsTestHelper(scoped_ptr<TestViewsDelegate> views_delegate);
+
+ ~ScopedViewsTestHelper();
+
+ // Returns the context for creating new windows. In Aura builds, this will be
+ // the RootWindow. Everywhere else, null.
+ gfx::NativeWindow GetContext();
+
+ TestViewsDelegate* views_delegate() { return views_delegate_.get(); };
+
+ private:
+ scoped_ptr<TestViewsDelegate> views_delegate_;
+ scoped_ptr<ViewsTestHelper> test_helper_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedViewsTestHelper);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_TEST_SCOPED_VIEWS_TEST_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698