| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ | 5 #ifndef UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ |
| 6 #define UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ | 6 #define UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 namespace views { | 23 namespace views { |
| 24 | 24 |
| 25 // A base class for views unit test. It creates a message loop necessary | 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. | 26 // to drive UI events and takes care of OLE initialization for windows. |
| 27 class ViewsTestBase : public PlatformTest { | 27 class ViewsTestBase : public PlatformTest { |
| 28 public: | 28 public: |
| 29 ViewsTestBase(); | 29 ViewsTestBase(); |
| 30 ~ViewsTestBase() override; | 30 ~ViewsTestBase() override; |
| 31 | 31 |
| 32 // Whether the test is running under mus. | |
| 33 static bool IsMus(); | |
| 34 | |
| 35 // testing::Test: | 32 // testing::Test: |
| 36 void SetUp() override; | 33 void SetUp() override; |
| 37 void TearDown() override; | 34 void TearDown() override; |
| 38 | 35 |
| 39 void RunPendingMessages(); | 36 void RunPendingMessages(); |
| 40 | 37 |
| 41 // Creates a widget of |type| with any platform specific data for use in | 38 // Creates a widget of |type| with any platform specific data for use in |
| 42 // cross-platform tests. | 39 // cross-platform tests. |
| 43 Widget::InitParams CreateParams(Widget::InitParams::Type type); | 40 Widget::InitParams CreateParams(Widget::InitParams::Type type); |
| 44 | 41 |
| 45 // Use for tests that you should not create a NativeWidgetMus. Ideally we | 42 // Use for tests that you should not create a NativeWidgetMus. Ideally we |
| 46 // would use an ifdef, but for the time being we're not compiling differently, | 43 // would use an ifdef, but for the time being we're not compiling differently, |
| 47 // so that a define is not possible. | 44 // so that a define is not possible. |
| 48 void DisableNativeWidgetMus(); | 45 void DisableNativeWidgetMus(); |
| 46 bool IsMus() const; |
| 49 | 47 |
| 50 protected: | 48 protected: |
| 51 TestViewsDelegate* views_delegate() const { | 49 TestViewsDelegate* views_delegate() const { |
| 52 return test_helper_->views_delegate(); | 50 return test_helper_->views_delegate(); |
| 53 } | 51 } |
| 54 | 52 |
| 55 void set_views_delegate(std::unique_ptr<TestViewsDelegate> views_delegate) { | 53 void set_views_delegate(std::unique_ptr<TestViewsDelegate> views_delegate) { |
| 56 DCHECK(!setup_called_); | 54 DCHECK(!setup_called_); |
| 57 views_delegate_for_setup_.swap(views_delegate); | 55 views_delegate_for_setup_.swap(views_delegate); |
| 58 } | 56 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 73 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
| 74 ui::ScopedOleInitializer ole_initializer_; | 72 ui::ScopedOleInitializer ole_initializer_; |
| 75 #endif | 73 #endif |
| 76 | 74 |
| 77 DISALLOW_COPY_AND_ASSIGN(ViewsTestBase); | 75 DISALLOW_COPY_AND_ASSIGN(ViewsTestBase); |
| 78 }; | 76 }; |
| 79 | 77 |
| 80 } // namespace views | 78 } // namespace views |
| 81 | 79 |
| 82 #endif // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ | 80 #endif // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ |
| OLD | NEW |