test_native_theme.cc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #include "ui/native_theme/test_native_theme.h"
  5. namespace ui {
  6. TestNativeTheme::TestNativeTheme() : NativeTheme(false) {}
  7. TestNativeTheme::~TestNativeTheme() = default;
  8. gfx::Size TestNativeTheme::GetPartSize(Part part,
  9. State state,
  10. const ExtraParams& extra) const {
  11. return gfx::Size();
  12. }
  13. void TestNativeTheme::Paint(cc::PaintCanvas* canvas,
  14. const ui::ColorProvider* color_provider,
  15. Part part,
  16. State state,
  17. const gfx::Rect& rect,
  18. const ExtraParams& extra,
  19. ColorScheme color_scheme,
  20. const absl::optional<SkColor>& accent_color) const {
  21. }
  22. bool TestNativeTheme::SupportsNinePatch(Part part) const {
  23. return false;
  24. }
  25. gfx::Size TestNativeTheme::GetNinePatchCanvasSize(Part part) const {
  26. return gfx::Size();
  27. }
  28. gfx::Rect TestNativeTheme::GetNinePatchAperture(Part part) const {
  29. return gfx::Rect();
  30. }
  31. bool TestNativeTheme::UserHasContrastPreference() const {
  32. return contrast_preference_;
  33. }
  34. bool TestNativeTheme::ShouldUseDarkColors() const {
  35. return dark_mode_;
  36. }
  37. NativeTheme::PreferredColorScheme TestNativeTheme::GetPreferredColorScheme()
  38. const {
  39. return CalculatePreferredColorScheme();
  40. }
  41. NativeTheme::ColorScheme TestNativeTheme::GetDefaultSystemColorScheme() const {
  42. if (is_platform_high_contrast_)
  43. return ColorScheme::kPlatformHighContrast;
  44. return NativeTheme::GetDefaultSystemColorScheme();
  45. }
  46. void TestNativeTheme::AddColorSchemeNativeThemeObserver(
  47. NativeTheme* theme_to_update) {
  48. color_scheme_observer_ =
  49. std::make_unique<ui::NativeTheme::ColorSchemeNativeThemeObserver>(
  50. theme_to_update);
  51. AddObserver(color_scheme_observer_.get());
  52. }
  53. } // namespace ui