Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / views / test / views_test_base.h
blobb59ebf48649c4c159ef57869de0347da98f710ec
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 "testing/platform_test.h"
12 #include "ui/views/test/scoped_views_test_helper.h"
13 #include "ui/views/test/test_views_delegate.h"
14 #include "ui/views/widget/widget.h"
16 #if defined(OS_WIN)
17 #include "ui/base/win/scoped_ole_initializer.h"
18 #endif
20 namespace views {
22 // A base class for views unit test. It creates a message loop necessary
23 // to drive UI events and takes care of OLE initialization for windows.
24 class ViewsTestBase : public PlatformTest {
25 public:
26 ViewsTestBase();
27 ~ViewsTestBase() override;
29 // testing::Test:
30 void SetUp() override;
31 void TearDown() override;
33 void RunPendingMessages();
35 // Creates a widget of |type| with any platform specific data for use in
36 // cross-platform tests.
37 Widget::InitParams CreateParams(Widget::InitParams::Type type);
39 protected:
40 TestViewsDelegate* views_delegate() const {
41 return test_helper_->views_delegate();
44 void set_views_delegate(scoped_ptr<TestViewsDelegate> views_delegate) {
45 DCHECK(!setup_called_);
46 views_delegate_for_setup_.swap(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::NativeWindow GetContext();
55 private:
56 base::MessageLoopForUI message_loop_;
57 scoped_ptr<TestViewsDelegate> views_delegate_for_setup_;
58 scoped_ptr<ScopedViewsTestHelper> test_helper_;
59 bool setup_called_;
60 bool teardown_called_;
62 #if defined(OS_WIN)
63 ui::ScopedOleInitializer ole_initializer_;
64 #endif
66 DISALLOW_COPY_AND_ASSIGN(ViewsTestBase);
69 } // namespace views
71 #endif // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_