CupertinoTheme & CupertinoTextTheme dark mode updates (#41859)

This commit is contained in:
LongCatIsLooong
2019-10-28 15:50:08 -07:00
committed by GitHub
parent 20e015ffe6
commit 4ac2daf337
22 changed files with 743 additions and 330 deletions

View File

@@ -127,6 +127,12 @@ const Matcher isInCard = _IsInCard();
/// * [isInCard], the opposite.
const Matcher isNotInCard = _IsNotInCard();
/// Asserts that the object represents the same color as [color] when used to paint.
///
/// Specifically this matcher checks the object is of type [Color] and its [Color.value]
/// equals to that of the given [color].
Matcher isSameColorAs(Color color) => _ColorMatcher(targetColor: color);
/// Asserts that an object's toString() is a plausible one-line description.
///
/// Specifically, this matcher checks that the string does not contains newline
@@ -1609,6 +1615,24 @@ class _CoversSameAreaAs extends Matcher {
description.add('covers expected area and only expected area');
}
class _ColorMatcher extends Matcher {
const _ColorMatcher({
@required this.targetColor,
}) : assert(targetColor != null);
final Color targetColor;
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
if (item is Color)
return item.value == targetColor.value;
return false;
}
@override
Description describe(Description description) => description.add('matches color $targetColor');
}
Future<ui.Image> _captureImage(Element element) {
RenderObject renderObject = element.renderObject;
while (!renderObject.isRepaintBoundary) {

View File

@@ -237,6 +237,33 @@ void main() {
);
});
test('isSameColorAs', () {
expect(
const Color(0x87654321),
isSameColorAs(_CustomColor(0x87654321)),
);
expect(
_CustomColor(0x87654321),
isSameColorAs(const Color(0x87654321)),
);
expect(
const Color(0x12345678),
isNot(isSameColorAs(_CustomColor(0x87654321))),
);
expect(
_CustomColor(0x87654321),
isNot(isSameColorAs(const Color(0x12345678))),
);
expect(
_CustomColor(0xFF123456),
isSameColorAs(_CustomColor(0xFF123456)..isEqual = false),
);
});
group('coversSameAreaAs', () {
test('empty Paths', () {
expect(
@@ -676,3 +703,14 @@ class _FakeSemanticsNode extends SemanticsNode {
@override
SemanticsData getSemanticsData() => data;
}
class _CustomColor extends Color {
_CustomColor(int value) : super(value);
bool isEqual;
@override
bool operator ==(dynamic other) => isEqual ?? super == other;
@override
int get hashCode => hashValues(super.hashCode, isEqual);
}