1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_TEST_VIEWS_TEST_BASE_H_
6 #define UI_VIEWS_TEST_VIEWS_TEST_BASE_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/views/test/test_views_delegate.h"
14 #include "ui/base/win/scoped_ole_initializer.h"
25 // A base class for views unit test. It creates a message loop necessary
26 // to drive UI events and takes care of OLE initialization for windows.
27 class ViewsTestBase : public testing::Test {
30 virtual ~ViewsTestBase();
33 virtual void SetUp() OVERRIDE;
34 virtual void TearDown() OVERRIDE;
36 void RunPendingMessages();
38 // Creates a widget of |type| with any platform specific data for use in
39 // cross-platform tests.
40 Widget::InitParams CreateParams(Widget::InitParams::Type type);
43 TestViewsDelegate& views_delegate() const { return *views_delegate_.get(); }
45 void set_views_delegate(TestViewsDelegate* views_delegate) {
46 views_delegate_.reset(views_delegate);
49 base::MessageLoopForUI* message_loop() { return &message_loop_; }
51 // Returns a context view. In aura builds, this will be the
52 // RootWindow. Everywhere else, NULL.
53 gfx::NativeView GetContext();
56 base::MessageLoopForUI message_loop_;
57 scoped_ptr<TestViewsDelegate> views_delegate_;
59 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_;
62 bool teardown_called_;
65 ui::ScopedOleInitializer ole_initializer_;
68 DISALLOW_COPY_AND_ASSIGN(ViewsTestBase);
73 #endif // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_