test_native_theme.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2018 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.
  4. #ifndef UI_NATIVE_THEME_TEST_NATIVE_THEME_H_
  5. #define UI_NATIVE_THEME_TEST_NATIVE_THEME_H_
  6. #include "ui/native_theme/native_theme.h"
  7. namespace ui {
  8. class TestNativeTheme : public NativeTheme {
  9. public:
  10. TestNativeTheme();
  11. TestNativeTheme(const TestNativeTheme&) = delete;
  12. TestNativeTheme& operator=(const TestNativeTheme&) = delete;
  13. ~TestNativeTheme() override;
  14. // NativeTheme:
  15. gfx::Size GetPartSize(Part part,
  16. State state,
  17. const ExtraParams& extra) const override;
  18. void Paint(cc::PaintCanvas* canvas,
  19. const ui::ColorProvider* color_provider,
  20. Part part,
  21. State state,
  22. const gfx::Rect& rect,
  23. const ExtraParams& extra,
  24. ColorScheme color_scheme,
  25. const absl::optional<SkColor>& accent_color) const override;
  26. bool SupportsNinePatch(Part part) const override;
  27. gfx::Size GetNinePatchCanvasSize(Part part) const override;
  28. gfx::Rect GetNinePatchAperture(Part part) const override;
  29. bool UserHasContrastPreference() const override;
  30. bool ShouldUseDarkColors() const override;
  31. PreferredColorScheme GetPreferredColorScheme() const override;
  32. ColorScheme GetDefaultSystemColorScheme() const override;
  33. void SetDarkMode(bool dark_mode) { dark_mode_ = dark_mode; }
  34. void SetUserHasContrastPreference(bool contrast_preference) {
  35. contrast_preference_ = contrast_preference;
  36. }
  37. void SetIsPlatformHighContrast(bool is_platform_high_contrast) {
  38. is_platform_high_contrast_ = is_platform_high_contrast;
  39. }
  40. void AddColorSchemeNativeThemeObserver(NativeTheme* theme_to_update);
  41. private:
  42. bool dark_mode_ = false;
  43. bool contrast_preference_ = false;
  44. bool is_platform_high_contrast_ = false;
  45. std::unique_ptr<NativeTheme::ColorSchemeNativeThemeObserver>
  46. color_scheme_observer_;
  47. };
  48. } // namespace ui
  49. #endif // UI_NATIVE_THEME_TEST_NATIVE_THEME_H_