Merge "Updating MaterialDynamicColor to match cl/523763539" into udc-dev

This commit is contained in:
Marcelo Arteiro
2023-04-27 08:13:06 +00:00
committed by Android (Google) Code Review
14 changed files with 1260 additions and 1157 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2023 The Android Open Source Project * Copyright (C) 2022 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -71,12 +71,11 @@ public final class DynamicColor {
* The base constructor for DynamicColor. * The base constructor for DynamicColor.
* *
* <p>Functional arguments allow overriding without risks that come with subclasses. _Strongly_ * <p>Functional arguments allow overriding without risks that come with subclasses. _Strongly_
* prefer using one of the static convenience constructors. This class is arguably too flexible * prefer using one of the static convenience constructors. This class is arguably too
* to * flexible to
* ensure it can support any scenario. * ensure it can support any scenario.
* *
* <p>For example, the default behavior of adjust tone at max contrast to be at a 7.0 ratio * <p>For example, the default behavior of adjust tone at max contrast to be at a 7.0 ratio with
* with
* its background is principled and matches a11y guidance. That does not mean it's the desired * its background is principled and matches a11y guidance. That does not mean it's the desired
* approach for _every_ design system, and every color pairing, always, in every case. * approach for _every_ design system, and every color pairing, always, in every case.
* *
@@ -90,22 +89,22 @@ public final class DynamicColor {
* made. * made.
* @param toneMinContrast given DynamicScheme, return tone in HCT/L* in L*a*b* this color * @param toneMinContrast given DynamicScheme, return tone in HCT/L* in L*a*b* this color
* should * should
* be at minimum contrast. See toneMinContrastDefault for the default * be at minimum contrast. See toneMinContrastDefault for the
* behavior, and strongly * default behavior, and strongly
* consider using it unless you have strong opinions on a11y. The * consider using it unless you have strong opinions on a11y. The
* static constructors use it. * static constructors use it.
* @param toneMaxContrast given DynamicScheme, return tone in HCT/L* in L*a*b* this color * @param toneMaxContrast given DynamicScheme, return tone in HCT/L* in L*a*b* this color
* should * should
* be at maximum contrast. See toneMaxContrastDefault for the default * be at maximum contrast. See toneMaxContrastDefault for the
* behavior, and strongly * default behavior, and strongly
* consider using it unless you have strong opinions on a11y. The * consider using it unless you have strong opinions on a11y. The
* static constructors use it. * static constructors use it.
* @param toneDeltaConstraint given DynamicScheme, return a ToneDeltaConstraint instance that * @param toneDeltaConstraint given DynamicScheme, return a ToneDeltaConstraint instance that
* describes a requirement that this DynamicColor must always have * describes a requirement that this DynamicColor must always have
* some difference in tone/L* * some difference in tone/L*
* from another DynamicColor.<br> * from another DynamicColor.<br>
* Unlikely to be useful unless a design system has some distortions * Unlikely to be useful unless a design system has some
* where colors that don't * distortions where colors that don't
* have a background/foreground relationship must have _some_ * have a background/foreground relationship must have _some_
* difference in tone, yet, not * difference in tone, yet, not
* enough difference to create meaningful contrast. * enough difference to create meaningful contrast.
@@ -164,8 +163,8 @@ public final class DynamicColor {
* <p>If the design system uses the same hex code on multiple backgrounds, define that in * <p>If the design system uses the same hex code on multiple backgrounds, define that in
* multiple * multiple
* DynamicColors so that the background is accurate for each one. If you define a DynamicColor * DynamicColors so that the background is accurate for each one. If you define a DynamicColor
* with one background, and actually use it on another, DynamicColor can't guarantee contrast. * with one background, and actually use it on another, DynamicColor can't guarantee contrast
* For * . For
* example, if you use a color on both black and white, increasing the contrast on one * example, if you use a color on both black and white, increasing the contrast on one
* necessarily * necessarily
* decreases contrast of the other. * decreases contrast of the other.
@@ -195,8 +194,8 @@ public final class DynamicColor {
* for contrast, given a background, colors can adjust to * for contrast, given a background, colors can adjust to
* increase/decrease contrast. * increase/decrease contrast.
* @param toneDeltaConstraint Function that provides a ToneDeltaConstraint given DynamicScheme. * @param toneDeltaConstraint Function that provides a ToneDeltaConstraint given DynamicScheme.
* Useful for ensuring lightness difference between colors that don't * Useful for ensuring lightness difference between colors that
* _require_ contrast or * don't _require_ contrast or
* have a formal background/foreground relationship. * have a formal background/foreground relationship.
*/ */
public static DynamicColor fromArgb( public static DynamicColor fromArgb(
@@ -212,17 +211,17 @@ public final class DynamicColor {
* Create a DynamicColor. * Create a DynamicColor.
* *
* @param palette Function that provides a TonalPalette given DynamicScheme. A TonalPalette is * @param palette Function that provides a TonalPalette given DynamicScheme. A TonalPalette is
* defined by a hue and chroma, so this replaces the need to specify hue/chroma. * defined by a hue and chroma, so this replaces the need to specify
* By providing * hue/chroma. By providing
* a tonal palette, when contrast adjustments are made, intended chroma can be * a tonal palette, when contrast adjustments are made, intended chroma can be
* preserved. For * preserved. For
* example, at T/L* 90, there is a significant limit to the amount of chroma. * example, at T/L* 90, there is a significant limit to the amount of chroma.
* There is no * There is no
* colorful red, a red that light is pink. By preserving the _intended_ chroma if * colorful red, a red that light is pink. By preserving the _intended_ chroma
* lightness * if lightness
* lowers for contrast adjustments, the intended chroma is restored. * lowers for contrast adjustments, the intended chroma is restored.
* @param tone Function that provides a tone given DynamicScheme. (useful for dark vs. light * @param tone Function that provides a tone given DynamicScheme. (useful for dark vs.
* mode) * light mode)
*/ */
public static DynamicColor fromPalette( public static DynamicColor fromPalette(
Function<DynamicScheme, TonalPalette> palette, Function<DynamicScheme, Double> tone) { Function<DynamicScheme, TonalPalette> palette, Function<DynamicScheme, Double> tone) {
@@ -232,16 +231,16 @@ public final class DynamicColor {
/** /**
* Create a DynamicColor. * Create a DynamicColor.
* *
* @param palette Function that provides a TonalPalette given DynamicScheme. A TonalPalette * @param palette Function that provides a TonalPalette given DynamicScheme. A
* is * TonalPalette is
* defined by a hue and chroma, so this replaces the need to specify * defined by a hue and chroma, so this replaces the need to specify
* hue/chroma. By providing * hue/chroma. By providing
* a tonal palette, when contrast adjustments are made, intended chroma can be * a tonal palette, when contrast adjustments are made, intended chroma can
* preserved. For * be preserved. For
* example, at T/L* 90, there is a significant limit to the amount of chroma. * example, at T/L* 90, there is a significant limit to the amount of
* There is no * chroma. There is no
* colorful red, a red that light is pink. By preserving the _intended_ chroma * colorful red, a red that light is pink. By preserving the _intended_
* if lightness * chroma if lightness
* lowers for contrast adjustments, the intended chroma is restored. * lowers for contrast adjustments, the intended chroma is restored.
* @param tone Function that provides a tone given DynamicScheme. (useful for dark vs. * @param tone Function that provides a tone given DynamicScheme. (useful for dark vs.
* light mode) * light mode)
@@ -261,12 +260,12 @@ public final class DynamicColor {
* *
* @param palette Function that provides a TonalPalette given DynamicScheme. A * @param palette Function that provides a TonalPalette given DynamicScheme. A
* TonalPalette is * TonalPalette is
* defined by a hue and chroma, so this replaces the need to specify * defined by a hue and chroma, so this replaces the need to
* hue/chroma. By providing * specify hue/chroma. By providing
* a tonal palette, when contrast adjustments are made, intended * a tonal palette, when contrast adjustments are made, intended
* chroma can be preserved. For * chroma can be preserved. For
* example, at T/L* 90, there is a significant limit to the amount of * example, at T/L* 90, there is a significant limit to the amount
* chroma. There is no * of chroma. There is no
* colorful red, a red that light is pink. By preserving the * colorful red, a red that light is pink. By preserving the
* _intended_ chroma if lightness * _intended_ chroma if lightness
* lowers for contrast adjustments, the intended chroma is restored. * lowers for contrast adjustments, the intended chroma is restored.
@@ -277,8 +276,8 @@ public final class DynamicColor {
* for contrast, given a background, colors can adjust to * for contrast, given a background, colors can adjust to
* increase/decrease contrast. * increase/decrease contrast.
* @param toneDeltaConstraint Function that provides a ToneDeltaConstraint given DynamicScheme. * @param toneDeltaConstraint Function that provides a ToneDeltaConstraint given DynamicScheme.
* Useful for ensuring lightness difference between colors that don't * Useful for ensuring lightness difference between colors that
* _require_ contrast or * don't _require_ contrast or
* have a formal background/foreground relationship. * have a formal background/foreground relationship.
*/ */
public static DynamicColor fromPalette( public static DynamicColor fromPalette(
@@ -297,96 +296,6 @@ public final class DynamicColor {
toneDeltaConstraint); toneDeltaConstraint);
} }
/** Returns the ARGB (i.e. hex code) representation of the resolved color given scheme. */
public int getArgb(DynamicScheme scheme) {
final int argb = getHct(scheme).toInt();
if (opacity == null) {
return argb;
}
final double percentage = opacity.apply(scheme);
final int alpha = MathUtils.clampInt(0, 255, (int) Math.round(percentage * 255));
return (argb & 0x00ffffff) | (alpha << 24);
}
/** Returns the HCT representation of the resolved color given scheme. */
public Hct getHct(DynamicScheme scheme) {
final Hct cachedAnswer = hctCache.get(scheme);
if (cachedAnswer != null) {
return cachedAnswer;
}
// This is crucial for aesthetics: we aren't simply the taking the standard color
// and changing its tone for contrast. Rather, we find the tone for contrast, then
// use the specified chroma from the palette to construct a new color.
//
// For example, this enables colors with standard tone of T90, which has limited chroma, to
// "recover" intended chroma as contrast increases.
final Hct answer = Hct.from(hue.apply(scheme), chroma.apply(scheme), getTone(scheme));
// NOMUTANTS--trivial test with onerous dependency injection requirement.
if (hctCache.size() > 4) {
hctCache.clear();
}
// NOMUTANTS--trivial test with onerous dependency injection requirement.
hctCache.put(scheme, answer);
return answer;
}
/** Returns the tone in HCT, ranging from 0 to 100, of the resolved color given scheme. */
public double getTone(DynamicScheme scheme) {
double answer = tone.apply(scheme);
final boolean decreasingContrast = scheme.contrastLevel < 0.0;
if (scheme.contrastLevel != 0.0) {
final double startTone = tone.apply(scheme);
final double endTone =
decreasingContrast ? toneMinContrast.apply(scheme) : toneMaxContrast.apply(
scheme);
final double delta = (endTone - startTone) * Math.abs(scheme.contrastLevel);
answer = delta + startTone;
}
final DynamicColor bgDynamicColor = background == null ? null : background.apply(scheme);
double minRatio = Contrast.RATIO_MIN;
double maxRatio = Contrast.RATIO_MAX;
if (bgDynamicColor != null) {
final boolean bgHasBg =
bgDynamicColor.background != null && bgDynamicColor.background.apply(scheme)
!= null;
final double standardRatio =
Contrast.ratioOfTones(tone.apply(scheme), bgDynamicColor.tone.apply(scheme));
if (decreasingContrast) {
final double minContrastRatio =
Contrast.ratioOfTones(
toneMinContrast.apply(scheme),
bgDynamicColor.toneMinContrast.apply(scheme));
minRatio = bgHasBg ? minContrastRatio : 1.0;
maxRatio = standardRatio;
} else {
final double maxContrastRatio =
Contrast.ratioOfTones(
toneMaxContrast.apply(scheme),
bgDynamicColor.toneMaxContrast.apply(scheme));
minRatio = bgHasBg ? min(maxContrastRatio, standardRatio) : 1.0;
maxRatio = bgHasBg ? max(maxContrastRatio, standardRatio) : 21.0;
}
}
final double finalMinRatio = minRatio;
final double finalMaxRatio = maxRatio;
final double finalAnswer = answer;
answer =
calculateDynamicTone(
scheme,
this.tone,
(dynamicColor) -> dynamicColor.getTone(scheme),
(a, b) -> finalAnswer,
(s) -> bgDynamicColor,
toneDeltaConstraint,
(s) -> finalMinRatio,
(s) -> finalMaxRatio);
return answer;
}
/** /**
* The default algorithm for calculating the tone of a color at minimum contrast.<br> * The default algorithm for calculating the tone of a color at minimum contrast.<br>
* If the original contrast ratio was >= 7.0, reach contrast 4.5.<br> * If the original contrast ratio was >= 7.0, reach contrast 4.5.<br>
@@ -475,8 +384,8 @@ public final class DynamicColor {
* <p>It enforces important properties:<br> * <p>It enforces important properties:<br>
* #1. Desired contrast ratio is reached.<br> * #1. Desired contrast ratio is reached.<br>
* As contrast increases from standard to max, the tones involved should always be at least the * As contrast increases from standard to max, the tones involved should always be at least the
* standard ratio. For example, if a button is T90, and button text is T0, and the button is T0 * standard ratio. For example, if a button is T90, and button text is T0, and the button is
* at * T0 at
* max contrast, the button text cannot simply linearly interpolate from T0 to T100, or at some * max contrast, the button text cannot simply linearly interpolate from T0 to T100, or at some
* point they'll both be at the same tone. * point they'll both be at the same tone.
* *
@@ -489,8 +398,7 @@ public final class DynamicColor {
* *
* <p>#3. Ensure tone delta with another color.<br> * <p>#3. Ensure tone delta with another color.<br>
* In design systems, there may be colors that don't have a pure background/foreground * In design systems, there may be colors that don't have a pure background/foreground
* relationship, but, do require different tones for visual differentiation. * relationship, but, do require different tones for visual differentiation. ToneDeltaConstraint
* ToneDeltaConstraint
* models this requirement, and DynamicColor enforces it. * models this requirement, and DynamicColor enforces it.
*/ */
public static double calculateDynamicTone( public static double calculateDynamicTone(
@@ -596,13 +504,16 @@ public final class DynamicColor {
final boolean preferLighter = tonePrefersLightForeground(bgTone); final boolean preferLighter = tonePrefersLightForeground(bgTone);
if (preferLighter) { if (preferLighter) {
// "Negligible difference" handles an edge case where the initial contrast ratio is high // "Neglible difference" handles an edge case where the initial contrast ratio is high
// (ex. 13.0), and the ratio passed to the function is that high ratio, and both the // (ex. 13.0), and the ratio passed to the function is that high ratio, and both the
// lighter and darker ratio fails to pass that ratio. // lighter
// and darker ratio fails to pass that ratio.
// //
// This was observed with Tonal Spot's On Primary Container turning black momentarily // This was observed with Tonal Spot's On Primary Container turning black momentarily
// between high and max contrast in light mode. PC's standard tone was T90, OPC's was // between
// T10, it was light mode, and the contrast level was 0.6568521221032331. // high and max contrast in light mode. PC's standard tone was T90, OPC's was T10, it
// was
// light mode, and the contrast level was 0.6568521221032331.
final boolean negligibleDifference = final boolean negligibleDifference =
Math.abs(lighterRatio - darkerRatio) < 0.1 && lighterRatio < ratio Math.abs(lighterRatio - darkerRatio) < 0.1 && lighterRatio < ratio
&& darkerRatio < ratio; && darkerRatio < ratio;
@@ -634,13 +545,109 @@ public final class DynamicColor {
* <p>T60 used as to create the smallest discontinuity possible when skipping down to T49 in * <p>T60 used as to create the smallest discontinuity possible when skipping down to T49 in
* order * order
* to ensure light foregrounds. * to ensure light foregrounds.
*
* <p>Since `tertiaryContainer` in dark monochrome scheme requires a tone of 60, it should
* not be
* adjusted. Therefore, 60 is excluded here.
*/ */
public static boolean tonePrefersLightForeground(double tone) { public static boolean tonePrefersLightForeground(double tone) {
return Math.round(tone) <= 60; return Math.round(tone) < 60;
} }
/** Tones less than ~T50 always permit white at 4.5 contrast. */ /**
* Tones less than ~T50 always permit white at 4.5 contrast.
*/
public static boolean toneAllowsLightForeground(double tone) { public static boolean toneAllowsLightForeground(double tone) {
return Math.round(tone) <= 49; return Math.round(tone) <= 49;
} }
public int getArgb(DynamicScheme scheme) {
final int argb = getHct(scheme).toInt();
if (opacity == null) {
return argb;
}
final double percentage = opacity.apply(scheme);
final int alpha = MathUtils.clampInt(0, 255, (int) Math.round(percentage * 255));
return (argb & 0x00ffffff) | (alpha << 24);
}
public Hct getHct(DynamicScheme scheme) {
final Hct cachedAnswer = hctCache.get(scheme);
if (cachedAnswer != null) {
return cachedAnswer;
}
// This is crucial for aesthetics: we aren't simply the taking the standard color
// and changing its tone for contrast. Rather, we find the tone for contrast, then
// use the specified chroma from the palette to construct a new color.
//
// For example, this enables colors with standard tone of T90, which has limited chroma, to
// "recover" intended chroma as contrast increases.
final Hct answer = Hct.from(hue.apply(scheme), chroma.apply(scheme), getTone(scheme));
// NOMUTANTS--trivial test with onerous dependency injection requirement.
if (hctCache.size() > 4) {
hctCache.clear();
}
// NOMUTANTS--trivial test with onerous dependency injection requirement.
hctCache.put(scheme, answer);
return answer;
}
/**
* Returns the tone in HCT, ranging from 0 to 100, of the resolved color given scheme.
*/
public double getTone(DynamicScheme scheme) {
double answer = tone.apply(scheme);
final boolean decreasingContrast = scheme.contrastLevel < 0.0;
if (scheme.contrastLevel != 0.0) {
final double startTone = tone.apply(scheme);
final double endTone =
decreasingContrast ? toneMinContrast.apply(scheme) : toneMaxContrast.apply(
scheme);
final double delta = (endTone - startTone) * Math.abs(scheme.contrastLevel);
answer = delta + startTone;
}
final DynamicColor bgDynamicColor = background == null ? null : background.apply(scheme);
double minRatio = Contrast.RATIO_MIN;
double maxRatio = Contrast.RATIO_MAX;
if (bgDynamicColor != null) {
final boolean bgHasBg =
bgDynamicColor.background != null && bgDynamicColor.background.apply(scheme)
!= null;
final double standardRatio =
Contrast.ratioOfTones(tone.apply(scheme), bgDynamicColor.tone.apply(scheme));
if (decreasingContrast) {
final double minContrastRatio =
Contrast.ratioOfTones(
toneMinContrast.apply(scheme),
bgDynamicColor.toneMinContrast.apply(scheme));
minRatio = bgHasBg ? minContrastRatio : 1.0;
maxRatio = standardRatio;
} else {
final double maxContrastRatio =
Contrast.ratioOfTones(
toneMaxContrast.apply(scheme),
bgDynamicColor.toneMaxContrast.apply(scheme));
minRatio = bgHasBg ? min(maxContrastRatio, standardRatio) : 1.0;
maxRatio = bgHasBg ? max(maxContrastRatio, standardRatio) : 21.0;
}
}
final double finalMinRatio = minRatio;
final double finalMaxRatio = maxRatio;
final double finalAnswer = answer;
answer =
calculateDynamicTone(
scheme,
this.tone,
(dynamicColor) -> dynamicColor.getTone(scheme),
(a, b) -> finalAnswer,
(s) -> bgDynamicColor,
toneDeltaConstraint,
(s) -> finalMinRatio,
(s) -> finalMaxRatio);
return answer;
}
} }

View File

@@ -22,7 +22,7 @@ import com.android.systemui.monet.hct.ViewingConditions;
import com.android.systemui.monet.scheme.DynamicScheme; import com.android.systemui.monet.scheme.DynamicScheme;
import com.android.systemui.monet.scheme.Variant; import com.android.systemui.monet.scheme.Variant;
/** Named colors, otherwise known as tokens, or roles, in the Material Design system. */ /** Named colors, otherwise known as tokens, or roles, in the Material Design system.*/
// Prevent lint for Function.apply not being available on Android before API level 14 (4.0.1). // Prevent lint for Function.apply not being available on Android before API level 14 (4.0.1).
// "AndroidJdkLibsChecker" for Function, "NewApi" for Function.apply(). // "AndroidJdkLibsChecker" for Function, "NewApi" for Function.apply().
// A java_library Bazel rule with an Android constraint cannot skip these warnings without this // A java_library Bazel rule with an Android constraint cannot skip these warnings without this
@@ -33,341 +33,54 @@ public final class MaterialDynamicColors {
private static final double CONTAINER_ACCENT_TONE_DELTA = 15.0; private static final double CONTAINER_ACCENT_TONE_DELTA = 15.0;
private MaterialDynamicColors() { public MaterialDynamicColors() {
} }
public static DynamicColor highestSurface(DynamicScheme s) {
return s.isDark ? surfaceBright : surfaceDim;
}
public static final DynamicColor background =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 98.0);
public static final DynamicColor onBackground =
DynamicColor.fromPalette(
(s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 10.0, (s) -> background);
public static final DynamicColor surface =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 98.0);
public static final DynamicColor surfaceInverse =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 30.0);
public static final DynamicColor surfaceBright =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 24.0 : 98.0);
public static final DynamicColor surfaceDim =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 87.0);
public static final DynamicColor surfaceSub2 =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 4.0 : 100.0);
public static final DynamicColor surfaceSub1 =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 96.0);
public static final DynamicColor surfaceContainer =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 12.0 : 94.0);
public static final DynamicColor surfaceAdd1 =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 17.0 : 92.0);
public static final DynamicColor surfaceAdd2 =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 22.0 : 90.0);
public static final DynamicColor onSurface =
DynamicColor.fromPalette(
(s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 10.0,
(s) -> highestSurface(s));
public static final DynamicColor onSurfaceInverse =
DynamicColor.fromPalette(
(s) -> s.neutralPalette, (s) -> s.isDark ? 20.0 : 95.0, (s) -> surfaceInverse);
public static final DynamicColor surfaceVariant =
DynamicColor.fromPalette((s) -> s.neutralVariantPalette, (s) -> s.isDark ? 30.0 : 90.0);
public static final DynamicColor onSurfaceVariant =
DynamicColor.fromPalette(
(s) -> s.neutralVariantPalette, (s) -> s.isDark ? 80.0 : 30.0,
(s) -> surfaceVariant);
public static final DynamicColor outline =
DynamicColor.fromPalette(
(s) -> s.neutralVariantPalette, (s) -> 50.0, (s) -> highestSurface(s));
public static final DynamicColor outlineVariant =
DynamicColor.fromPalette(
(s) -> s.neutralVariantPalette, (s) -> s.isDark ? 30.0 : 80.0,
(s) -> highestSurface(s));
public static final DynamicColor primaryContainer =
DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> {
if (!isFidelity(s)) {
return s.isDark ? 30.0 : 90.0;
}
return performAlbers(s.sourceColorHct, s);
},
(s) -> highestSurface(s));
public static final DynamicColor onPrimaryContainer =
DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> {
if (!isFidelity(s)) {
return s.isDark ? 90.0 : 10.0;
}
return DynamicColor.contrastingTone(primaryContainer.tone.apply(s), 4.5);
},
(s) -> primaryContainer,
null);
public static final DynamicColor primary =
DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> s.isDark ? 80.0 : 40.0,
(s) -> highestSurface(s),
(s) ->
new ToneDeltaConstraint(
CONTAINER_ACCENT_TONE_DELTA,
primaryContainer,
s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
public static final DynamicColor primaryInverse =
DynamicColor.fromPalette(
(s) -> s.primaryPalette, (s) -> s.isDark ? 40.0 : 80.0, (s) -> surfaceInverse);
public static final DynamicColor onPrimary =
DynamicColor.fromPalette(
(s) -> s.primaryPalette, (s) -> s.isDark ? 20.0 : 100.0, (s) -> primary);
public static final DynamicColor secondaryContainer =
DynamicColor.fromPalette(
(s) -> s.secondaryPalette,
(s) -> {
final double initialTone = s.isDark ? 30.0 : 90.0;
if (!isFidelity(s)) {
return initialTone;
}
double answer =
findDesiredChromaByTone(
s.secondaryPalette.getHue(),
s.secondaryPalette.getChroma(),
initialTone,
!s.isDark);
answer = performAlbers(s.secondaryPalette.getHct(answer), s);
return answer;
},
(s) -> highestSurface(s));
public static final DynamicColor onSecondaryContainer =
DynamicColor.fromPalette(
(s) -> s.secondaryPalette,
(s) -> {
if (!isFidelity(s)) {
return s.isDark ? 90.0 : 10.0;
}
return DynamicColor.contrastingTone(secondaryContainer.tone.apply(s), 4.5);
},
(s) -> secondaryContainer);
public static final DynamicColor secondary =
DynamicColor.fromPalette(
(s) -> s.secondaryPalette,
(s) -> s.isDark ? 80.0 : 40.0,
(s) -> highestSurface(s),
(s) ->
new ToneDeltaConstraint(
CONTAINER_ACCENT_TONE_DELTA,
secondaryContainer,
s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
public static final DynamicColor onSecondary =
DynamicColor.fromPalette(
(s) -> s.secondaryPalette, (s) -> s.isDark ? 20.0 : 100.0, (s) -> secondary);
public static final DynamicColor tertiaryContainer =
DynamicColor.fromPalette(
(s) -> s.tertiaryPalette,
(s) -> {
if (!isFidelity(s)) {
return s.isDark ? 30.0 : 90.0;
}
final double albersTone =
performAlbers(s.tertiaryPalette.getHct(s.sourceColorHct.getTone()),
s);
final Hct proposedHct = s.tertiaryPalette.getHct(albersTone);
return DislikeAnalyzer.fixIfDisliked(proposedHct).getTone();
},
(s) -> highestSurface(s));
public static final DynamicColor onTertiaryContainer =
DynamicColor.fromPalette(
(s) -> s.tertiaryPalette,
(s) -> {
if (!isFidelity(s)) {
return s.isDark ? 90.0 : 10.0;
}
return DynamicColor.contrastingTone(tertiaryContainer.tone.apply(s), 4.5);
},
(s) -> tertiaryContainer);
public static final DynamicColor tertiary =
DynamicColor.fromPalette(
(s) -> s.tertiaryPalette,
(s) -> s.isDark ? 80.0 : 40.0,
(s) -> highestSurface(s),
(s) ->
new ToneDeltaConstraint(
CONTAINER_ACCENT_TONE_DELTA,
tertiaryContainer,
s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
public static final DynamicColor onTertiary =
DynamicColor.fromPalette(
(s) -> s.tertiaryPalette, (s) -> s.isDark ? 20.0 : 100.0, (s) -> tertiary);
public static final DynamicColor errorContainer =
DynamicColor.fromPalette(
(s) -> s.errorPalette, (s) -> s.isDark ? 30.0 : 90.0, (s) -> highestSurface(s));
public static final DynamicColor onErrorContainer =
DynamicColor.fromPalette(
(s) -> s.errorPalette, (s) -> s.isDark ? 90.0 : 10.0, (s) -> errorContainer);
public static final DynamicColor error =
DynamicColor.fromPalette(
(s) -> s.errorPalette,
(s) -> s.isDark ? 80.0 : 40.0,
(s) -> highestSurface(s),
(s) ->
new ToneDeltaConstraint(
CONTAINER_ACCENT_TONE_DELTA,
errorContainer,
s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
public static final DynamicColor onError =
DynamicColor.fromPalette((s) -> s.errorPalette, (s) -> s.isDark ? 20.0 : 100.0,
(s) -> error);
public static final DynamicColor primaryFixed =
DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> 90.0,
(s) -> highestSurface(s));
public static final DynamicColor primaryFixedDarker =
DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> 80.0,
(s) -> highestSurface(s));
public static final DynamicColor onPrimaryFixed =
DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> 10.0,
(s) -> primaryFixedDarker);
public static final DynamicColor onPrimaryFixedVariant =
DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> 30.0,
(s) -> primaryFixedDarker);
public static final DynamicColor secondaryFixed =
DynamicColor.fromPalette((s) -> s.secondaryPalette, (s) -> 90.0,
(s) -> highestSurface(s));
public static final DynamicColor secondaryFixedDarker =
DynamicColor.fromPalette((s) -> s.secondaryPalette, (s) -> 80.0,
(s) -> highestSurface(s));
public static final DynamicColor onSecondaryFixed =
DynamicColor.fromPalette((s) -> s.secondaryPalette, (s) -> 10.0,
(s) -> secondaryFixedDarker);
public static final DynamicColor onSecondaryFixedVariant =
DynamicColor.fromPalette((s) -> s.secondaryPalette, (s) -> 30.0,
(s) -> secondaryFixedDarker);
public static final DynamicColor tertiaryFixed =
DynamicColor.fromPalette((s) -> s.tertiaryPalette, (s) -> 90.0,
(s) -> highestSurface(s));
public static final DynamicColor tertiaryFixedDarker =
DynamicColor.fromPalette((s) -> s.tertiaryPalette, (s) -> 80.0,
(s) -> highestSurface(s));
public static final DynamicColor onTertiaryFixed =
DynamicColor.fromPalette((s) -> s.tertiaryPalette, (s) -> 10.0,
(s) -> tertiaryFixedDarker);
public static final DynamicColor onTertiaryFixedVariant =
DynamicColor.fromPalette((s) -> s.tertiaryPalette, (s) -> 30.0,
(s) -> tertiaryFixedDarker);
/** /**
* These colors were present in Android framework before Android U, and used by MDC controls. * These colors were present in Android framework before Android U, and used by MDC controls.
* They * They
* should be avoided, if possible. It's unclear if they're used on multiple backgrounds, and if * should be avoided, if possible. It's unclear if they're used on multiple backgrounds, and if
* they are, they can't be adjusted for contrast.* For now, they will be set with no * they are, they can't be adjusted for contrast.* For now, they will be set with no background,
* background,
* and those won't adjust for contrast, avoiding issues. * and those won't adjust for contrast, avoiding issues.
* *
* <p>* For example, if the same color is on a white background _and_ black background, there's * <p>* For example, if the same color is on a white background _and_ black background,
* no * there's no
* way to increase contrast with either without losing contrast with the other. * way to increase contrast with either without losing contrast with the other.
*/ */
// colorControlActivated documented as colorAccent in M3 & GM3. // colorControlActivated documented as colorAccent in M3 & GM3.
// colorAccent documented as colorSecondary in M3 and colorPrimary in GM3. // colorAccent documented as colorSecondary in M3 and colorPrimary in GM3.
// Android used Material's Container as Primary/Secondary/Tertiary at launch. // Android used Material's Container as Primary/Secondary/Tertiary at launch.
// Therefore, this is a duplicated version of Primary Container. // Therefore, this is a duplicated version of Primary Container.
public static final DynamicColor controlActivated = public static DynamicColor controlActivated() {
DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> s.isDark ? 30.0 : 90.0, null); return DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> s.isDark ? 30.0 : 90.0, null);
}
// colorControlNormal documented as textColorSecondary in M3 & GM3. // Compatibility Keys Colors for Android
// In Material, textColorSecondary points to onSurfaceVariant in the non-disabled state, public static DynamicColor primaryPaletteKeyColor() {
// which is Neutral Variant T30/80 in light/dark. return DynamicColor.fromPalette(
public static final DynamicColor controlNormal = (s) -> s.primaryPalette, (s) -> s.primaryPalette.getKeyColor().getTone());
DynamicColor.fromPalette((s) -> s.neutralVariantPalette, (s) -> s.isDark ? 80.0 : 30.0); }
// colorControlHighlight documented, in both M3 & GM3: public static DynamicColor secondaryPaletteKeyColor() {
// Light mode: #1f000000 dark mode: #33ffffff. return DynamicColor.fromPalette(
// These are black and white with some alpha. (s) -> s.secondaryPalette, (s) -> s.secondaryPalette.getKeyColor().getTone());
// 1F hex = 31 decimal; 31 / 255 = 12% alpha. }
// 33 hex = 51 decimal; 51 / 255 = 20% alpha.
// DynamicColors do not support alpha currently, and _may_ not need it for this use case,
// depending on how MDC resolved alpha for the other cases.
// Returning black in dark mode, white in light mode.
public static final DynamicColor controlHighlight =
new DynamicColor(
s -> 0.0,
s -> 0.0,
s -> s.isDark ? 100.0 : 0.0,
s -> s.isDark ? 0.20 : 0.12,
null,
scheme ->
DynamicColor.toneMinContrastDefault(
(s) -> s.isDark ? 100.0 : 0.0, null, scheme, null),
scheme ->
DynamicColor.toneMaxContrastDefault(
(s) -> s.isDark ? 100.0 : 0.0, null, scheme, null),
null);
// textColorPrimaryInverse documented, in both M3 & GM3, documented as N10/N90. public static DynamicColor tertiaryPaletteKeyColor() {
public static final DynamicColor textPrimaryInverse = return DynamicColor.fromPalette(
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0); (s) -> s.tertiaryPalette, (s) -> s.tertiaryPalette.getKeyColor().getTone());
}
// textColorSecondaryInverse and textColorTertiaryInverse both documented, in both M3 & GM3, as public static DynamicColor neutralPaletteKeyColor() {
// NV30/NV80 return DynamicColor.fromPalette(
public static final DynamicColor textSecondaryAndTertiaryInverse = (s) -> s.neutralPalette, (s) -> s.neutralPalette.getKeyColor().getTone());
DynamicColor.fromPalette((s) -> s.neutralVariantPalette, (s) -> s.isDark ? 30.0 : 80.0); }
// textColorPrimaryInverseDisableOnly documented, in both M3 & GM3, as N10/N90 public static DynamicColor neutralVariantPaletteKeyColor() {
public static final DynamicColor textPrimaryInverseDisableOnly = return DynamicColor.fromPalette(
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0); (s) -> s.neutralVariantPalette,
(s) -> s.neutralVariantPalette.getKeyColor().getTone());
// textColorSecondaryInverse and textColorTertiaryInverse in disabled state both documented, }
// in both M3 & GM3, as N10/N90
public static final DynamicColor textSecondaryAndTertiaryInverseDisabled =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
// textColorHintInverse documented, in both M3 & GM3, as N10/N90
public static final DynamicColor textHintInverse =
DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
private static ViewingConditions viewingConditionsForAlbers(DynamicScheme scheme) { private static ViewingConditions viewingConditionsForAlbers(DynamicScheme scheme) {
return ViewingConditions.defaultWithBackgroundLstar(scheme.isDark ? 30.0 : 80.0); return ViewingConditions.defaultWithBackgroundLstar(scheme.isDark ? 30.0 : 80.0);
@@ -377,6 +90,10 @@ public final class MaterialDynamicColors {
return scheme.variant == Variant.FIDELITY || scheme.variant == Variant.CONTENT; return scheme.variant == Variant.FIDELITY || scheme.variant == Variant.CONTENT;
} }
private static boolean isMonochrome(DynamicScheme scheme) {
return scheme.variant == Variant.MONOCHROME;
}
static double findDesiredChromaByTone( static double findDesiredChromaByTone(
double hue, double chroma, double tone, boolean byDecreasingTone) { double hue, double chroma, double tone, boolean byDecreasingTone) {
double answer = tone; double answer = tone;
@@ -416,34 +133,456 @@ public final class MaterialDynamicColors {
} }
} }
// Compatibility mappings for Android public static DynamicColor highestSurface(DynamicScheme s) {
public static final DynamicColor surfaceContainerLow = surfaceSub1; return s.isDark ? surfaceBright() : surfaceDim();
public static final DynamicColor surfaceContainerLowest = surfaceSub2; }
public static final DynamicColor surfaceContainerHigh = surfaceAdd1;
public static final DynamicColor surfaceContainerHighest = surfaceAdd2;
public static final DynamicColor primaryFixedDim = primaryFixedDarker;
public static final DynamicColor secondaryFixedDim = secondaryFixedDarker;
public static final DynamicColor tertiaryFixedDim = tertiaryFixedDarker;
// Compatibility Keys Colors for Android public static DynamicColor background() {
public static final DynamicColor primaryPaletteKeyColor = return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 98.0);
DynamicColor.fromPalette( }
(s) -> s.primaryPalette, (s) -> s.primaryPalette.getKeyColor().getTone());
public static final DynamicColor secondaryPaletteKeyColor = public static DynamicColor onBackground() {
DynamicColor.fromPalette( return DynamicColor.fromPalette(
(s) -> s.secondaryPalette, (s) -> s.secondaryPalette.getKeyColor().getTone()); (s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 10.0, (s) -> background());
}
public static final DynamicColor tertiaryPaletteKeyColor = public static DynamicColor surface() {
DynamicColor.fromPalette( return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 98.0);
(s) -> s.tertiaryPalette, (s) -> s.tertiaryPalette.getKeyColor().getTone()); }
public static final DynamicColor neutralPaletteKeyColor = public static DynamicColor inverseSurface() {
DynamicColor.fromPalette( return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 20.0);
(s) -> s.neutralPalette, (s) -> s.neutralPalette.getKeyColor().getTone()); }
public static final DynamicColor neutralVariantPaletteKeyColor = public static DynamicColor surfaceBright() {
DynamicColor.fromPalette( return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 24.0 : 98.0);
(s) -> s.neutralVariantPalette, }
(s) -> s.neutralVariantPalette.getKeyColor().getTone());
public static DynamicColor surfaceDim() {
return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 87.0);
}
public static DynamicColor surfaceContainerLowest() {
return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 4.0 : 100.0);
}
public static DynamicColor surfaceContainerLow() {
return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 96.0);
}
public static DynamicColor surfaceContainer() {
return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 12.0 : 94.0);
}
public static DynamicColor surfaceContainerHigh() {
return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 17.0 : 92.0);
}
public static DynamicColor surfaceContainerHighest() {
return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 22.0 : 90.0);
}
public static DynamicColor onSurface() {
return DynamicColor.fromPalette(
(s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 10.0,
MaterialDynamicColors::highestSurface);
}
public static DynamicColor inverseOnSurface() {
return DynamicColor.fromPalette(
(s) -> s.neutralPalette, (s) -> s.isDark ? 20.0 : 95.0, (s) -> inverseSurface());
}
public static DynamicColor surfaceVariant() {
return DynamicColor.fromPalette((s) -> s.neutralVariantPalette,
(s) -> s.isDark ? 30.0 : 90.0);
}
public static DynamicColor onSurfaceVariant() {
return DynamicColor.fromPalette(
(s) -> s.neutralVariantPalette, (s) -> s.isDark ? 80.0 : 30.0,
(s) -> surfaceVariant());
}
public static DynamicColor outline() {
return DynamicColor.fromPalette(
(s) -> s.neutralVariantPalette, (s) -> 50.0, MaterialDynamicColors::highestSurface);
}
public static DynamicColor outlineVariant() {
return DynamicColor.fromPalette(
(s) -> s.neutralVariantPalette, (s) -> s.isDark ? 30.0 : 80.0,
MaterialDynamicColors::highestSurface);
}
public static DynamicColor primaryContainer() {
return DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> {
if (isFidelity(s)) {
return performAlbers(s.sourceColorHct, s);
}
if (isMonochrome(s)) {
return s.isDark ? 85.0 : 25.0;
}
return s.isDark ? 30.0 : 90.0;
},
MaterialDynamicColors::highestSurface);
}
public static DynamicColor onPrimaryContainer() {
return DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> {
if (isFidelity(s)) {
return DynamicColor.contrastingTone(primaryContainer().tone.apply(s), 4.5);
}
if (isMonochrome(s)) {
return s.isDark ? 0.0 : 100.0;
}
return s.isDark ? 90.0 : 10.0;
},
(s) -> primaryContainer(),
null);
}
public static DynamicColor primary() {
return DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 100.0 : 0.0;
}
return s.isDark ? 80.0 : 40.0;
},
MaterialDynamicColors::highestSurface,
(s) ->
new ToneDeltaConstraint(
CONTAINER_ACCENT_TONE_DELTA,
primaryContainer(),
s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
}
public static DynamicColor inversePrimary() {
return DynamicColor.fromPalette(
(s) -> s.primaryPalette, (s) -> s.isDark ? 40.0 : 80.0, (s) -> inverseSurface());
}
public static DynamicColor onPrimary() {
return DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 10.0 : 90.0;
}
return s.isDark ? 20.0 : 100.0;
},
(s) -> primary());
}
public static DynamicColor secondaryContainer() {
return DynamicColor.fromPalette(
(s) -> s.secondaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 30.0 : 85.0;
}
final double initialTone = s.isDark ? 30.0 : 90.0;
if (!isFidelity(s)) {
return initialTone;
}
double answer =
findDesiredChromaByTone(
s.secondaryPalette.getHue(),
s.secondaryPalette.getChroma(),
initialTone,
!s.isDark);
answer = performAlbers(s.secondaryPalette.getHct(answer), s);
return answer;
},
MaterialDynamicColors::highestSurface);
}
public static DynamicColor onSecondaryContainer() {
return DynamicColor.fromPalette(
(s) -> s.secondaryPalette,
(s) -> {
if (!isFidelity(s)) {
return s.isDark ? 90.0 : 10.0;
}
return DynamicColor.contrastingTone(secondaryContainer().tone.apply(s), 4.5);
},
(s) -> secondaryContainer());
}
public static DynamicColor secondary() {
return DynamicColor.fromPalette(
(s) -> s.secondaryPalette,
(s) -> s.isDark ? 80.0 : 40.0,
MaterialDynamicColors::highestSurface,
(s) ->
new ToneDeltaConstraint(
CONTAINER_ACCENT_TONE_DELTA,
secondaryContainer(),
s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
}
public static DynamicColor onSecondary() {
return DynamicColor.fromPalette(
(s) -> s.secondaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 10.0 : 100.0;
}
return s.isDark ? 20.0 : 100.0;
},
(s) -> secondary());
}
public static DynamicColor tertiaryContainer() {
return DynamicColor.fromPalette(
(s) -> s.tertiaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 60.0 : 49.0;
}
if (!isFidelity(s)) {
return s.isDark ? 30.0 : 90.0;
}
final double albersTone =
performAlbers(s.tertiaryPalette.getHct(s.sourceColorHct.getTone()), s);
final Hct proposedHct = s.tertiaryPalette.getHct(albersTone);
return DislikeAnalyzer.fixIfDisliked(proposedHct).getTone();
},
MaterialDynamicColors::highestSurface);
}
public static DynamicColor onTertiaryContainer() {
return DynamicColor.fromPalette(
(s) -> s.tertiaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 0.0 : 100.0;
}
if (!isFidelity(s)) {
return s.isDark ? 90.0 : 10.0;
}
return DynamicColor.contrastingTone(tertiaryContainer().tone.apply(s), 4.5);
},
(s) -> tertiaryContainer());
}
public static DynamicColor tertiary() {
return DynamicColor.fromPalette(
(s) -> s.tertiaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 90.0 : 25.0;
}
return s.isDark ? 80.0 : 40.0;
},
MaterialDynamicColors::highestSurface,
(s) ->
new ToneDeltaConstraint(
CONTAINER_ACCENT_TONE_DELTA,
tertiaryContainer(),
s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
}
public static DynamicColor onTertiary() {
return DynamicColor.fromPalette(
(s) -> s.tertiaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 10.0 : 90.0;
}
return s.isDark ? 20.0 : 100.0;
},
(s) -> tertiary());
}
public static DynamicColor errorContainer() {
return DynamicColor.fromPalette(
(s) -> s.errorPalette, (s) -> s.isDark ? 30.0 : 90.0,
MaterialDynamicColors::highestSurface);
}
public static DynamicColor onErrorContainer() {
return DynamicColor.fromPalette(
(s) -> s.errorPalette, (s) -> s.isDark ? 90.0 : 10.0, (s) -> errorContainer());
}
public static DynamicColor error() {
return DynamicColor.fromPalette(
(s) -> s.errorPalette,
(s) -> s.isDark ? 80.0 : 40.0,
MaterialDynamicColors::highestSurface,
(s) ->
new ToneDeltaConstraint(
CONTAINER_ACCENT_TONE_DELTA,
errorContainer(),
s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
}
public static DynamicColor onError() {
return DynamicColor.fromPalette(
(s) -> s.errorPalette, (s) -> s.isDark ? 20.0 : 100.0, (s) -> error());
}
public static DynamicColor primaryFixed() {
return DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 100.0 : 10.0;
}
return 90.0;
},
MaterialDynamicColors::highestSurface);
}
public static DynamicColor primaryFixedDim() {
return DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 90.0 : 20.0;
}
return 80.0;
},
MaterialDynamicColors::highestSurface);
}
public static DynamicColor onPrimaryFixed() {
return DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 10.0 : 90.0;
}
return 10.0;
},
(s) -> primaryFixedDim());
}
public static DynamicColor onPrimaryFixedVariant() {
return DynamicColor.fromPalette(
(s) -> s.primaryPalette,
(s) -> {
if (isMonochrome(s)) {
return s.isDark ? 30.0 : 70.0;
}
return 30.0;
},
(s) -> primaryFixedDim());
}
public static DynamicColor secondaryFixed() {
return DynamicColor.fromPalette(
(s) -> s.secondaryPalette, (s) -> isMonochrome(s) ? 80.0 : 90.0,
MaterialDynamicColors::highestSurface);
}
public static DynamicColor secondaryFixedDim() {
return DynamicColor.fromPalette(
(s) -> s.secondaryPalette, (s) -> isMonochrome(s) ? 70.0 : 80.0,
MaterialDynamicColors::highestSurface);
}
public static DynamicColor onSecondaryFixed() {
return DynamicColor.fromPalette(
(s) -> s.secondaryPalette, (s) -> 10.0, (s) -> secondaryFixedDim());
}
public static DynamicColor onSecondaryFixedVariant() {
return DynamicColor.fromPalette(
(s) -> s.secondaryPalette,
(s) -> isMonochrome(s) ? 25.0 : 30.0,
(s) -> secondaryFixedDim());
}
public static DynamicColor tertiaryFixed() {
return DynamicColor.fromPalette(
(s) -> s.tertiaryPalette, (s) -> isMonochrome(s) ? 40.0 : 90.0,
MaterialDynamicColors::highestSurface);
}
public static DynamicColor tertiaryFixedDim() {
return DynamicColor.fromPalette(
(s) -> s.tertiaryPalette, (s) -> isMonochrome(s) ? 30.0 : 80.0,
MaterialDynamicColors::highestSurface);
}
public static DynamicColor onTertiaryFixed() {
return DynamicColor.fromPalette(
(s) -> s.tertiaryPalette, (s) -> isMonochrome(s) ? 90.0 : 10.0,
(s) -> tertiaryFixedDim());
}
public static DynamicColor onTertiaryFixedVariant() {
return DynamicColor.fromPalette(
(s) -> s.tertiaryPalette, (s) -> isMonochrome(s) ? 70.0 : 30.0,
(s) -> tertiaryFixedDim());
}
// colorControlNormal documented as textColorSecondary in M3 & GM3.
// In Material, textColorSecondary points to onSurfaceVariant in the non-disabled state,
// which is Neutral Variant T30/80 in light/dark.
public static DynamicColor controlNormal() {
return DynamicColor.fromPalette((s) -> s.neutralVariantPalette,
(s) -> s.isDark ? 80.0 : 30.0);
}
// colorControlHighlight documented, in both M3 & GM3:
// Light mode: #1f000000 dark mode: #33ffffff.
// These are black and white with some alpha.
// 1F hex = 31 decimal; 31 / 255 = 12% alpha.
// 33 hex = 51 decimal; 51 / 255 = 20% alpha.
// DynamicColors do not support alpha currently, and _may_ not need it for this use case,
// depending on how MDC resolved alpha for the other cases.
// Returning black in dark mode, white in light mode.
public static DynamicColor controlHighlight() {
return new DynamicColor(
s -> 0.0,
s -> 0.0,
s -> s.isDark ? 100.0 : 0.0,
s -> s.isDark ? 0.20 : 0.12,
null,
scheme ->
DynamicColor.toneMinContrastDefault((s) -> s.isDark ? 100.0 : 0.0, null,
scheme, null),
scheme ->
DynamicColor.toneMaxContrastDefault((s) -> s.isDark ? 100.0 : 0.0, null,
scheme, null),
null);
}
// textColorPrimaryInverse documented, in both M3 & GM3, documented as N10/N90.
public static DynamicColor textPrimaryInverse() {
return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
}
// textColorSecondaryInverse and textColorTertiaryInverse both documented, in both M3 & GM3, as
// NV30/NV80
public static DynamicColor textSecondaryAndTertiaryInverse() {
return DynamicColor.fromPalette((s) -> s.neutralVariantPalette,
(s) -> s.isDark ? 30.0 : 80.0);
}
// textColorPrimaryInverseDisableOnly documented, in both M3 & GM3, as N10/N90
public static DynamicColor textPrimaryInverseDisableOnly() {
return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
}
// textColorSecondaryInverse and textColorTertiaryInverse in disabled state both documented,
// in both M3 & GM3, as N10/N90
public static DynamicColor textSecondaryAndTertiaryInverseDisabled() {
return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
}
// textColorHintInverse documented, in both M3 & GM3, as N10/N90
public static DynamicColor textHintInverse() {
return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
}
} }

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.android.systemui.theme package com.android.systemui.theme
import android.util.Pair import android.util.Pair
@@ -24,68 +25,73 @@ class DynamicColors {
@JvmField @JvmField
val ALL_DYNAMIC_COLORS_MAPPED: List<Pair<String, DynamicColor>> = val ALL_DYNAMIC_COLORS_MAPPED: List<Pair<String, DynamicColor>> =
arrayListOf( arrayListOf(
Pair.create("primary_container", MDC.primaryContainer), Pair.create("primary_container", MDC.primaryContainer()),
Pair.create("on_primary_container", MDC.onPrimaryContainer), Pair.create("on_primary_container", MDC.onPrimaryContainer()),
Pair.create("primary", MDC.primary), Pair.create("primary", MDC.primary()),
Pair.create("on_primary", MDC.onPrimary), Pair.create("on_primary", MDC.onPrimary()),
Pair.create("secondary_container", MDC.secondaryContainer), Pair.create("secondary_container", MDC.secondaryContainer()),
Pair.create("on_secondary_container", MDC.onSecondaryContainer), Pair.create("on_secondary_container", MDC.onSecondaryContainer()),
Pair.create("secondary", MDC.secondary), Pair.create("secondary", MDC.secondary()),
Pair.create("on_secondary", MDC.onSecondary), Pair.create("on_secondary", MDC.onSecondary()),
Pair.create("tertiary_container", MDC.tertiaryContainer), Pair.create("tertiary_container", MDC.tertiaryContainer()),
Pair.create("on_tertiary_container", MDC.onTertiaryContainer), Pair.create("on_tertiary_container", MDC.onTertiaryContainer()),
Pair.create("tertiary", MDC.tertiary), Pair.create("tertiary", MDC.tertiary()),
Pair.create("on_tertiary", MDC.onTertiary), Pair.create("on_tertiary", MDC.onTertiary()),
Pair.create("background", MDC.background), Pair.create("background", MDC.background()),
Pair.create("on_background", MDC.onBackground), Pair.create("on_background", MDC.onBackground()),
Pair.create("surface", MDC.surface), Pair.create("surface", MDC.surface()),
Pair.create("on_surface", MDC.onSurface), Pair.create("on_surface", MDC.onSurface()),
Pair.create("surface_container_low", MDC.surfaceContainerLow), Pair.create("surface_container_low", MDC.surfaceContainerLow()),
Pair.create("surface_container_lowest", MDC.surfaceContainerLowest), Pair.create("surface_container_lowest", MDC.surfaceContainerLowest()),
Pair.create("surface_container", MDC.surfaceContainer), Pair.create("surface_container", MDC.surfaceContainer()),
Pair.create("surface_container_high", MDC.surfaceContainerHigh), Pair.create("surface_container_high", MDC.surfaceContainerHigh()),
Pair.create("surface_container_highest", MDC.surfaceContainerHighest), Pair.create("surface_container_highest", MDC.surfaceContainerHighest()),
Pair.create("surface_bright", MDC.surfaceBright), Pair.create("surface_bright", MDC.surfaceBright()),
Pair.create("surface_dim", MDC.surfaceDim), Pair.create("surface_dim", MDC.surfaceDim()),
Pair.create("surface_variant", MDC.surfaceVariant), Pair.create("surface_variant", MDC.surfaceVariant()),
Pair.create("on_surface_variant", MDC.onSurfaceVariant), Pair.create("on_surface_variant", MDC.onSurfaceVariant()),
Pair.create("outline", MDC.outline), Pair.create("outline", MDC.outline()),
Pair.create("outline_variant", MDC.outlineVariant), Pair.create("error", MDC.error()),
Pair.create("error", MDC.error), Pair.create("on_error", MDC.onError()),
Pair.create("on_error", MDC.onError), Pair.create("error_container", MDC.errorContainer()),
Pair.create("error_container", MDC.errorContainer), Pair.create("on_error_container", MDC.onErrorContainer()),
Pair.create("on_error_container", MDC.onErrorContainer), Pair.create("primary_fixed", MDC.primaryFixed()),
Pair.create("primary_fixed", MDC.primaryFixed), Pair.create("primary_fixed_dim", MDC.primaryFixedDim()),
Pair.create("primary_fixed_dim", MDC.primaryFixedDim), Pair.create("on_primary_fixed", MDC.onPrimaryFixed()),
Pair.create("on_primary_fixed", MDC.onPrimaryFixed), Pair.create("on_primary_fixed_variant", MDC.onPrimaryFixedVariant()),
Pair.create("on_primary_fixed_variant", MDC.onPrimaryFixedVariant), Pair.create("secondary_fixed", MDC.secondaryFixed()),
Pair.create("secondary_fixed", MDC.secondaryFixed), Pair.create("secondary_fixed_dim", MDC.secondaryFixedDim()),
Pair.create("secondary_fixed_dim", MDC.secondaryFixedDim), Pair.create("on_secondary_fixed", MDC.onSecondaryFixed()),
Pair.create("on_secondary_fixed", MDC.onSecondaryFixed), Pair.create("on_secondary_fixed_variant", MDC.onSecondaryFixedVariant()),
Pair.create("on_secondary_fixed_variant", MDC.onSecondaryFixedVariant), Pair.create("tertiary_fixed", MDC.tertiaryFixed()),
Pair.create("tertiary_fixed", MDC.tertiaryFixed), Pair.create("tertiary_fixed_dim", MDC.tertiaryFixedDim()),
Pair.create("tertiary_fixed_dim", MDC.tertiaryFixedDim), Pair.create("on_tertiary_fixed", MDC.onTertiaryFixed()),
Pair.create("on_tertiary_fixed", MDC.onTertiaryFixed), Pair.create("on_tertiary_fixed_variant", MDC.onTertiaryFixedVariant()),
Pair.create("on_tertiary_fixed_variant", MDC.onTertiaryFixedVariant), Pair.create("control_activated", MDC.controlActivated()),
Pair.create("control_activated", MDC.controlActivated), Pair.create("control_normal", MDC.controlNormal()),
Pair.create("control_normal", MDC.controlNormal), Pair.create("control_highlight", MDC.controlHighlight()),
Pair.create("control_highlight", MDC.controlHighlight), Pair.create("text_primary_inverse", MDC.textPrimaryInverse()),
Pair.create("text_primary_inverse", MDC.textPrimaryInverse),
Pair.create( Pair.create(
"text_secondary_and_tertiary_inverse", "text_secondary_and_tertiary_inverse",
MDC.textSecondaryAndTertiaryInverse MDC.textSecondaryAndTertiaryInverse()
),
Pair.create(
"text_primary_inverse_disable_only",
MDC.textPrimaryInverseDisableOnly()
), ),
Pair.create("text_primary_inverse_disable_only", MDC.textPrimaryInverseDisableOnly),
Pair.create( Pair.create(
"text_secondary_and_tertiary_inverse_disabled", "text_secondary_and_tertiary_inverse_disabled",
MDC.textSecondaryAndTertiaryInverseDisabled MDC.textSecondaryAndTertiaryInverseDisabled()
), ),
Pair.create("text_hint_inverse", MDC.textHintInverse), Pair.create("text_hint_inverse", MDC.textHintInverse()),
Pair.create("palette_key_color_primary", MDC.primaryPaletteKeyColor), Pair.create("palette_key_color_primary", MDC.primaryPaletteKeyColor()),
Pair.create("palette_key_color_secondary", MDC.secondaryPaletteKeyColor), Pair.create("palette_key_color_secondary", MDC.secondaryPaletteKeyColor()),
Pair.create("palette_key_color_tertiary", MDC.tertiaryPaletteKeyColor), Pair.create("palette_key_color_tertiary", MDC.tertiaryPaletteKeyColor()),
Pair.create("palette_key_color_neutral", MDC.neutralPaletteKeyColor), Pair.create("palette_key_color_neutral", MDC.neutralPaletteKeyColor()),
Pair.create("palette_key_color_neutral_variant", MDC.neutralVariantPaletteKeyColor) Pair.create(
"palette_key_color_neutral_variant",
MDC.neutralVariantPaletteKeyColor()
)
) )
} }
} }

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.android.systemui.theme; package com.android.systemui.theme;
import static android.util.TypedValue.TYPE_INT_COLOR_ARGB8; import static android.util.TypedValue.TYPE_INT_COLOR_ARGB8;
@@ -659,9 +660,9 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
&& res.getColor(android.R.color.system_neutral2_500, theme) && res.getColor(android.R.color.system_neutral2_500, theme)
== mColorScheme.getNeutral2().getS500() == mColorScheme.getNeutral2().getS500()
&& res.getColor(android.R.color.system_primary_container_dark, theme) && res.getColor(android.R.color.system_primary_container_dark, theme)
== MaterialDynamicColors.primaryContainer.getArgb(mDynamicSchemeDark) == MaterialDynamicColors.primaryContainer().getArgb(mDynamicSchemeDark)
&& res.getColor(android.R.color.system_primary_container_light, theme) && res.getColor(android.R.color.system_primary_container_light, theme)
== MaterialDynamicColors.primaryContainer.getArgb(mDynamicSchemeLight))) { == MaterialDynamicColors.primaryContainer().getArgb(mDynamicSchemeLight))) {
return false; return false;
} }
} }

View File

@@ -17,18 +17,16 @@
package com.android.systemui.monet; package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat; import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.contrast.Contrast; import com.android.systemui.monet.contrast.Contrast;
import com.android.systemui.monet.dynamiccolor.DynamicColor; import com.android.systemui.monet.dynamiccolor.DynamicColor;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors; import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.dynamiccolor.ToneDeltaConstraint; import com.android.systemui.monet.dynamiccolor.ToneDeltaConstraint;
import com.android.systemui.monet.dynamiccolor.TonePolarity; import com.android.systemui.monet.dynamiccolor.TonePolarity;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.hct.Hct; import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.DynamicScheme; import com.android.systemui.monet.scheme.DynamicScheme;
import com.android.systemui.monet.scheme.SchemeContent; import com.android.systemui.monet.scheme.SchemeContent;
@@ -36,21 +34,24 @@ import com.android.systemui.monet.scheme.SchemeFidelity;
import com.android.systemui.monet.scheme.SchemeMonochrome; import com.android.systemui.monet.scheme.SchemeMonochrome;
import com.android.systemui.monet.scheme.SchemeTonalSpot; import com.android.systemui.monet.scheme.SchemeTonalSpot;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest @SmallTest
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class DynamicColorTest extends SysuiTestCase { public final class DynamicColorTest extends SysuiTestCase{
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test @Test
public void fromArgbNoBackground_doesntChangeForContrast() { public void fromArgbNoBackground_doesntChangeForContrast() {
final int blueArgb = 0xff0000ff; final int blueArgb = 0xff0000ff;
final DynamicColor dynamicColor = DynamicColor.fromArgb(blueArgb); final DynamicColor dynamicColor = DynamicColor.fromArgb(blueArgb);
final SchemeTonalSpot standardContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, final SchemeTonalSpot standardContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 0.0);
0.0);
assertThat(dynamicColor.getArgb(standardContrast)).isSameColorAs(blueArgb); assertThat(dynamicColor.getArgb(standardContrast)).isSameColorAs(blueArgb);
final SchemeTonalSpot minContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, -1.0); final SchemeTonalSpot minContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, -1.0);
@@ -70,8 +71,7 @@ public final class DynamicColorTest extends SysuiTestCase {
blueArgb, blueArgb,
(s) -> 30.0, (s) -> 30.0,
null, null,
(s) -> new ToneDeltaConstraint(30, otherDynamicColor, (s) -> new ToneDeltaConstraint(30, otherDynamicColor, TonePolarity.NO_PREFERENCE));
TonePolarity.NO_PREFERENCE));
final SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 0.0); final SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 0.0);
assertThat(dynamicColor.getArgb(scheme)).isSameColorAs(0xff0000ef); assertThat(dynamicColor.getArgb(scheme)).isSameColorAs(0xff0000ef);
} }
@@ -92,8 +92,7 @@ public final class DynamicColorTest extends SysuiTestCase {
DynamicColor.toneMaxContrastDefault( DynamicColor.toneMaxContrastDefault(
(s) -> s.isDark ? 100.0 : 0.0, null, scheme, null), (s) -> s.isDark ? 100.0 : 0.0, null, scheme, null),
null); null);
final SchemeTonalSpot lightScheme = new SchemeTonalSpot(Hct.fromInt(0xff4285f4), false, final SchemeTonalSpot lightScheme = new SchemeTonalSpot(Hct.fromInt(0xff4285f4), false, 0.0);
0.0);
assertThat(dynamicColor.getArgb(lightScheme)).isSameColorAs(0x1f000000); assertThat(dynamicColor.getArgb(lightScheme)).isSameColorAs(0x1f000000);
final SchemeTonalSpot darkScheme = new SchemeTonalSpot(Hct.fromInt(0xff4285f4), true, 0.0); final SchemeTonalSpot darkScheme = new SchemeTonalSpot(Hct.fromInt(0xff4285f4), true, 0.0);
@@ -103,7 +102,7 @@ public final class DynamicColorTest extends SysuiTestCase {
@Test @Test
public void respectsContrast() { public void respectsContrast() {
final Hct[] seedColors = final Hct[] seedColors =
new Hct[]{ new Hct[] {
Hct.fromInt(0xFFFF0000), Hct.fromInt(0xFFFF0000),
Hct.fromInt(0xFFFFFF00), Hct.fromInt(0xFFFFFF00),
Hct.fromInt(0xFF00FF00), Hct.fromInt(0xFF00FF00),
@@ -114,65 +113,50 @@ public final class DynamicColorTest extends SysuiTestCase {
for (Hct seedColor : seedColors) { for (Hct seedColor : seedColors) {
for (double contrastLevel : contrastLevels) { for (double contrastLevel : contrastLevels) {
for (boolean isDark : new boolean[]{false, true}) { for (boolean isDark : new boolean[] {false, true}) {
final DynamicScheme[] schemes = final DynamicScheme[] schemes =
new DynamicScheme[]{ new DynamicScheme[] {
new SchemeContent(seedColor, isDark, contrastLevel), new SchemeContent(seedColor, isDark, contrastLevel),
new SchemeMonochrome(seedColor, isDark, contrastLevel), new SchemeMonochrome(seedColor, isDark, contrastLevel),
new SchemeTonalSpot(seedColor, isDark, contrastLevel), new SchemeTonalSpot(seedColor, isDark, contrastLevel),
new SchemeFidelity(seedColor, isDark, contrastLevel) new SchemeFidelity(seedColor, isDark, contrastLevel)
}; };
for (final DynamicScheme scheme : schemes) { for (final DynamicScheme scheme : schemes) {
assertTrue(
pairSatisfiesContrast(scheme, dynamicColors.onPrimary(), dynamicColors.primary()));
assertTrue( assertTrue(
pairSatisfiesContrast( pairSatisfiesContrast(
scheme, MaterialDynamicColors.onPrimary, scheme, dynamicColors.onPrimaryContainer(), dynamicColors.primaryContainer()));
MaterialDynamicColors.primary)); assertTrue(
pairSatisfiesContrast(
scheme, dynamicColors.onSecondary(), dynamicColors.secondary()));
assertTrue( assertTrue(
pairSatisfiesContrast( pairSatisfiesContrast(
scheme, scheme,
MaterialDynamicColors.onPrimaryContainer, dynamicColors.onSecondaryContainer(),
MaterialDynamicColors.primaryContainer)); dynamicColors.secondaryContainer()));
assertTrue( assertTrue(
pairSatisfiesContrast( pairSatisfiesContrast(
scheme, MaterialDynamicColors.onSecondary, scheme, dynamicColors.onTertiary(), dynamicColors.tertiary()));
MaterialDynamicColors.secondary));
assertTrue( assertTrue(
pairSatisfiesContrast( pairSatisfiesContrast(
scheme, scheme,
MaterialDynamicColors.onSecondaryContainer, dynamicColors.onTertiaryContainer(),
MaterialDynamicColors.secondaryContainer)); dynamicColors.tertiaryContainer()));
assertTrue(
pairSatisfiesContrast(scheme, dynamicColors.onError(), dynamicColors.error()));
assertTrue( assertTrue(
pairSatisfiesContrast( pairSatisfiesContrast(
scheme, MaterialDynamicColors.onTertiary, scheme, dynamicColors.onErrorContainer(), dynamicColors.errorContainer()));
MaterialDynamicColors.tertiary));
assertTrue( assertTrue(
pairSatisfiesContrast( pairSatisfiesContrast(
scheme, scheme, dynamicColors.onBackground(), dynamicColors.background()));
MaterialDynamicColors.onTertiaryContainer,
MaterialDynamicColors.tertiaryContainer));
assertTrue( assertTrue(
pairSatisfiesContrast( pairSatisfiesContrast(
scheme, MaterialDynamicColors.onError, scheme, dynamicColors.onSurfaceVariant(), dynamicColors.surfaceVariant()));
MaterialDynamicColors.error));
assertTrue( assertTrue(
pairSatisfiesContrast( pairSatisfiesContrast(
scheme, scheme, dynamicColors.inverseOnSurface(), dynamicColors.inverseSurface()));
MaterialDynamicColors.onErrorContainer,
MaterialDynamicColors.errorContainer));
assertTrue(
pairSatisfiesContrast(
scheme, MaterialDynamicColors.onBackground,
MaterialDynamicColors.background));
assertTrue(
pairSatisfiesContrast(
scheme,
MaterialDynamicColors.onSurfaceVariant,
MaterialDynamicColors.surfaceVariant));
assertTrue(
pairSatisfiesContrast(
scheme,
MaterialDynamicColors.onSurfaceInverse,
MaterialDynamicColors.surfaceInverse));
} }
} }
} }
@@ -183,28 +167,34 @@ public final class DynamicColorTest extends SysuiTestCase {
public void valuesAreCorrect() { public void valuesAreCorrect() {
// Checks that the values of certain dynamic colors match Dart results. // Checks that the values of certain dynamic colors match Dart results.
assertThat( assertThat(
MaterialDynamicColors.onPrimaryContainer.getArgb( dynamicColors
new SchemeFidelity(Hct.fromInt(0xFFFF0000), false, 0.5))) .onPrimaryContainer()
.getArgb(new SchemeFidelity(Hct.fromInt(0xFFFF0000), false, 0.5)))
.isSameColorAs(0xFFFFE5E1); .isSameColorAs(0xFFFFE5E1);
assertThat( assertThat(
MaterialDynamicColors.onSecondaryContainer.getArgb( dynamicColors
new SchemeContent(Hct.fromInt(0xFF0000FF), false, 0.5))) .onSecondaryContainer()
.getArgb(new SchemeContent(Hct.fromInt(0xFF0000FF), false, 0.5)))
.isSameColorAs(0xFFFFFCFF); .isSameColorAs(0xFFFFFCFF);
assertThat( assertThat(
MaterialDynamicColors.onTertiaryContainer.getArgb( dynamicColors
new SchemeContent(Hct.fromInt(0xFFFFFF00), true, -0.5))) .onTertiaryContainer()
.getArgb(new SchemeContent(Hct.fromInt(0xFFFFFF00), true, -0.5)))
.isSameColorAs(0xFF616600); .isSameColorAs(0xFF616600);
assertThat( assertThat(
MaterialDynamicColors.surfaceInverse.getArgb( dynamicColors
new SchemeContent(Hct.fromInt(0xFF0000FF), false, 0.0))) .inverseSurface()
.isSameColorAs(0xFF464652); .getArgb(new SchemeContent(Hct.fromInt(0xFF0000FF), false, 0.0)))
.isSameColorAs(0xFF2F2F3B);
assertThat( assertThat(
MaterialDynamicColors.primaryInverse.getArgb( dynamicColors
new SchemeContent(Hct.fromInt(0xFFFF0000), false, -0.5))) .inversePrimary()
.isSameColorAs(0xFFFF8C7A); .getArgb(new SchemeContent(Hct.fromInt(0xFFFF0000), false, -0.5)))
.isSameColorAs(0xFFFF907F);
assertThat( assertThat(
MaterialDynamicColors.outlineVariant.getArgb( dynamicColors
new SchemeContent(Hct.fromInt(0xFFFFFF00), true, 0.0))) .outlineVariant()
.getArgb(new SchemeContent(Hct.fromInt(0xFFFFFF00), true, 0.0)))
.isSameColorAs(0xFF484831); .isSameColorAs(0xFF484831);
} }

View File

@@ -25,246 +25,229 @@ import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct; import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeContent; import com.android.systemui.monet.scheme.SchemeContent;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest @SmallTest
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class SchemeContentTest extends SysuiTestCase { public final class SchemeContentTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test @Test
public void testKeyColors() { public void testKeyColors() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xff0000ff), false, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff080CFF); .isSameColorAs(0xff080CFF);
assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff656DD3); .isSameColorAs(0xff656DD3);
assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff81009F); .isSameColorAs(0xff81009F);
assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767684); .isSameColorAs(0xff767684);
assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff757589); .isSameColorAs(0xff757589);
} }
@Test @Test
public void lightTheme_minContrast_primary() { public void lightTheme_minContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFF1218FF); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF1218FF);
} }
@Test @Test
public void lightTheme_standardContrast_primary() { public void lightTheme_standardContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFF0001C3); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF0001C3);
} }
@Test @Test
public void lightTheme_maxContrast_primary() { public void lightTheme_maxContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFF000181); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF000181);
} }
@Test @Test
public void lightTheme_minContrast_primaryContainer() { public void lightTheme_minContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF5660FF);
0xFF5660FF);
} }
@Test @Test
public void lightTheme_standardContrast_primaryContainer() { public void lightTheme_standardContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF2D36FF);
0xFF2D36FF);
} }
@Test @Test
public void lightTheme_maxContrast_primaryContainer() { public void lightTheme_maxContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF0000E3);
0xFF0000E3);
} }
@Test @Test
public void lightTheme_minContrast_tertiaryContainer() { public void lightTheme_minContrast_tertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFB042CC);
0xFFB042CC);
} }
@Test @Test
public void lightTheme_standardContrast_tertiaryContainer() { public void lightTheme_standardContrast_tertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF9221AF);
0xFF9221AF);
} }
@Test @Test
public void lightTheme_maxContrast_tertiaryContainer() { public void lightTheme_maxContrast_tertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF73008E);
0xFF73008E);
} }
@Test @Test
public void lightTheme_minContrast_objectionableTertiaryContainerLightens() { public void lightTheme_minContrast_objectionableTertiaryContainerLightens() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, -1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, -1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFD03A71);
0xFFD03A71);
} }
@Test @Test
public void lightTheme_standardContrast_objectionableTertiaryContainerLightens() { public void lightTheme_standardContrast_objectionableTertiaryContainerLightens() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, 0.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFAC1B57);
0xFFAC1B57);
} }
@Test @Test
public void lightTheme_maxContrast_objectionableTertiaryContainerDarkens() { public void lightTheme_maxContrast_objectionableTertiaryContainerDarkens() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, 1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF870040);
0xFF870040);
} }
@Test @Test
public void lightTheme_minContrast_onPrimaryContainer() { public void lightTheme_minContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFCBCDFF);
0xFFCBCDFF);
} }
@Test @Test
public void lightTheme_standardContrast_onPrimaryContainer() { public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFCECFFF);
0xFFCECFFF);
} }
@Test @Test
public void lightTheme_maxContrast_onPrimaryContainer() { public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFD6D6FF);
0xFFD6D6FF);
} }
@Test @Test
public void lightTheme_minContrast_surface() { public void lightTheme_minContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFFFBF8FF); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
} }
@Test @Test
public void lightTheme_standardContrast_surface() { public void lightTheme_standardContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFFFBF8FF); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
} }
@Test @Test
public void lightTheme_maxContrast_surface() { public void lightTheme_maxContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFFFBF8FF); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
} }
@Test @Test
public void darkTheme_minContrast_primary() { public void darkTheme_minContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFF5660FF); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF5660FF);
} }
@Test @Test
public void darkTheme_standardContrast_primary() { public void darkTheme_standardContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFFBEC2FF); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFFBEC2FF);
} }
@Test @Test
public void darkTheme_maxContrast_primary() { public void darkTheme_maxContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFFF6F4FF); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFFF6F4FF);
} }
@Test @Test
public void darkTheme_minContrast_primaryContainer() { public void darkTheme_minContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF0000E6);
0xFF0000E6);
} }
@Test @Test
public void darkTheme_standardContrast_primaryContainer() { public void darkTheme_standardContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF0000E6);
0xFF0000E6);
} }
@Test @Test
public void darkTheme_maxContrast_primaryContainer() { public void darkTheme_maxContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFFC4C6FF);
0xFFC4C6FF);
} }
@Test @Test
public void darkTheme_minContrast_onPrimaryContainer() { public void darkTheme_minContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFF7A83FF);
0xFF7A83FF);
} }
@Test @Test
public void darkTheme_standardContrast_onPrimaryContainer() { public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFA4AAFF);
0xFFA4AAFF);
} }
@Test @Test
public void darkTheme_maxContrast_onPrimaryContainer() { public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFF0001C6);
0xFF0001C6);
} }
@Test @Test
public void darkTheme_minContrast_onTertiaryContainer() { public void darkTheme_minContrast_onTertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFCF60EA);
0xFFCF60EA);
} }
@Test @Test
public void darkTheme_standardContrast_onTertiaryContainer() { public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFEB8CFF);
0xFFEB8CFF);
} }
@Test @Test
public void darkTheme_maxContrast_onTertiaryContainer() { public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF63007B);
0xFF63007B);
} }
@Test @Test
public void darkTheme_minContrast_surface() { public void darkTheme_minContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFF12121D); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFF12121D);
} }
@Test @Test
public void darkTheme_standardContrast_surface() { public void darkTheme_standardContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFF12121D); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFF12121D);
} }
@Test @Test
public void darkTheme_maxContrast_surface() { public void darkTheme_maxContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0); SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFF12121D); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFF12121D);
} }
} }

View File

@@ -25,183 +25,175 @@ import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct; import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeExpressive; import com.android.systemui.monet.scheme.SchemeExpressive;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest @SmallTest
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class SchemeExpressiveTest extends SysuiTestCase { public final class SchemeExpressiveTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test @Test
public void testKeyColors() { public void testKeyColors() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff35855F); .isSameColorAs(0xff35855F);
assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff8C6D8C); .isSameColorAs(0xff8C6D8C);
assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff806EA1); .isSameColorAs(0xff806EA1);
assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff79757F); .isSameColorAs(0xff79757F);
assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff7A7585); .isSameColorAs(0xff7A7585);
} }
@Test @Test
public void lightTheme_minContrast_primary() { public void lightTheme_minContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff32835D); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffad603c);
} }
@Test @Test
public void lightTheme_standardContrast_primary() { public void lightTheme_standardContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff146C48); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff924b28);
} }
@Test @Test
public void lightTheme_maxContrast_primary() { public void lightTheme_maxContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff002818); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff401400);
} }
@Test @Test
public void lightTheme_minContrast_primaryContainer() { public void lightTheme_minContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffffdbcc);
0xffA2F4C6);
} }
@Test @Test
public void lightTheme_standardContrast_primaryContainer() { public void lightTheme_standardContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffffdbcc);
0xffA2F4C6);
} }
@Test @Test
public void lightTheme_maxContrast_primaryContainer() { public void lightTheme_maxContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff6f3010);
0xff004D31);
} }
@Test @Test
public void lightTheme_minContrast_onPrimaryContainer() { public void lightTheme_minContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff99512e);
0xff1e724e);
} }
@Test @Test
public void lightTheme_standardContrast_onPrimaryContainer() { public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff351000);
0xff002112);
} }
@Test @Test
public void lightTheme_maxContrast_onPrimaryContainer() { public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffffd0bc);
0xff9aebbe);
} }
@Test @Test
public void lightTheme_minContrast_surface() { public void lightTheme_minContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffdf7ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_standardContrast_surface() { public void lightTheme_standardContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffdf7ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_maxContrast_surface() { public void lightTheme_maxContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffdf7ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void darkTheme_minContrast_primary() { public void darkTheme_minContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff32835d); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffad603c);
} }
@Test @Test
public void darkTheme_standardContrast_primary() { public void darkTheme_standardContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff87d7ab); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffffb595);
} }
@Test @Test
public void darkTheme_maxContrast_primary() { public void darkTheme_maxContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffd5ffe4); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfffff3ee);
} }
@Test @Test
public void darkTheme_minContrast_primaryContainer() { public void darkTheme_minContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff743413);
0xff005234);
} }
@Test @Test
public void darkTheme_standardContrast_primaryContainer() { public void darkTheme_standardContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff743413);
0xff005234);
} }
@Test @Test
public void darkTheme_maxContrast_primaryContainer() { public void darkTheme_maxContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffffbb9e);
0xff8bdbaf);
} }
@Test @Test
public void darkTheme_minContrast_onPrimaryContainer() { public void darkTheme_minContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xfff99f75);
0xff76c59b);
} }
@Test @Test
public void darkTheme_standardContrast_onPrimaryContainer() { public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffffdbcc);
0xffa2f4c6);
} }
@Test @Test
public void darkTheme_maxContrast_onPrimaryContainer() { public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff622706);
0xff004229);
} }
@Test @Test
public void darkTheme_minContrast_surface() { public void darkTheme_minContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff14121a); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
} }
@Test @Test
public void darkTheme_standardContrast_surface() { public void darkTheme_standardContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff14121a); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
} }
@Test @Test
public void darkTheme_maxContrast_surface() { public void darkTheme_maxContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0); SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff14121a); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
} }
} }

View File

@@ -25,245 +25,230 @@ import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct; import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeFidelity; import com.android.systemui.monet.scheme.SchemeFidelity;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest @SmallTest
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class SchemeFidelityTest extends SysuiTestCase { public final class SchemeFidelityTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test @Test
public void testKeyColors() { public void testKeyColors() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff080CFF); .isSameColorAs(0xff080CFF);
assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff656DD3); .isSameColorAs(0xff656DD3);
assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff9D0002); .isSameColorAs(0xff9D0002);
assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767684); .isSameColorAs(0xff767684);
assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff757589); .isSameColorAs(0xff757589);
} }
@Test @Test
public void lightTheme_minContrast_primary() { public void lightTheme_minContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff1218ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff1218ff);
} }
@Test @Test
public void lightTheme_standardContrast_primary() { public void lightTheme_standardContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff0001c3); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff0001c3);
} }
@Test @Test
public void lightTheme_maxContrast_primary() { public void lightTheme_maxContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff000181); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000181);
} }
@Test @Test
public void lightTheme_minContrast_primaryContainer() { public void lightTheme_minContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff5660ff);
0xff5660ff);
} }
@Test @Test
public void lightTheme_standardContrast_primaryContainer() { public void lightTheme_standardContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff2d36ff);
0xff2d36ff);
} }
@Test @Test
public void lightTheme_maxContrast_primaryContainer() { public void lightTheme_maxContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e3);
0xff0000e3);
} }
@Test @Test
public void lightTheme_minContrast_tertiaryContainer() { public void lightTheme_minContrast_tertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffd93628);
0xffd93628);
} }
@Test @Test
public void lightTheme_standardContrast_tertiaryContainer() { public void lightTheme_standardContrast_tertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffb31910);
0xffb31910);
} }
@Test @Test
public void lightTheme_maxContrast_tertiaryContainer() { public void lightTheme_maxContrast_tertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xff8c0002);
0xff8c0002);
} }
@Test @Test
public void lightTheme_minContrast_objectionableTertiaryContainerLightens() { public void lightTheme_minContrast_objectionableTertiaryContainerLightens() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, -1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffbcac5a);
0xffbcac5a);
} }
@Test @Test
public void lightTheme_standardContrast_objectionableTertiaryContainerLightens() { public void lightTheme_standardContrast_objectionableTertiaryContainerLightens() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, 0.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffbcac5a);
0xffbcac5a);
} }
@Test @Test
public void lightTheme_maxContrast_objectionableTertiaryContainerDarkens() { public void lightTheme_maxContrast_objectionableTertiaryContainerDarkens() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, 1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xff4d4300);
0xff4d4300);
} }
@Test @Test
public void lightTheme_minContrast_onPrimaryContainer() { public void lightTheme_minContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffcbcdff);
0xffcbcdff);
} }
@Test @Test
public void lightTheme_standardContrast_onPrimaryContainer() { public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffcecfff);
0xffcecfff);
} }
@Test @Test
public void lightTheme_maxContrast_onPrimaryContainer() { public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd6d6ff);
0xffd6d6ff);
} }
@Test @Test
public void lightTheme_minContrast_surface() { public void lightTheme_minContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_standardContrast_surface() { public void lightTheme_standardContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_maxContrast_surface() { public void lightTheme_maxContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void darkTheme_minContrast_primary() { public void darkTheme_minContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5660ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5660ff);
} }
@Test @Test
public void darkTheme_standardContrast_primary() { public void darkTheme_standardContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffbec2ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
} }
@Test @Test
public void darkTheme_maxContrast_primary() { public void darkTheme_maxContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff6f4ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
} }
@Test @Test
public void darkTheme_minContrast_primaryContainer() { public void darkTheme_minContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e6);
0xff0000e6);
} }
@Test @Test
public void darkTheme_standardContrast_primaryContainer() { public void darkTheme_standardContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e6);
0xff0000e6);
} }
@Test @Test
public void darkTheme_maxContrast_primaryContainer() { public void darkTheme_maxContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffc4c6ff);
0xffc4c6ff);
} }
@Test @Test
public void darkTheme_minContrast_onPrimaryContainer() { public void darkTheme_minContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff7a83ff);
0xff7a83ff);
} }
@Test @Test
public void darkTheme_standardContrast_onPrimaryContainer() { public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffa4aaff);
0xffa4aaff);
} }
@Test @Test
public void darkTheme_maxContrast_onPrimaryContainer() { public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff0001c6);
0xff0001c6);
} }
@Test @Test
public void darkTheme_minContrast_onTertiaryContainer() { public void darkTheme_minContrast_onTertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xfffe513e);
0xfffe513e);
} }
@Test @Test
public void darkTheme_standardContrast_onTertiaryContainer() { public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffFF9181);
0xffFF9181);
} }
@Test @Test
public void darkTheme_maxContrast_onTertiaryContainer() { public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff790001);
0xff790001);
} }
@Test @Test
public void darkTheme_minContrast_surface() { public void darkTheme_minContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12121d); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12121d);
} }
@Test @Test
public void darkTheme_standardContrast_surface() { public void darkTheme_standardContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12121d); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12121d);
} }
@Test @Test
public void darkTheme_maxContrast_surface() { public void darkTheme_maxContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0); SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12121d); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12121d);
} }
} }

View File

@@ -25,226 +25,230 @@ import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct; import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeFruitSalad; import com.android.systemui.monet.scheme.SchemeFruitSalad;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest @SmallTest
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class SchemeFruitSaladTest extends SysuiTestCase { public final class SchemeFruitSaladTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test @Test
public void testKeyColors() { public void testKeyColors() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff0091C0); .isSameColorAs(0xff0091C0);
assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff3A7E9E); .isSameColorAs(0xff3A7E9E);
assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff6E72AC); .isSameColorAs(0xff6E72AC);
assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777682); .isSameColorAs(0xff777682);
assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B); .isSameColorAs(0xff75758B);
} }
@Test @Test
public void lightTheme_minContrast_primary() { public void lightTheme_minContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff007ea7); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff007ea7);
} }
@Test @Test
public void lightTheme_standardContrast_primary() { public void lightTheme_standardContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff006688); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff006688);
} }
@Test @Test
public void lightTheme_maxContrast_primary() { public void lightTheme_maxContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff002635); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff002635);
} }
@Test @Test
public void lightTheme_minContrast_primaryContainer() { public void lightTheme_minContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffC2E8FF); 0xffC2E8FF);
} }
@Test @Test
public void lightTheme_standardContrast_primaryContainer() { public void lightTheme_standardContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffC2E8FF); 0xffC2E8FF);
} }
@Test @Test
public void lightTheme_maxContrast_primaryContainer() { public void lightTheme_maxContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff004862); 0xff004862);
} }
@Test @Test
public void lightTheme_minContrast_tertiaryContainer() { public void lightTheme_minContrast_tertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF); 0xffE0E0FF);
} }
@Test @Test
public void lightTheme_standardContrast_tertiaryContainer() { public void lightTheme_standardContrast_tertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF); 0xffE0E0FF);
} }
@Test @Test
public void lightTheme_maxContrast_tertiaryContainer() { public void lightTheme_maxContrast_tertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xFF3A3E74); 0xFF3A3E74);
} }
@Test @Test
public void lightTheme_minContrast_onPrimaryContainer() { public void lightTheme_minContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff006C90); 0xff006C90);
} }
@Test @Test
public void lightTheme_standardContrast_onPrimaryContainer() { public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff001E2B); 0xff001E2B);
} }
@Test @Test
public void lightTheme_maxContrast_onPrimaryContainer() { public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffACE1FF); 0xffACE1FF);
} }
@Test @Test
public void lightTheme_minContrast_surface() { public void lightTheme_minContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_standardContrast_surface() { public void lightTheme_standardContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_maxContrast_surface() { public void lightTheme_maxContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void darkTheme_minContrast_primary() { public void darkTheme_minContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff007EA7); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff007EA7);
} }
@Test @Test
public void darkTheme_standardContrast_primary() { public void darkTheme_standardContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFF76D1FF); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF76D1FF);
} }
@Test @Test
public void darkTheme_maxContrast_primary() { public void darkTheme_maxContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFFECF7FF); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFFECF7FF);
} }
@Test @Test
public void darkTheme_minContrast_primaryContainer() { public void darkTheme_minContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xFF004D67); 0xFF004D67);
} }
@Test @Test
public void darkTheme_standardContrast_primaryContainer() { public void darkTheme_standardContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xFF004D67); 0xFF004D67);
} }
@Test @Test
public void darkTheme_maxContrast_primaryContainer() { public void darkTheme_maxContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xFF83D5FF); 0xFF83D5FF);
} }
@Test @Test
public void darkTheme_minContrast_onPrimaryContainer() { public void darkTheme_minContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff55C0F2); 0xff55C0F2);
} }
@Test @Test
public void darkTheme_standardContrast_onPrimaryContainer() { public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffC2E8FF); 0xffC2E8FF);
} }
@Test @Test
public void darkTheme_maxContrast_onPrimaryContainer() { public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff003E54); 0xff003E54);
} }
@Test @Test
public void darkTheme_minContrast_onTertiaryContainer() { public void darkTheme_minContrast_onTertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffADB0EF); 0xffADB0EF);
} }
@Test @Test
public void darkTheme_standardContrast_onTertiaryContainer() { public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffe0e0ff); 0xffe0e0ff);
} }
@Test @Test
public void darkTheme_maxContrast_onTertiaryContainer() { public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xff30346A); 0xff30346A);
} }
@Test @Test
public void darkTheme_minContrast_surface() { public void darkTheme_minContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131c); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131c);
} }
@Test @Test
public void darkTheme_standardContrast_surface() { public void darkTheme_standardContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131c); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131c);
} }
@Test @Test
public void darkTheme_maxContrast_surface() { public void darkTheme_maxContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0); SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131c); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131c);
} }
} }

View File

@@ -16,6 +16,7 @@
package com.android.systemui.monet; package com.android.systemui.monet;
import static com.google.common.truth.Truth.assertThat;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat; import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
@@ -25,204 +26,227 @@ import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct; import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeMonochrome; import com.android.systemui.monet.scheme.SchemeMonochrome;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest @SmallTest
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class SchemeMonochromeTest extends SysuiTestCase { public final class SchemeMonochromeTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test @Test
public void testKeyColors() { public void testKeyColors() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707); .isSameColorAs(0xff070707);
assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707); .isSameColorAs(0xff070707);
assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707); .isSameColorAs(0xff070707);
assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707); .isSameColorAs(0xff070707);
assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707); .isSameColorAs(0xff070707);
} }
@Test @Test
public void lightTheme_minContrast_primary() { public void lightTheme_minContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff747474); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff3c3c3c);
} }
@Test @Test
public void lightTheme_standardContrast_primary() { public void lightTheme_standardContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5e5e5e); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000000);
} }
@Test @Test
public void lightTheme_maxContrast_primary() { public void lightTheme_maxContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff222222); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000000);
} }
@Test @Test
public void lightTheme_minContrast_primaryContainer() { public void lightTheme_minContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff5f5f5f);
0xffe2e2e2);
} }
@Test @Test
public void lightTheme_standardContrast_primaryContainer() { public void lightTheme_standardContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3b3b3b);
0xffe2e2e2);
} }
@Test @Test
public void lightTheme_maxContrast_primaryContainer() { public void lightTheme_maxContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3a3a3a);
0xff434343);
} }
@Test @Test
public void lightTheme_minContrast_onPrimaryContainer() { public void lightTheme_minContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd9d9d9);
0xff646464);
} }
@Test @Test
public void lightTheme_standardContrast_onPrimaryContainer() { public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffffffff);
0xff1b1b1b);
} }
@Test @Test
public void lightTheme_maxContrast_onPrimaryContainer() { public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffcdcdcd);
0xffdadada);
} }
@Test @Test
public void lightTheme_minContrast_surface() { public void lightTheme_minContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
} }
@Test @Test
public void lightTheme_standardContrast_surface() { public void lightTheme_standardContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
} }
@Test @Test
public void lightTheme_maxContrast_surface() { public void lightTheme_maxContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
} }
@Test @Test
public void darkTheme_minContrast_primary() { public void darkTheme_minContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff747474); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffcccccc);
} }
@Test @Test
public void darkTheme_standardContrast_primary() { public void darkTheme_standardContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffc6c6c6); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffffffff);
} }
@Test @Test
public void darkTheme_maxContrast_primary() { public void darkTheme_maxContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff5f5f5); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffffffff);
} }
@Test @Test
public void darkTheme_minContrast_primaryContainer() { public void darkTheme_minContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffa3a3a3);
0xff474747);
} }
@Test @Test
public void darkTheme_standardContrast_primaryContainer() { public void darkTheme_standardContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffd4d4d4);
0xff474747);
} }
@Test @Test
public void darkTheme_maxContrast_primaryContainer() { public void darkTheme_maxContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffd5d5d5);
0xffcbcbcb);
} }
@Test @Test
public void darkTheme_minContrast_onPrimaryContainer() { public void darkTheme_minContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff393939);
0xffb5b5b5);
} }
@Test @Test
public void darkTheme_standardContrast_onPrimaryContainer() { public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff000000);
0xffe2e2e2);
} }
@Test @Test
public void darkTheme_maxContrast_onPrimaryContainer() { public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff404040);
0xff393939);
} }
@Test @Test
public void darkTheme_minContrast_onTertiaryContainer() { public void darkTheme_minContrast_onTertiaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffd1d1d1);
0xffb5b5b5);
} }
@Test @Test
public void darkTheme_standardContrast_onTertiaryContainer() { public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff000000);
0xffe2e2e2);
} }
@Test @Test
public void darkTheme_maxContrast_onTertiaryContainer() { public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff393939);
0xff393939);
} }
@Test @Test
public void darkTheme_minContrast_surface() { public void darkTheme_minContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
} }
@Test @Test
public void darkTheme_standardContrast_surface() { public void darkTheme_standardContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
} }
@Test @Test
public void darkTheme_maxContrast_surface() { public void darkTheme_maxContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1.0); SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
@Test
public void darkTheme_monochromeSpec() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primary().getHct(scheme).getTone()).isWithin(1).of(100);
assertThat(dynamicColors.onPrimary().getHct(scheme).getTone()).isWithin(1).of(10);
assertThat(dynamicColors.primaryContainer().getHct(scheme).getTone()).isWithin(1).of(85);
assertThat(dynamicColors.onPrimaryContainer().getHct(scheme).getTone()).isWithin(1).of(0);
assertThat(dynamicColors.secondary().getHct(scheme).getTone()).isWithin(1).of(80);
assertThat(dynamicColors.onSecondary().getHct(scheme).getTone()).isWithin(1).of(10);
assertThat(dynamicColors.secondaryContainer().getHct(scheme).getTone()).isWithin(1).of(30);
assertThat(dynamicColors.onSecondaryContainer().getHct(scheme).getTone()).isWithin(1).of(90);
assertThat(dynamicColors.tertiary().getHct(scheme).getTone()).isWithin(1).of(90);
assertThat(dynamicColors.onTertiary().getHct(scheme).getTone()).isWithin(1).of(10);
assertThat(dynamicColors.tertiaryContainer().getHct(scheme).getTone()).isWithin(1).of(60);
assertThat(dynamicColors.onTertiaryContainer().getHct(scheme).getTone()).isWithin(1).of(0);
}
@Test
public void lightTheme_monochromeSpec() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primary().getHct(scheme).getTone()).isWithin(1).of(0);
assertThat(dynamicColors.onPrimary().getHct(scheme).getTone()).isWithin(1).of(90);
assertThat(dynamicColors.primaryContainer().getHct(scheme).getTone()).isWithin(1).of(25);
assertThat(dynamicColors.onPrimaryContainer().getHct(scheme).getTone()).isWithin(1).of(100);
assertThat(dynamicColors.secondary().getHct(scheme).getTone()).isWithin(1).of(40);
assertThat(dynamicColors.onSecondary().getHct(scheme).getTone()).isWithin(1).of(100);
assertThat(dynamicColors.secondaryContainer().getHct(scheme).getTone()).isWithin(1).of(85);
assertThat(dynamicColors.onSecondaryContainer().getHct(scheme).getTone()).isWithin(1).of(10);
assertThat(dynamicColors.tertiary().getHct(scheme).getTone()).isWithin(1).of(25);
assertThat(dynamicColors.onTertiary().getHct(scheme).getTone()).isWithin(1).of(90);
assertThat(dynamicColors.tertiaryContainer().getHct(scheme).getTone()).isWithin(1).of(49);
assertThat(dynamicColors.onTertiaryContainer().getHct(scheme).getTone()).isWithin(1).of(100);
} }
} }

View File

@@ -25,204 +25,193 @@ import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct; import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeNeutral; import com.android.systemui.monet.scheme.SchemeNeutral;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest @SmallTest
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class SchemeNeutralTest extends SysuiTestCase { public final class SchemeNeutralTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test @Test
public void testKeyColors() { public void testKeyColors() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767685); .isSameColorAs(0xff767685);
assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777680); .isSameColorAs(0xff777680);
assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B); .isSameColorAs(0xff75758B);
assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff787678); .isSameColorAs(0xff787678);
assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff787678); .isSameColorAs(0xff787678);
} }
@Test @Test
public void lightTheme_minContrast_primary() { public void lightTheme_minContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff737383); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff737383);
} }
@Test @Test
public void lightTheme_standardContrast_primary() { public void lightTheme_standardContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5d5d6c); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5d5d6c);
} }
@Test @Test
public void lightTheme_maxContrast_primary() { public void lightTheme_maxContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff21212e); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff21212e);
} }
@Test @Test
public void lightTheme_minContrast_primaryContainer() { public void lightTheme_minContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe2e1f3);
0xffe2e1f3);
} }
@Test @Test
public void lightTheme_standardContrast_primaryContainer() { public void lightTheme_standardContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe2e1f3);
0xffe2e1f3);
} }
@Test @Test
public void lightTheme_maxContrast_primaryContainer() { public void lightTheme_maxContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff414250);
0xff414250);
} }
@Test @Test
public void lightTheme_minContrast_onPrimaryContainer() { public void lightTheme_minContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff636372);
0xff636372);
} }
@Test @Test
public void lightTheme_standardContrast_onPrimaryContainer() { public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff1a1b27);
0xff1a1b27);
} }
@Test @Test
public void lightTheme_maxContrast_onPrimaryContainer() { public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd9d8ea);
0xffd9d8ea);
} }
@Test @Test
public void lightTheme_minContrast_surface() { public void lightTheme_minContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffcf8fa); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffcf8fa);
} }
@Test @Test
public void lightTheme_standardContrast_surface() { public void lightTheme_standardContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffcf8fa); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffcf8fa);
} }
@Test @Test
public void lightTheme_maxContrast_surface() { public void lightTheme_maxContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffcf8fa); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffcf8fa);
} }
@Test @Test
public void darkTheme_minContrast_primary() { public void darkTheme_minContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff737383); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff737383);
} }
@Test @Test
public void darkTheme_standardContrast_primary() { public void darkTheme_standardContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffc6c5d6); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffc6c5d6);
} }
@Test @Test
public void darkTheme_maxContrast_primary() { public void darkTheme_maxContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff6f4ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
} }
@Test @Test
public void darkTheme_minContrast_primaryContainer() { public void darkTheme_minContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff454654);
0xff454654);
} }
@Test @Test
public void darkTheme_standardContrast_primaryContainer() { public void darkTheme_standardContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff454654);
0xff454654);
} }
@Test @Test
public void darkTheme_maxContrast_primaryContainer() { public void darkTheme_maxContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffcac9da);
0xffcac9da);
} }
@Test @Test
public void darkTheme_minContrast_onPrimaryContainer() { public void darkTheme_minContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffb5b3c4);
0xffb5b3c4);
} }
@Test @Test
public void darkTheme_standardContrast_onPrimaryContainer() { public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffe2e1f3);
0xffe2e1f3);
} }
@Test @Test
public void darkTheme_maxContrast_onPrimaryContainer() { public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff373846);
0xff373846);
} }
@Test @Test
public void darkTheme_minContrast_onTertiaryContainer() { public void darkTheme_minContrast_onTertiaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffb3b3cb);
0xffb3b3cb);
} }
@Test @Test
public void darkTheme_standardContrast_onTertiaryContainer() { public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffe1e0f9);
0xffe1e0f9);
} }
@Test @Test
public void darkTheme_maxContrast_onTertiaryContainer() { public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff37374b);
0xff37374b);
} }
@Test @Test
public void darkTheme_minContrast_surface() { public void darkTheme_minContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131315); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131315);
} }
@Test @Test
public void darkTheme_standardContrast_surface() { public void darkTheme_standardContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131315); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131315);
} }
@Test @Test
public void darkTheme_maxContrast_surface() { public void darkTheme_maxContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0); SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131315); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131315);
} }
} }

View File

@@ -25,225 +25,229 @@ import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct; import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeRainbow; import com.android.systemui.monet.scheme.SchemeRainbow;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest @SmallTest
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class SchemeRainbowTest extends SysuiTestCase { public final class SchemeRainbowTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test @Test
public void testKeyColors() { public void testKeyColors() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff696FC4); .isSameColorAs(0xff696FC4);
assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B); .isSameColorAs(0xff75758B);
assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff936B84); .isSameColorAs(0xff936B84);
assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707); .isSameColorAs(0xff070707);
assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707); .isSameColorAs(0xff070707);
} }
@Test @Test
public void lightTheme_minContrast_primary() { public void lightTheme_minContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff676DC1); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff676DC1);
} }
@Test @Test
public void lightTheme_standardContrast_primary() { public void lightTheme_standardContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5056A9); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5056A9);
} }
@Test @Test
public void lightTheme_maxContrast_primary() { public void lightTheme_maxContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff0F136A); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff0F136A);
} }
@Test @Test
public void lightTheme_minContrast_primaryContainer() { public void lightTheme_minContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF); 0xffE0E0FF);
} }
@Test @Test
public void lightTheme_standardContrast_primaryContainer() { public void lightTheme_standardContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF); 0xffE0E0FF);
} }
@Test @Test
public void lightTheme_maxContrast_primaryContainer() { public void lightTheme_maxContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff34398B); 0xff34398B);
} }
@Test @Test
public void lightTheme_minContrast_tertiaryContainer() { public void lightTheme_minContrast_tertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffffd8ee); 0xffffd8ee);
} }
@Test @Test
public void lightTheme_standardContrast_tertiaryContainer() { public void lightTheme_standardContrast_tertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffffd8ee); 0xffffd8ee);
} }
@Test @Test
public void lightTheme_maxContrast_tertiaryContainer() { public void lightTheme_maxContrast_tertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xff5A384E); 0xff5A384E);
} }
@Test @Test
public void lightTheme_minContrast_onPrimaryContainer() { public void lightTheme_minContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff565CB0); 0xff565CB0);
} }
@Test @Test
public void lightTheme_standardContrast_onPrimaryContainer() { public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff050865); 0xff050865);
} }
@Test @Test
public void lightTheme_maxContrast_onPrimaryContainer() { public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffd6d6ff); 0xffd6d6ff);
} }
@Test @Test
public void lightTheme_minContrast_surface() { public void lightTheme_minContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
} }
@Test @Test
public void lightTheme_standardContrast_surface() { public void lightTheme_standardContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
} }
@Test @Test
public void lightTheme_maxContrast_surface() { public void lightTheme_maxContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
} }
@Test @Test
public void darkTheme_minContrast_primary() { public void darkTheme_minContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff676DC1); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff676DC1);
} }
@Test @Test
public void darkTheme_standardContrast_primary() { public void darkTheme_standardContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffbec2ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
} }
@Test @Test
public void darkTheme_maxContrast_primary() { public void darkTheme_maxContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff6f4ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
} }
@Test @Test
public void darkTheme_minContrast_primaryContainer() { public void darkTheme_minContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff383E8F); 0xff383E8F);
} }
@Test @Test
public void darkTheme_standardContrast_primaryContainer() { public void darkTheme_standardContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff383E8F); 0xff383E8F);
} }
@Test @Test
public void darkTheme_maxContrast_primaryContainer() { public void darkTheme_maxContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffc4c6ff); 0xffc4c6ff);
} }
@Test @Test
public void darkTheme_minContrast_onPrimaryContainer() { public void darkTheme_minContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffa9afff); 0xffa9afff);
} }
@Test @Test
public void darkTheme_standardContrast_onPrimaryContainer() { public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffe0e0ff); 0xffe0e0ff);
} }
@Test @Test
public void darkTheme_maxContrast_onPrimaryContainer() { public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff292f81); 0xff292f81);
} }
@Test @Test
public void darkTheme_minContrast_onTertiaryContainer() { public void darkTheme_minContrast_onTertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffd5a8c3); 0xffd5a8c3);
} }
@Test @Test
public void darkTheme_standardContrast_onTertiaryContainer() { public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffffd8ee); 0xffffd8ee);
} }
@Test @Test
public void darkTheme_maxContrast_onTertiaryContainer() { public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xff4f2e44); 0xff4f2e44);
} }
@Test @Test
public void darkTheme_minContrast_surface() { public void darkTheme_minContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
} }
@Test @Test
public void darkTheme_standardContrast_surface() { public void darkTheme_standardContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
} }
@Test @Test
public void darkTheme_maxContrast_surface() { public void darkTheme_maxContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0); SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
} }
} }

View File

@@ -25,348 +25,338 @@ import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct; import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeTonalSpot; import com.android.systemui.monet.scheme.SchemeTonalSpot;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest @SmallTest
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class SchemeTonalSpotTest extends SysuiTestCase { public final class SchemeTonalSpotTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test @Test
public void testKeyColors() { public void testKeyColors() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff6E72AC); .isSameColorAs(0xff6E72AC);
assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B); .isSameColorAs(0xff75758B);
assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff936B84); .isSameColorAs(0xff936B84);
assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff78767A); .isSameColorAs(0xff78767A);
assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777680); .isSameColorAs(0xff777680);
} }
@Test @Test
public void lightTheme_minContrast_primary() { public void lightTheme_minContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff6c70aa); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff6a6fb1);
} }
@Test @Test
public void lightTheme_standardContrast_primary() { public void lightTheme_standardContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff555992); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff545999);
} }
@Test @Test
public void lightTheme_maxContrast_primary() { public void lightTheme_maxContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff181c51); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff161a59);
} }
@Test @Test
public void lightTheme_minContrast_primaryContainer() { public void lightTheme_minContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
0xffe0e0ff);
} }
@Test @Test
public void lightTheme_standardContrast_primaryContainer() { public void lightTheme_standardContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
0xffe0e0ff);
} }
@Test @Test
public void lightTheme_maxContrast_primaryContainer() { public void lightTheme_maxContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff383c7c);
0xff3a3e74);
} }
@Test @Test
public void lightTheme_minContrast_onPrimaryContainer() { public void lightTheme_minContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff5a5fa0);
0xff5C5F98);
} }
@Test @Test
public void lightTheme_standardContrast_onPrimaryContainer() { public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff0e1253);
0xff11144B);
} }
@Test @Test
public void lightTheme_maxContrast_onPrimaryContainer() { public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd6d6ff);
0xffd6d6ff);
} }
@Test @Test
public void lightTheme_minContrast_surface() { public void lightTheme_minContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xffFCF8FD); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_standardContrast_surface() { public void lightTheme_standardContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xffFCF8FD); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_maxContrast_surface() { public void lightTheme_maxContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xffFCF8FD); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_minContrast_onSurface() { public void lightTheme_minContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff605E62); assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xff5f5e65);
} }
@Test @Test
public void lightTheme_standardContrast_onSurface() { public void lightTheme_standardContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff1B1B1F); assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xff1b1b21);
} }
@Test @Test
public void lightTheme_maxContrast_onSurface() { public void lightTheme_maxContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff1B1A1E); assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xff1a1a20);
} }
@Test @Test
public void lightTheme_minContrast_onSecondary() { public void lightTheme_minContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xffcfcfe7); assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xffcfcfe7);
} }
@Test @Test
public void lightTheme_standardContrast_onSecondary() { public void lightTheme_standardContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xffffffff); assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xffffffff);
} }
@Test @Test
public void lightTheme_maxContrast_onSecondary() { public void lightTheme_maxContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xffababc3); assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xffababc3);
} }
@Test @Test
public void lightTheme_minContrast_onTertiary() { public void lightTheme_minContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xfff3c3df); assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xfff3c3df);
} }
@Test @Test
public void lightTheme_standardContrast_onTertiary() { public void lightTheme_standardContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xffffffff); assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xffffffff);
} }
@Test @Test
public void lightTheme_maxContrast_onTertiary() { public void lightTheme_maxContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xffcda0bb); assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xffcda0bb);
} }
@Test @Test
public void lightTheme_minContrast_onError() { public void lightTheme_minContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xffffc2bb); assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffffc2bb);
} }
@Test @Test
public void lightTheme_standardContrast_onError() { public void lightTheme_standardContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xffffffff); assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffffffff);
} }
@Test @Test
public void lightTheme_maxContrast_onError() { public void lightTheme_maxContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xffff8d80); assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffff8d80);
} }
@Test @Test
public void darkTheme_minContrast_primary() { public void darkTheme_minContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff6C70AA); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff6a6fb1);
} }
@Test @Test
public void darkTheme_standardContrast_primary() { public void darkTheme_standardContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffbec2ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
} }
@Test @Test
public void darkTheme_maxContrast_primary() { public void darkTheme_maxContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff6f4ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
} }
@Test @Test
public void darkTheme_minContrast_primaryContainer() { public void darkTheme_minContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3c4180);
0xff3E4278);
} }
@Test @Test
public void darkTheme_standardContrast_primaryContainer() { public void darkTheme_standardContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3c4180);
0xff3E4278);
} }
@Test @Test
public void darkTheme_maxContrast_primaryContainer() { public void darkTheme_maxContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffc4c6ff);
0xffc4c6ff);
} }
@Test @Test
public void darkTheme_minContrast_onPrimaryContainer() { public void darkTheme_minContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffabaff7);
0xffadb0ef);
} }
@Test @Test
public void darkTheme_standardContrast_onPrimaryContainer() { public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
0xffe0e0ff);
} }
@Test @Test
public void darkTheme_maxContrast_onPrimaryContainer() { public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff2e3271);
0xff30346A);
} }
@Test @Test
public void darkTheme_minContrast_onTertiaryContainer() { public void darkTheme_minContrast_onTertiaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffd5a8c3);
0xffd5a8c3);
} }
@Test @Test
public void darkTheme_standardContrast_onTertiaryContainer() { public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffffd8ee);
0xffffd8ee);
} }
@Test @Test
public void darkTheme_maxContrast_onTertiaryContainer() { public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff4f2e44);
0xff4f2e44);
} }
@Test @Test
public void darkTheme_minContrast_onSecondary() { public void darkTheme_minContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xfffffbff); assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xfffffbff);
} }
@Test @Test
public void darkTheme_standardContrast_onSecondary() { public void darkTheme_standardContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xff2e2f42); assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xff2e2f42);
} }
@Test @Test
public void darkTheme_maxContrast_onSecondary() { public void darkTheme_maxContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xff505165); assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xff505165);
} }
@Test @Test
public void darkTheme_minContrast_onTertiary() { public void darkTheme_minContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xfffffbff); assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xfffffbff);
} }
@Test @Test
public void darkTheme_standardContrast_onTertiary() { public void darkTheme_standardContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xff46263b); assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xff46263b);
} }
@Test @Test
public void darkTheme_maxContrast_onTertiary() { public void darkTheme_maxContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xff6b485f); assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xff6b485f);
} }
@Test @Test
public void darkTheme_minContrast_onError() { public void darkTheme_minContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xfffffbff); assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xfffffbff);
} }
@Test @Test
public void darkTheme_standardContrast_onError() { public void darkTheme_standardContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xff690005); assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xff690005);
} }
@Test @Test
public void darkTheme_maxContrast_onError() { public void darkTheme_maxContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xffa80710); assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffa80710);
} }
@Test @Test
public void darkTheme_minContrast_surface() { public void darkTheme_minContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131316); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131318);
} }
@Test @Test
public void darkTheme_standardContrast_surface() { public void darkTheme_standardContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131316); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131318);
} }
@Test @Test
public void darkTheme_maxContrast_surface() { public void darkTheme_maxContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131316); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131318);
} }
@Test @Test
public void darkTheme_minContrast_onSurface() { public void darkTheme_minContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffa4a2a6); assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xffa4a2a9);
} }
@Test @Test
public void darkTheme_standardContrast_onSurface() { public void darkTheme_standardContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffe5e1e6); assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xffe4e1e9);
} }
@Test @Test
public void darkTheme_maxContrast_onSurface() { public void darkTheme_maxContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffe6e2e7); assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xffe5e2ea);
} }
} }

View File

@@ -25,204 +25,193 @@ import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct; import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeVibrant; import com.android.systemui.monet.scheme.SchemeVibrant;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest @SmallTest
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class SchemeVibrantTest extends SysuiTestCase { public final class SchemeVibrantTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test @Test
public void testKeyColors() { public void testKeyColors() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff080CFF); .isSameColorAs(0xff080CFF);
assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff7B7296); .isSameColorAs(0xff7B7296);
assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff886C9D); .isSameColorAs(0xff886C9D);
assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777682); .isSameColorAs(0xff777682);
assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767685); .isSameColorAs(0xff767685);
} }
@Test @Test
public void lightTheme_minContrast_primary() { public void lightTheme_minContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5660ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5660ff);
} }
@Test @Test
public void lightTheme_standardContrast_primary() { public void lightTheme_standardContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff343dff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff343dff);
} }
@Test @Test
public void lightTheme_maxContrast_primary() { public void lightTheme_maxContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff000181); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000181);
} }
@Test @Test
public void lightTheme_minContrast_primaryContainer() { public void lightTheme_minContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
0xffe0e0ff);
} }
@Test @Test
public void lightTheme_standardContrast_primaryContainer() { public void lightTheme_standardContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
0xffe0e0ff);
} }
@Test @Test
public void lightTheme_maxContrast_primaryContainer() { public void lightTheme_maxContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e3);
0xff0000e3);
} }
@Test @Test
public void lightTheme_minContrast_onPrimaryContainer() { public void lightTheme_minContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff3e47ff);
0xff3e47ff);
} }
@Test @Test
public void lightTheme_standardContrast_onPrimaryContainer() { public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff00006e);
0xff00006e);
} }
@Test @Test
public void lightTheme_maxContrast_onPrimaryContainer() { public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd6d6ff);
0xffd6d6ff);
} }
@Test @Test
public void lightTheme_minContrast_surface() { public void lightTheme_minContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_standardContrast_surface() { public void lightTheme_standardContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void lightTheme_maxContrast_surface() { public void lightTheme_maxContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
} }
@Test @Test
public void darkTheme_minContrast_primary() { public void darkTheme_minContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5660ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5660ff);
} }
@Test @Test
public void darkTheme_standardContrast_primary() { public void darkTheme_standardContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffbec2ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
} }
@Test @Test
public void darkTheme_maxContrast_primary() { public void darkTheme_maxContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff6f4ff); assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
} }
@Test @Test
public void darkTheme_minContrast_primaryContainer() { public void darkTheme_minContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000ef);
0xff0000ef);
} }
@Test @Test
public void darkTheme_standardContrast_primaryContainer() { public void darkTheme_standardContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000ef);
0xff0000ef);
} }
@Test @Test
public void darkTheme_maxContrast_primaryContainer() { public void darkTheme_maxContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffc4c6ff);
0xffc4c6ff);
} }
@Test @Test
public void darkTheme_minContrast_onPrimaryContainer() { public void darkTheme_minContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffa9afff);
0xffa9afff);
} }
@Test @Test
public void darkTheme_standardContrast_onPrimaryContainer() { public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
0xffe0e0ff);
} }
@Test @Test
public void darkTheme_maxContrast_onPrimaryContainer() { public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff0001c6);
0xff0001c6);
} }
@Test @Test
public void darkTheme_minContrast_onTertiaryContainer() { public void darkTheme_minContrast_onTertiaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffc9a9df);
0xffc9a9df);
} }
@Test @Test
public void darkTheme_standardContrast_onTertiaryContainer() { public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xfff2daff);
0xfff2daff);
} }
@Test @Test
public void darkTheme_maxContrast_onTertiaryContainer() { public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs( assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff472e5b);
0xff472e5b);
} }
@Test @Test
public void darkTheme_minContrast_surface() { public void darkTheme_minContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131C); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
} }
@Test @Test
public void darkTheme_standardContrast_surface() { public void darkTheme_standardContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131C); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
} }
@Test @Test
public void darkTheme_maxContrast_surface() { public void darkTheme_maxContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0); SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131C); assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
} }
} }