| 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_TEST_VIEWS_DELEGATE_H_ | 5 #ifndef UI_VIEWS_TEST_TEST_VIEWS_DELEGATE_H_ |
| 6 #define UI_VIEWS_TEST_TEST_VIEWS_DELEGATE_H_ | 6 #define UI_VIEWS_TEST_TEST_VIEWS_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "ui/views/style/typography_provider.h" | 12 #include "ui/views/layout/layout_provider.h" |
| 13 #include "ui/views/views_delegate.h" | 13 #include "ui/views/views_delegate.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 | 16 |
| 17 class TestViewsDelegate : public ViewsDelegate { | 17 class TestViewsDelegate : public ViewsDelegate { |
| 18 public: | 18 public: |
| 19 TestViewsDelegate(); | 19 TestViewsDelegate(); |
| 20 ~TestViewsDelegate() override; | 20 ~TestViewsDelegate() override; |
| 21 | 21 |
| 22 // If set to |true|, forces widgets that do not provide a native widget to use | 22 // If set to |true|, forces widgets that do not provide a native widget to use |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 // Allows tests to provide a ContextFactory via the ViewsDelegate interface. | 33 // Allows tests to provide a ContextFactory via the ViewsDelegate interface. |
| 34 void set_context_factory(ui::ContextFactory* context_factory) { | 34 void set_context_factory(ui::ContextFactory* context_factory) { |
| 35 context_factory_ = context_factory; | 35 context_factory_ = context_factory; |
| 36 } | 36 } |
| 37 | 37 |
| 38 void set_context_factory_private( | 38 void set_context_factory_private( |
| 39 ui::ContextFactoryPrivate* context_factory_private) { | 39 ui::ContextFactoryPrivate* context_factory_private) { |
| 40 context_factory_private_ = context_factory_private; | 40 context_factory_private_ = context_factory_private; |
| 41 } | 41 } |
| 42 | 42 |
| 43 // For convenience, we create a layout provider by default, but embedders |
| 44 // that use their own layout provider subclasses may need to set those classes |
| 45 // as the layout providers for their tests. |
| 46 void set_layout_provider(std::unique_ptr<LayoutProvider> layout_provider) { |
| 47 layout_provider_.swap(layout_provider); |
| 48 } |
| 49 |
| 43 // ViewsDelegate: | 50 // ViewsDelegate: |
| 44 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
| 45 HICON GetSmallWindowIcon() const override; | 52 HICON GetSmallWindowIcon() const override; |
| 46 #endif | 53 #endif |
| 47 void OnBeforeWidgetInit(Widget::InitParams* params, | 54 void OnBeforeWidgetInit(Widget::InitParams* params, |
| 48 internal::NativeWidgetDelegate* delegate) override; | 55 internal::NativeWidgetDelegate* delegate) override; |
| 49 ui::ContextFactory* GetContextFactory() override; | 56 ui::ContextFactory* GetContextFactory() override; |
| 50 ui::ContextFactoryPrivate* GetContextFactoryPrivate() override; | 57 ui::ContextFactoryPrivate* GetContextFactoryPrivate() override; |
| 51 const TypographyProvider& GetTypographyProvider() const override; | |
| 52 | 58 |
| 53 private: | 59 private: |
| 54 ui::ContextFactory* context_factory_; | 60 ui::ContextFactory* context_factory_; |
| 55 ui::ContextFactoryPrivate* context_factory_private_; | 61 ui::ContextFactoryPrivate* context_factory_private_; |
| 56 bool use_desktop_native_widgets_; | 62 bool use_desktop_native_widgets_; |
| 57 bool use_transparent_windows_; | 63 bool use_transparent_windows_; |
| 58 DefaultTypographyProvider typography_provider_; | 64 std::unique_ptr<LayoutProvider> layout_provider_ = |
| 65 base::MakeUnique<LayoutProvider>(); |
| 59 | 66 |
| 60 DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate); | 67 DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate); |
| 61 }; | 68 }; |
| 62 | 69 |
| 63 } // namespace views | 70 } // namespace views |
| 64 | 71 |
| 65 #endif // UI_VIEWS_TEST_TEST_VIEWS_DELEGATE_H_ | 72 #endif // UI_VIEWS_TEST_TEST_VIEWS_DELEGATE_H_ |
| OLD | NEW |