forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dark Mode: split out TestNativeTheme as a separate class/target
There was a handy dandy testing version of NativeTheme in view_unittest.cc that I'd like to reuse in upcoming unit tests for WebUI Dark Mode support (https://crrev.com/c/1354685). BUG=883049 R=sky@chromium.org Change-Id: Ie39f6c42f5069450ec9933b1b83d4cb615ab713d Reviewed-on: https://chromium-review.googlesource.com/c/1357607 Commit-Queue: Dan Beam <dbeam@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Cr-Commit-Position: refs/heads/master@{#613233}
- Loading branch information
Showing
5 changed files
with
113 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ui/native_theme/test_native_theme.h" | ||
|
||
namespace ui { | ||
|
||
TestNativeTheme::TestNativeTheme() {} | ||
TestNativeTheme::~TestNativeTheme() {} | ||
|
||
SkColor TestNativeTheme::GetSystemColor(ColorId color_id) const { | ||
return SK_ColorRED; | ||
} | ||
|
||
gfx::Size TestNativeTheme::GetPartSize(Part part, | ||
State state, | ||
const ExtraParams& extra) const { | ||
return gfx::Size(); | ||
} | ||
|
||
void TestNativeTheme::Paint(cc::PaintCanvas* canvas, | ||
Part part, | ||
State state, | ||
const gfx::Rect& rect, | ||
const ExtraParams& extra) const {} | ||
|
||
bool TestNativeTheme::SupportsNinePatch(Part part) const { | ||
return false; | ||
} | ||
|
||
gfx::Size TestNativeTheme::GetNinePatchCanvasSize(Part part) const { | ||
return gfx::Size(); | ||
} | ||
|
||
gfx::Rect TestNativeTheme::GetNinePatchAperture(Part part) const { | ||
return gfx::Rect(); | ||
} | ||
|
||
bool TestNativeTheme::UsesHighContrastColors() const { | ||
return false; | ||
} | ||
|
||
bool TestNativeTheme::SystemDarkModeEnabled() const { | ||
return dark_mode_; | ||
} | ||
|
||
} // namespace ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef UI_NATIVE_THEME_TEST_NATIVE_THEME_H_ | ||
#define UI_NATIVE_THEME_TEST_NATIVE_THEME_H_ | ||
|
||
#include "base/macros.h" | ||
#include "ui/native_theme/native_theme.h" | ||
|
||
namespace ui { | ||
|
||
class TestNativeTheme : public NativeTheme { | ||
public: | ||
TestNativeTheme(); | ||
~TestNativeTheme() override; | ||
|
||
// NativeTheme: | ||
SkColor GetSystemColor(ColorId color_id) const override; | ||
gfx::Size GetPartSize(Part part, | ||
State state, | ||
const ExtraParams& extra) const override; | ||
void Paint(cc::PaintCanvas* canvas, | ||
Part part, | ||
State state, | ||
const gfx::Rect& rect, | ||
const ExtraParams& extra) const override; | ||
bool SupportsNinePatch(Part part) const override; | ||
gfx::Size GetNinePatchCanvasSize(Part part) const override; | ||
gfx::Rect GetNinePatchAperture(Part part) const override; | ||
bool UsesHighContrastColors() const override; | ||
bool SystemDarkModeEnabled() const override; | ||
|
||
void SetDarkMode(bool dark_mode) { dark_mode_ = dark_mode; } | ||
|
||
private: | ||
bool dark_mode_ = false; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(TestNativeTheme); | ||
}; | ||
|
||
} // namespace ui | ||
|
||
#endif // UI_NATIVE_THEME_TEST_NATIVE_THEME_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters