| 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 |
| 32 // testing::Test: | 35 // testing::Test: |
| 33 void SetUp() override; | 36 void SetUp() override; |
| 34 void TearDown() override; | 37 void TearDown() override; |
| 35 | 38 |
| 36 void RunPendingMessages(); | 39 void RunPendingMessages(); |
| 37 | 40 |
| 38 // Creates a widget of |type| with any platform specific data for use in | 41 // Creates a widget of |type| with any platform specific data for use in |
| 39 // cross-platform tests. | 42 // cross-platform tests. |
| 40 Widget::InitParams CreateParams(Widget::InitParams::Type type); | 43 Widget::InitParams CreateParams(Widget::InitParams::Type type); |
| 41 | 44 |
| 42 // Use for tests that you should not create a NativeWidgetMus. Ideally we | 45 // Use for tests that you should not create a NativeWidgetMus. Ideally we |
| 43 // would use an ifdef, but for the time being we're not compiling differently, | 46 // would use an ifdef, but for the time being we're not compiling differently, |
| 44 // so that a define is not possible. | 47 // so that a define is not possible. |
| 45 void DisableNativeWidgetMus(); | 48 void DisableNativeWidgetMus(); |
| 46 bool IsMus() const; | |
| 47 | 49 |
| 48 protected: | 50 protected: |
| 49 TestViewsDelegate* views_delegate() const { | 51 TestViewsDelegate* views_delegate() const { |
| 50 return test_helper_->views_delegate(); | 52 return test_helper_->views_delegate(); |
| 51 } | 53 } |
| 52 | 54 |
| 53 void set_views_delegate(std::unique_ptr<TestViewsDelegate> views_delegate) { | 55 void set_views_delegate(std::unique_ptr<TestViewsDelegate> views_delegate) { |
| 54 DCHECK(!setup_called_); | 56 DCHECK(!setup_called_); |
| 55 views_delegate_for_setup_.swap(views_delegate); | 57 views_delegate_for_setup_.swap(views_delegate); |
| 56 } | 58 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 71 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
| 72 ui::ScopedOleInitializer ole_initializer_; | 74 ui::ScopedOleInitializer ole_initializer_; |
| 73 #endif | 75 #endif |
| 74 | 76 |
| 75 DISALLOW_COPY_AND_ASSIGN(ViewsTestBase); | 77 DISALLOW_COPY_AND_ASSIGN(ViewsTestBase); |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 } // namespace views | 80 } // namespace views |
| 79 | 81 |
| 80 #endif // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ | 82 #endif // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ |
| OLD | NEW |