Remove monet test folder from SystemUI

The tests are in google3/javatests/com/google/ux/material/libmonet.
There should be no more monet source code in in frameworks/base.

Bug: 290464773
Test: treehugger
Test: atest SystemUITest
Change-Id: Ia687812bd2c48f2494dd1e4bcdbdddbdd9227b84
This commit is contained in:
Aurélien Pomini
2023-07-19 11:41:14 +00:00
parent 00f62accd7
commit 6341e29dcf
25 changed files with 1 additions and 4240 deletions

View File

@@ -27,7 +27,7 @@ import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.biometrics.AuthController
import com.android.systemui.keyguard.ui.view.KeyguardRootView
import com.android.systemui.monet.utils.ArgbSubject.assertThat
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,109 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.blend.Blend;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@SmallTest
@RunWith(JUnit4.class)
public final class BlendTest extends SysuiTestCase {
private static final int RED = 0xffff0000;
private static final int BLUE = 0xff0000ff;
private static final int GREEN = 0xff00ff00;
private static final int YELLOW = 0xffffff00;
@Test
public void harmonize_redToBlue() {
int blended = Blend.harmonize(RED, BLUE);
assertThat(blended).isSameColorAs(0xffFB0057);
}
@Test
public void harmonize_redToGreen() {
int answer = Blend.harmonize(RED, GREEN);
assertThat(answer).isSameColorAs(0xffD85600);
}
@Test
public void harmonize_redToYellow() {
int answer = Blend.harmonize(RED, YELLOW);
assertThat(answer).isSameColorAs(0xffD85600);
}
@Test
public void harmonize_blueToGreen() {
int answer = Blend.harmonize(BLUE, GREEN);
assertThat(answer).isSameColorAs(0xff0047A3);
}
@Test
public void harmonize_blueToRed() {
int answer = Blend.harmonize(BLUE, RED);
assertThat(answer).isSameColorAs(0xff5700DC);
}
@Test
public void harmonize_blueToYellow() {
int answer = Blend.harmonize(BLUE, YELLOW);
assertThat(answer).isSameColorAs(0xff0047A3);
}
@Test
public void harmonize_greenToBlue() {
int answer = Blend.harmonize(GREEN, BLUE);
assertThat(answer).isSameColorAs(0xff00FC94);
}
@Test
public void harmonize_greenToRed() {
int answer = Blend.harmonize(GREEN, RED);
assertThat(answer).isSameColorAs(0xffB1F000);
}
@Test
public void harmonize_greenToYellow() {
int answer = Blend.harmonize(GREEN, YELLOW);
assertThat(answer).isSameColorAs(0xffB1F000);
}
@Test
public void harmonize_yellowToBlue() {
int answer = Blend.harmonize(YELLOW, BLUE);
assertThat(answer).isSameColorAs(0xffEBFFBA);
}
@Test
public void harmonize_yellowToGreen() {
int answer = Blend.harmonize(YELLOW, GREEN);
assertThat(answer).isSameColorAs(0xffEBFFBA);
}
@Test
public void harmonize_yellowToRed() {
int answer = Blend.harmonize(YELLOW, RED);
assertThat(answer).isSameColorAs(0xffFFF6E3);
}
}

View File

@@ -1,210 +0,0 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import android.app.WallpaperColors;
import android.graphics.Color;
import android.testing.AndroidTestingRunner;
import android.util.Log;
import androidx.test.filters.SmallTest;
import com.android.internal.graphics.cam.Cam;
import com.android.systemui.SysuiTestCase;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.List;
@SmallTest
@RunWith(AndroidTestingRunner.class)
public class ColorSchemeTest extends SysuiTestCase {
@Test
public void testFilterTransparency() {
ColorScheme colorScheme = new ColorScheme(Color.TRANSPARENT, false /* darkTheme */);
Assert.assertEquals(colorScheme.getAllAccentColors(),
new ColorScheme(0xFF1b6ef3, false).getAllAccentColors());
}
@Test
public void testDontFilterOpaque() {
ColorScheme colorScheme = new ColorScheme(0xFFFF0000, false /* darkTheme */);
Assert.assertNotEquals(colorScheme.getAllAccentColors(),
new ColorScheme(0xFF1b6ef3, false).getAllAccentColors());
}
@Test
public void testUniqueColors() {
WallpaperColors wallpaperColors = new WallpaperColors(Color.valueOf(0xffaec00a),
Color.valueOf(0xffaec00a), Color.valueOf(0xffaec00a));
List<Integer> rankedSeedColors = ColorScheme.getSeedColors(wallpaperColors);
Assert.assertEquals(rankedSeedColors, List.of(0xffaec00a));
}
@Test
public void testStyleApplied() {
WallpaperColors wallpaperColors = new WallpaperColors(Color.valueOf(0xffaec00a),
null, null);
// Expressive applies hue rotations to the theme color. The input theme color has hue
// 117, ensuring the hue changed significantly is a strong signal styles are being applied.
ColorScheme colorScheme = new ColorScheme(wallpaperColors, false, Style.EXPRESSIVE);
Assert.assertEquals(357.77, Cam.fromInt(colorScheme.getAccent1().getS500()).getHue(), 0.1);
}
@Test
public void testFiltersInvalidColors() {
WallpaperColors wallpaperColors = new WallpaperColors(Color.valueOf(0xff5e7ea2),
Color.valueOf(0xff5e7ea2), Color.valueOf(0xff000000));
List<Integer> rankedSeedColors = ColorScheme.getSeedColors(wallpaperColors);
Assert.assertEquals(rankedSeedColors, List.of(0xff5e7ea2));
}
@Test
public void testInvalidColorBecomesGBlue() {
WallpaperColors wallpaperColors = new WallpaperColors(Color.valueOf(0xff000000), null,
null);
List<Integer> rankedSeedColors = ColorScheme.getSeedColors(wallpaperColors);
Assert.assertEquals(rankedSeedColors, List.of(0xFF1b6ef3));
}
@Test
public void testDontFilterRRGGBB() {
ColorScheme colorScheme = new ColorScheme(0xFF0000, false /* darkTheme */);
Assert.assertEquals(colorScheme.getAllAccentColors(),
new ColorScheme(0xFFFF0000, false).getAllAccentColors());
}
@Test
public void testNoPopulationSignal() {
WallpaperColors wallpaperColors = new WallpaperColors(Color.valueOf(0xffaec00a),
Color.valueOf(0xffbe0000), Color.valueOf(0xffcc040f));
List<Integer> rankedSeedColors = ColorScheme.getSeedColors(wallpaperColors);
Assert.assertEquals(rankedSeedColors, List.of(0xffaec00a, 0xffbe0000, 0xffcc040f));
}
@Test
public void testTertiaryHueWrapsProperly() {
int colorInt = 0xffB3588A; // H350 C50 T50
ColorScheme colorScheme = new ColorScheme(colorInt, false /* darkTheme */);
int tertiaryMid = colorScheme.getAccent3().getAllShades().get(
colorScheme.getShadeCount() / 2);
Cam cam = Cam.fromInt(tertiaryMid);
Assert.assertEquals(cam.getHue(), 50.0, 10.0);
}
@Test
public void testSpritz() {
int colorInt = 0xffB3588A; // H350 C50 T50
ColorScheme colorScheme = new ColorScheme(colorInt, false /* darkTheme */,
Style.SPRITZ /* style */);
int primaryMid = colorScheme.getAccent1().getAllShades().get(
colorScheme.getShadeCount() / 2);
Cam cam = Cam.fromInt(primaryMid);
Assert.assertEquals(cam.getChroma(), 12.0, 1.0);
}
@Test
public void testVibrant() {
int colorInt = 0xffB3588A; // H350 C50 T50
ColorScheme colorScheme = new ColorScheme(colorInt, false /* darkTheme */,
Style.VIBRANT /* style */);
int neutralMid = colorScheme.getNeutral1().getAllShades().get(
colorScheme.getShadeCount() / 2);
Cam cam = Cam.fromInt(neutralMid);
Assert.assertTrue("chroma was " + cam.getChroma(), Math.floor(cam.getChroma()) <= 12.0);
}
@Test
public void testExpressive() {
int colorInt = 0xffB3588A; // H350 C50 T50
ColorScheme colorScheme = new ColorScheme(colorInt, false /* darkTheme */,
Style.EXPRESSIVE /* style */);
int neutralMid = colorScheme.getNeutral1().getAllShades().get(
colorScheme.getShadeCount() / 2);
Cam cam = Cam.fromInt(neutralMid);
Assert.assertTrue(cam.getChroma() <= 8.0);
}
@Test
public void testMonochromatic() {
int colorInt = 0xffB3588A; // H350 C50 T50
ColorScheme colorScheme = new ColorScheme(colorInt, false /* darkTheme */,
Style.MONOCHROMATIC /* style */);
int neutralMid = colorScheme.getNeutral1().getAllShades().get(
colorScheme.getShadeCount() / 2);
Assert.assertTrue(
Color.red(neutralMid) == Color.green(neutralMid)
&& Color.green(neutralMid) == Color.blue(neutralMid)
);
}
@Test
@SuppressWarnings("ResultOfMethodCallIgnored")
public void testToString() {
new ColorScheme(Color.TRANSPARENT, false /* darkTheme */).toString();
new ColorScheme(Color.argb(0, 0, 0, 0xf), false /* darkTheme */).toString();
new ColorScheme(Color.argb(0xff, 0xff, 0, 0), false /* darkTheme */).toString();
new ColorScheme(0xFFFFFFFF, false /* darkTheme */).toString();
new ColorScheme(Color.TRANSPARENT, true /* darkTheme */).toString();
new ColorScheme(Color.argb(0, 0, 0, 0xf), true /* darkTheme */).toString();
new ColorScheme(0xFFFF0000, true /* darkTheme */).toString();
new ColorScheme(0xFFFFFFFF, true /* darkTheme */).toString();
}
/**
* Generate xml for SystemPaletteTest#testThemeStyles().
*/
@Test
public void generateThemeStyles() {
StringBuilder xml = new StringBuilder();
for (int hue = 0; hue < 360; hue += 60) {
final int sourceColor = Cam.getInt(hue, 50f, 50f);
final String sourceColorHex = Integer.toHexString(sourceColor);
xml.append(" <theme color=\"").append(sourceColorHex).append("\">\n");
for (Style style : Style.values()) {
String styleName = style.name().toLowerCase();
ColorScheme colorScheme = new ColorScheme(sourceColor, false, style);
xml.append(" <").append(styleName).append(">");
List<String> colors = new ArrayList<>();
colorScheme.getAllHues().forEach(schemeHue -> {
colors.add("ffffff");
schemeHue.getAllShades().forEach(tone -> {
colors.add(Integer.toHexString(tone).substring(2));
});
});
xml.append(String.join(",", colors));
xml.append("</").append(styleName).append(">\n");
}
xml.append(" </theme>\n");
}
Log.d("ColorSchemeXml", xml.toString());
}
}

View File

@@ -1,207 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.google.common.truth.Truth.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.utils.ColorUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@SmallTest
@RunWith(JUnit4.class)
public final class ColorUtilsTest extends SysuiTestCase {
@Test
public void argbFromLab() {
assertThat(ColorUtils.argbFromLab(0.0, 0.0, 0.0)).isEqualTo(0xff000000);
assertThat(ColorUtils.argbFromLab(0.25, 0.0, 0.0)).isEqualTo(0xff010101);
assertThat(ColorUtils.argbFromLab(0.5, 0.0, 0.0)).isEqualTo(0xff020202);
assertThat(ColorUtils.argbFromLab(0.75, 0.0, 0.0)).isEqualTo(0xff030303);
assertThat(ColorUtils.argbFromLab(1.0, 0.0, 0.0)).isEqualTo(0xff040404);
assertThat(ColorUtils.argbFromLab(1.5, 0.0, 0.0)).isEqualTo(0xff050505);
assertThat(ColorUtils.argbFromLab(2.0, 0.0, 0.0)).isEqualTo(0xff070707);
assertThat(ColorUtils.argbFromLab(3.0, 0.0, 0.0)).isEqualTo(0xff0b0b0b);
assertThat(ColorUtils.argbFromLab(4.0, 0.0, 0.0)).isEqualTo(0xff0e0e0e);
assertThat(ColorUtils.argbFromLab(5.0, 0.0, 0.0)).isEqualTo(0xff111111);
assertThat(ColorUtils.argbFromLab(6.0, 0.0, 0.0)).isEqualTo(0xff131313);
assertThat(ColorUtils.argbFromLab(7.0, 0.0, 0.0)).isEqualTo(0xff151515);
assertThat(ColorUtils.argbFromLab(8.0, 0.0, 0.0)).isEqualTo(0xff181818);
assertThat(ColorUtils.argbFromLab(9.0, 0.0, 0.0)).isEqualTo(0xff191919);
assertThat(ColorUtils.argbFromLab(10.0, 0.0, 0.0)).isEqualTo(0xff1b1b1b);
assertThat(ColorUtils.argbFromLab(20.0, 0.0, 0.0)).isEqualTo(0xff303030);
assertThat(ColorUtils.argbFromLab(30.0, 0.0, 0.0)).isEqualTo(0xff474747);
assertThat(ColorUtils.argbFromLab(40.0, 0.0, 0.0)).isEqualTo(0xff5e5e5e);
assertThat(ColorUtils.argbFromLab(50.0, 0.0, 0.0)).isEqualTo(0xff777777);
assertThat(ColorUtils.argbFromLab(60.0, 0.0, 0.0)).isEqualTo(0xff919191);
assertThat(ColorUtils.argbFromLab(70.0, 0.0, 0.0)).isEqualTo(0xffababab);
assertThat(ColorUtils.argbFromLab(80.0, 0.0, 0.0)).isEqualTo(0xffc6c6c6);
assertThat(ColorUtils.argbFromLab(90.0, 0.0, 0.0)).isEqualTo(0xffe2e2e2);
assertThat(ColorUtils.argbFromLab(100.0, 0.0, 0.0)).isEqualTo(0xffffffff);
}
@Test
public void labFromArgb() {
assertThat(ColorUtils.labFromArgb(0xff000000)[0]).isWithin(0.001).of(0.0);
assertThat(ColorUtils.labFromArgb(0xff010101)[0]).isWithin(0.001).of(0.2741748000656514);
assertThat(ColorUtils.labFromArgb(0xff020202)[0]).isWithin(0.001).of(0.5483496001313029);
assertThat(ColorUtils.labFromArgb(0xff030303)[0]).isWithin(0.001).of(0.8225244001969543);
assertThat(ColorUtils.labFromArgb(0xff040404)[0]).isWithin(0.001).of(1.0966992002626057);
assertThat(ColorUtils.labFromArgb(0xff050505)[0]).isWithin(0.001).of(1.3708740003282571);
assertThat(ColorUtils.labFromArgb(0xff060606)[0]).isWithin(0.001).of(1.645048800393912);
assertThat(ColorUtils.labFromArgb(0xff070707)[0]).isWithin(0.001).of(1.9192236004595635);
assertThat(ColorUtils.labFromArgb(0xff080808)[0]).isWithin(0.001).of(2.193398400525215);
assertThat(ColorUtils.labFromArgb(0xff0c0c0c)[0]).isWithin(0.001).of(3.3209754491182544);
assertThat(ColorUtils.labFromArgb(0xff101010)[0]).isWithin(0.001).of(4.680444846419661);
assertThat(ColorUtils.labFromArgb(0xff181818)[0]).isWithin(0.001).of(8.248186036170349);
assertThat(ColorUtils.labFromArgb(0xff202020)[0]).isWithin(0.001).of(12.250030101522828);
assertThat(ColorUtils.labFromArgb(0xff404040)[0]).isWithin(0.001).of(27.093413739449055);
assertThat(ColorUtils.labFromArgb(0xff808080)[0]).isWithin(0.001).of(53.585013452169036);
assertThat(ColorUtils.labFromArgb(0xffffffff)[0]).isWithin(0.001).of(100.0);
}
@Test
public void argbFromLstar() {
assertThat(ColorUtils.argbFromLstar(0.0)).isEqualTo(0xff000000);
assertThat(ColorUtils.argbFromLstar(0.25)).isEqualTo(0xff010101);
assertThat(ColorUtils.argbFromLstar(0.5)).isEqualTo(0xff020202);
assertThat(ColorUtils.argbFromLstar(0.75)).isEqualTo(0xff030303);
assertThat(ColorUtils.argbFromLstar(1.0)).isEqualTo(0xff040404);
assertThat(ColorUtils.argbFromLstar(1.5)).isEqualTo(0xff050505);
assertThat(ColorUtils.argbFromLstar(2.0)).isEqualTo(0xff070707);
assertThat(ColorUtils.argbFromLstar(3.0)).isEqualTo(0xff0b0b0b);
assertThat(ColorUtils.argbFromLstar(4.0)).isEqualTo(0xff0e0e0e);
assertThat(ColorUtils.argbFromLstar(5.0)).isEqualTo(0xff111111);
assertThat(ColorUtils.argbFromLstar(6.0)).isEqualTo(0xff131313);
assertThat(ColorUtils.argbFromLstar(7.0)).isEqualTo(0xff151515);
assertThat(ColorUtils.argbFromLstar(8.0)).isEqualTo(0xff181818);
assertThat(ColorUtils.argbFromLstar(9.0)).isEqualTo(0xff191919);
assertThat(ColorUtils.argbFromLstar(10.0)).isEqualTo(0xff1b1b1b);
assertThat(ColorUtils.argbFromLstar(20.0)).isEqualTo(0xff303030);
assertThat(ColorUtils.argbFromLstar(30.0)).isEqualTo(0xff474747);
assertThat(ColorUtils.argbFromLstar(40.0)).isEqualTo(0xff5e5e5e);
assertThat(ColorUtils.argbFromLstar(50.0)).isEqualTo(0xff777777);
assertThat(ColorUtils.argbFromLstar(60.0)).isEqualTo(0xff919191);
assertThat(ColorUtils.argbFromLstar(70.0)).isEqualTo(0xffababab);
assertThat(ColorUtils.argbFromLstar(80.0)).isEqualTo(0xffc6c6c6);
assertThat(ColorUtils.argbFromLstar(90.0)).isEqualTo(0xffe2e2e2);
assertThat(ColorUtils.argbFromLstar(100.0)).isEqualTo(0xffffffff);
}
@Test
public void lstarFromArgb() {
assertThat(ColorUtils.lstarFromArgb(0xff000000)).isWithin(0.001).of(0.0);
assertThat(ColorUtils.lstarFromArgb(0xff010101)).isWithin(0.001).of(0.2741748000656518);
assertThat(ColorUtils.lstarFromArgb(0xff020202)).isWithin(0.001).of(0.5483496001313036);
assertThat(ColorUtils.lstarFromArgb(0xff030303)).isWithin(0.001).of(0.8225244001969553);
assertThat(ColorUtils.lstarFromArgb(0xff040404)).isWithin(0.001).of(1.0966992002626073);
assertThat(ColorUtils.lstarFromArgb(0xff050505)).isWithin(0.001).of(1.3708740003282587);
assertThat(ColorUtils.lstarFromArgb(0xff060606)).isWithin(0.001).of(1.6450488003939105);
assertThat(ColorUtils.lstarFromArgb(0xff070707)).isWithin(0.001).of(1.9192236004595624);
assertThat(ColorUtils.lstarFromArgb(0xff080808)).isWithin(0.001).of(2.1933984005252145);
assertThat(ColorUtils.lstarFromArgb(0xff0c0c0c)).isWithin(0.001).of(3.3209754491182557);
assertThat(ColorUtils.lstarFromArgb(0xff101010)).isWithin(0.001).of(4.680444846419663);
assertThat(ColorUtils.lstarFromArgb(0xff181818)).isWithin(0.001).of(8.248186036170349);
assertThat(ColorUtils.lstarFromArgb(0xff202020)).isWithin(0.001).of(12.250030101522828);
assertThat(ColorUtils.lstarFromArgb(0xff404040)).isWithin(0.001).of(27.093413739449055);
assertThat(ColorUtils.lstarFromArgb(0xff808080)).isWithin(0.001).of(53.585013452169036);
assertThat(ColorUtils.lstarFromArgb(0xffffffff)).isWithin(0.001).of(100.0);
}
@Test
public void yFromLstar() {
assertThat(ColorUtils.yFromLstar(0.0)).isWithin(1e-5).of(0.0);
assertThat(ColorUtils.yFromLstar(0.1)).isWithin(1e-5).of(0.0110705);
assertThat(ColorUtils.yFromLstar(0.2)).isWithin(1e-5).of(0.0221411);
assertThat(ColorUtils.yFromLstar(0.3)).isWithin(1e-5).of(0.0332116);
assertThat(ColorUtils.yFromLstar(0.4)).isWithin(1e-5).of(0.0442822);
assertThat(ColorUtils.yFromLstar(0.5)).isWithin(1e-5).of(0.0553528);
assertThat(ColorUtils.yFromLstar(1.0)).isWithin(1e-5).of(0.1107056);
assertThat(ColorUtils.yFromLstar(2.0)).isWithin(1e-5).of(0.2214112);
assertThat(ColorUtils.yFromLstar(3.0)).isWithin(1e-5).of(0.3321169);
assertThat(ColorUtils.yFromLstar(4.0)).isWithin(1e-5).of(0.4428225);
assertThat(ColorUtils.yFromLstar(5.0)).isWithin(1e-5).of(0.5535282);
assertThat(ColorUtils.yFromLstar(8.0)).isWithin(1e-5).of(0.8856451);
assertThat(ColorUtils.yFromLstar(10.0)).isWithin(1e-5).of(1.1260199);
assertThat(ColorUtils.yFromLstar(15.0)).isWithin(1e-5).of(1.9085832);
assertThat(ColorUtils.yFromLstar(20.0)).isWithin(1e-5).of(2.9890524);
assertThat(ColorUtils.yFromLstar(25.0)).isWithin(1e-5).of(4.4154767);
assertThat(ColorUtils.yFromLstar(30.0)).isWithin(1e-5).of(6.2359055);
assertThat(ColorUtils.yFromLstar(40.0)).isWithin(1e-5).of(11.2509737);
assertThat(ColorUtils.yFromLstar(50.0)).isWithin(1e-5).of(18.4186518);
assertThat(ColorUtils.yFromLstar(60.0)).isWithin(1e-5).of(28.1233342);
assertThat(ColorUtils.yFromLstar(70.0)).isWithin(1e-5).of(40.7494157);
assertThat(ColorUtils.yFromLstar(80.0)).isWithin(1e-5).of(56.6812907);
assertThat(ColorUtils.yFromLstar(90.0)).isWithin(1e-5).of(76.3033539);
assertThat(ColorUtils.yFromLstar(95.0)).isWithin(1e-5).of(87.6183294);
assertThat(ColorUtils.yFromLstar(99.0)).isWithin(1e-5).of(97.4360239);
assertThat(ColorUtils.yFromLstar(100.0)).isWithin(1e-5).of(100.0);
}
@Test
public void lstarFromY() {
assertThat(ColorUtils.lstarFromY(0.0)).isWithin(1e-5).of(0.0);
assertThat(ColorUtils.lstarFromY(0.1)).isWithin(1e-5).of(0.9032962);
assertThat(ColorUtils.lstarFromY(0.2)).isWithin(1e-5).of(1.8065925);
assertThat(ColorUtils.lstarFromY(0.3)).isWithin(1e-5).of(2.7098888);
assertThat(ColorUtils.lstarFromY(0.4)).isWithin(1e-5).of(3.6131851);
assertThat(ColorUtils.lstarFromY(0.5)).isWithin(1e-5).of(4.5164814);
assertThat(ColorUtils.lstarFromY(0.8856451)).isWithin(1e-5).of(8.0);
assertThat(ColorUtils.lstarFromY(1.0)).isWithin(1e-5).of(8.9914424);
assertThat(ColorUtils.lstarFromY(2.0)).isWithin(1e-5).of(15.4872443);
assertThat(ColorUtils.lstarFromY(3.0)).isWithin(1e-5).of(20.0438970);
assertThat(ColorUtils.lstarFromY(4.0)).isWithin(1e-5).of(23.6714419);
assertThat(ColorUtils.lstarFromY(5.0)).isWithin(1e-5).of(26.7347653);
assertThat(ColorUtils.lstarFromY(10.0)).isWithin(1e-5).of(37.8424304);
assertThat(ColorUtils.lstarFromY(15.0)).isWithin(1e-5).of(45.6341970);
assertThat(ColorUtils.lstarFromY(20.0)).isWithin(1e-5).of(51.8372115);
assertThat(ColorUtils.lstarFromY(25.0)).isWithin(1e-5).of(57.0754208);
assertThat(ColorUtils.lstarFromY(30.0)).isWithin(1e-5).of(61.6542222);
assertThat(ColorUtils.lstarFromY(40.0)).isWithin(1e-5).of(69.4695307);
assertThat(ColorUtils.lstarFromY(50.0)).isWithin(1e-5).of(76.0692610);
assertThat(ColorUtils.lstarFromY(60.0)).isWithin(1e-5).of(81.8381891);
assertThat(ColorUtils.lstarFromY(70.0)).isWithin(1e-5).of(86.9968642);
assertThat(ColorUtils.lstarFromY(80.0)).isWithin(1e-5).of(91.6848609);
assertThat(ColorUtils.lstarFromY(90.0)).isWithin(1e-5).of(95.9967686);
assertThat(ColorUtils.lstarFromY(95.0)).isWithin(1e-5).of(98.0335184);
assertThat(ColorUtils.lstarFromY(99.0)).isWithin(1e-5).of(99.6120372);
assertThat(ColorUtils.lstarFromY(100.0)).isWithin(1e-5).of(100.0);
}
@Test
public void yToLstarToY() {
for (double y = 0.0; y <= 100.0; y += 0.1) {
double lstar = ColorUtils.lstarFromY(y);
double reconstructedY = ColorUtils.yFromLstar(lstar);
assertThat(reconstructedY).isWithin(1e-8).of(y);
}
}
@Test
public void lstarToYToLstar() {
for (double lstar = 0.0; lstar <= 100.0; lstar += 0.1) {
double y = ColorUtils.yFromLstar(lstar);
double reconstructedLstar = ColorUtils.lstarFromY(y);
assertThat(reconstructedLstar).isWithin(1e-8).of(lstar);
}
}
}

View File

@@ -1,73 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static org.junit.Assert.assertEquals;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.contrast.Contrast;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@SmallTest
@RunWith(JUnit4.class)
public final class ContrastTest extends SysuiTestCase {
@Test
public void lighter_impossibleRatioErrors() {
assertEquals(-1.0, Contrast.lighter(90.0, 10.0), 0.001);
}
@Test
public void lighter_outOfBoundsInputAboveErrors() {
assertEquals(-1.0, Contrast.lighter(110.0, 2.0), 0.001);
}
@Test
public void lighter_outOfBoundsInputBelowErrors() {
assertEquals(-1.0, Contrast.lighter(-10.0, 2.0), 0.001);
}
@Test
public void lighterUnsafe_returnsMaxTone() {
assertEquals(100, Contrast.lighterUnsafe(100.0, 2.0), 0.001);
}
@Test
public void darker_impossibleRatioErrors() {
assertEquals(-1.0, Contrast.darker(10.0, 20.0), 0.001);
}
@Test
public void darker_outOfBoundsInputAboveErrors() {
assertEquals(-1.0, Contrast.darker(110.0, 2.0), 0.001);
}
@Test
public void darker_outOfBoundsInputBelowErrors() {
assertEquals(-1.0, Contrast.darker(-10.0, 2.0), 0.001);
}
@Test
public void darkerUnsafe_returnsMinTone() {
assertEquals(0.0, Contrast.darkerUnsafe(0.0, 2.0), 0.001);
}
}

View File

@@ -1,81 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.dislike.DislikeAnalyzer;
import com.android.systemui.monet.hct.Hct;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@SmallTest
@RunWith(JUnit4.class)
public final class DislikeTest extends SysuiTestCase {
@Test
public void monkSkinToneScaleColorsLiked() {
// From https://skintone.google#/get-started
int[] monkSkinToneScaleColors =
new int[]{
0xfff6ede4,
0xfff3e7db,
0xfff7ead0,
0xffeadaba,
0xffd7bd96,
0xffa07e56,
0xff825c43,
0xff604134,
0xff3a312a,
0xff292420,
};
for (int color : monkSkinToneScaleColors) {
assertFalse(DislikeAnalyzer.isDisliked(Hct.fromInt(color)));
}
}
@Test
public void bileColorsDisliked() {
int[] unlikable =
new int[]{
0xff95884B, 0xff716B40, 0xffB08E00, 0xff4C4308, 0xff464521,
};
for (int color : unlikable) {
assertTrue(DislikeAnalyzer.isDisliked(Hct.fromInt(color)));
}
}
@Test
public void bileColorsBecameLikable() {
int[] unlikable =
new int[]{
0xff95884B, 0xff716B40, 0xffB08E00, 0xff4C4308, 0xff464521,
};
for (int color : unlikable) {
Hct hct = Hct.fromInt(color);
assertTrue(DislikeAnalyzer.isDisliked(hct));
Hct likable = DislikeAnalyzer.fixIfDisliked(hct);
assertFalse(DislikeAnalyzer.isDisliked(likable));
}
}
}

View File

@@ -1,207 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import static org.junit.Assert.assertTrue;
import androidx.test.filters.SmallTest;
import com.android.systemui.monet.contrast.Contrast;
import com.android.systemui.monet.dynamiccolor.DynamicColor;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.dynamiccolor.ToneDeltaConstraint;
import com.android.systemui.monet.dynamiccolor.TonePolarity;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.DynamicScheme;
import com.android.systemui.monet.scheme.SchemeContent;
import com.android.systemui.monet.scheme.SchemeFidelity;
import com.android.systemui.monet.scheme.SchemeMonochrome;
import com.android.systemui.monet.scheme.SchemeTonalSpot;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class DynamicColorTest extends SysuiTestCase{
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test
public void fromArgbNoBackground_doesntChangeForContrast() {
final int blueArgb = 0xff0000ff;
final DynamicColor dynamicColor = DynamicColor.fromArgb(blueArgb);
final SchemeTonalSpot standardContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 0.0);
assertThat(dynamicColor.getArgb(standardContrast)).isSameColorAs(blueArgb);
final SchemeTonalSpot minContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, -1.0);
assertThat(dynamicColor.getArgb(minContrast)).isSameColorAs(blueArgb);
final SchemeTonalSpot maxContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 1.0);
assertThat(dynamicColor.getArgb(maxContrast)).isSameColorAs(blueArgb);
}
@Test
public void toneDeltaConstraintNoPreference_evaluatesCorrectly() {
final int blueArgb = 0xff0000ff;
final int redArgb = 0xffff0000;
final DynamicColor otherDynamicColor = DynamicColor.fromArgb(redArgb);
final DynamicColor dynamicColor =
DynamicColor.fromArgb(
blueArgb,
(s) -> 30.0,
null,
(s) -> new ToneDeltaConstraint(30, otherDynamicColor, TonePolarity.NO_PREFERENCE));
final SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 0.0);
assertThat(dynamicColor.getArgb(scheme)).isSameColorAs(0xff0000ef);
}
@Test
public void dynamicColor_withOpacity() {
final DynamicColor dynamicColor =
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);
final SchemeTonalSpot lightScheme = new SchemeTonalSpot(Hct.fromInt(0xff4285f4), false, 0.0);
assertThat(dynamicColor.getArgb(lightScheme)).isSameColorAs(0x1f000000);
final SchemeTonalSpot darkScheme = new SchemeTonalSpot(Hct.fromInt(0xff4285f4), true, 0.0);
assertThat(dynamicColor.getArgb(darkScheme)).isSameColorAs(0x33ffffff);
}
@Test
public void respectsContrast() {
final Hct[] seedColors =
new Hct[] {
Hct.fromInt(0xFFFF0000),
Hct.fromInt(0xFFFFFF00),
Hct.fromInt(0xFF00FF00),
Hct.fromInt(0xFF0000FF)
};
final double[] contrastLevels = {-1.0, -0.5, 0.0, 0.5, 1.0};
for (Hct seedColor : seedColors) {
for (double contrastLevel : contrastLevels) {
for (boolean isDark : new boolean[] {false, true}) {
final DynamicScheme[] schemes =
new DynamicScheme[] {
new SchemeContent(seedColor, isDark, contrastLevel),
new SchemeMonochrome(seedColor, isDark, contrastLevel),
new SchemeTonalSpot(seedColor, isDark, contrastLevel),
new SchemeFidelity(seedColor, isDark, contrastLevel)
};
for (final DynamicScheme scheme : schemes) {
assertTrue(
pairSatisfiesContrast(scheme, dynamicColors.onPrimary(), dynamicColors.primary()));
assertTrue(
pairSatisfiesContrast(
scheme, dynamicColors.onPrimaryContainer(), dynamicColors.primaryContainer()));
assertTrue(
pairSatisfiesContrast(
scheme, dynamicColors.onSecondary(), dynamicColors.secondary()));
assertTrue(
pairSatisfiesContrast(
scheme,
dynamicColors.onSecondaryContainer(),
dynamicColors.secondaryContainer()));
assertTrue(
pairSatisfiesContrast(
scheme, dynamicColors.onTertiary(), dynamicColors.tertiary()));
assertTrue(
pairSatisfiesContrast(
scheme,
dynamicColors.onTertiaryContainer(),
dynamicColors.tertiaryContainer()));
assertTrue(
pairSatisfiesContrast(scheme, dynamicColors.onError(), dynamicColors.error()));
assertTrue(
pairSatisfiesContrast(
scheme, dynamicColors.onErrorContainer(), dynamicColors.errorContainer()));
assertTrue(
pairSatisfiesContrast(
scheme, dynamicColors.onBackground(), dynamicColors.background()));
assertTrue(
pairSatisfiesContrast(
scheme, dynamicColors.onSurfaceVariant(), dynamicColors.surfaceVariant()));
assertTrue(
pairSatisfiesContrast(
scheme, dynamicColors.inverseOnSurface(), dynamicColors.inverseSurface()));
}
}
}
}
}
@Test
public void valuesAreCorrect() {
// Checks that the values of certain dynamic colors match Dart results.
assertThat(
dynamicColors
.onPrimaryContainer()
.getArgb(new SchemeFidelity(Hct.fromInt(0xFFFF0000), false, 0.5)))
.isSameColorAs(0xFFFFE5E1);
assertThat(
dynamicColors
.onSecondaryContainer()
.getArgb(new SchemeContent(Hct.fromInt(0xFF0000FF), false, 0.5)))
.isSameColorAs(0xFFFFFCFF);
assertThat(
dynamicColors
.onTertiaryContainer()
.getArgb(new SchemeContent(Hct.fromInt(0xFFFFFF00), true, -0.5)))
.isSameColorAs(0xFF616600);
assertThat(
dynamicColors
.inverseSurface()
.getArgb(new SchemeContent(Hct.fromInt(0xFF0000FF), false, 0.0)))
.isSameColorAs(0xFF2F2F3B);
assertThat(
dynamicColors
.inversePrimary()
.getArgb(new SchemeContent(Hct.fromInt(0xFFFF0000), false, -0.5)))
.isSameColorAs(0xFFFF907F);
assertThat(
dynamicColors
.outlineVariant()
.getArgb(new SchemeContent(Hct.fromInt(0xFFFFFF00), true, 0.0)))
.isSameColorAs(0xFF484831);
}
private boolean pairSatisfiesContrast(DynamicScheme scheme, DynamicColor fg, DynamicColor bg) {
double fgTone = fg.getHct(scheme).getTone();
double bgTone = bg.getHct(scheme).getTone();
double minimumRequirement = scheme.contrastLevel >= 0.0 ? 4.5 : 3.0;
return Contrast.ratioOfTones(fgTone, bgTone) >= minimumRequirement;
}
}

View File

@@ -1,320 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.hct.Cam16;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.hct.ViewingConditions;
import com.android.systemui.monet.utils.ColorUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@SmallTest
@RunWith(JUnit4.class)
public final class HctTest extends SysuiTestCase {
private static final int RED = 0xffff0000;
private static final int GREEN = 0xff00ff00;
private static final int BLUE = 0xff0000ff;
private static final int WHITE = 0xffffffff;
private static final int BLACK = 0xff000000;
private static final int MIDGRAY = 0xff777777;
public static final ViewingConditions VIEWING_CONDITIONS_WHITE_BACKGROUND =
ViewingConditions.make(
new double[]{
ColorUtils.whitePointD65()[0],
ColorUtils.whitePointD65()[1],
ColorUtils.whitePointD65()[2]
},
(200.0 / Math.PI * ColorUtils.yFromLstar(50.0) / 100.f),
100.0,
2.0,
false);
public static final ViewingConditions VIEWING_CONDITIONS_BLACK_BACKGROUND =
ViewingConditions.make(
new double[]{
ColorUtils.whitePointD65()[0],
ColorUtils.whitePointD65()[1],
ColorUtils.whitePointD65()[2]
},
(200.0 / Math.PI * ColorUtils.yFromLstar(50.0) / 100.f),
0.0,
2.0,
false);
@Test
public void camFromArgb_red() {
Cam16 cam = Cam16.fromInt(RED);
assertEquals(27.408, cam.getHue(), 0.001);
assertEquals(113.357, cam.getChroma(), 0.001);
assertEquals(46.445, cam.getJ(), 0.001);
assertEquals(89.494, cam.getM(), 0.001);
assertEquals(91.889, cam.getS(), 0.001);
assertEquals(105.988, cam.getQ(), 0.001);
}
@Test
public void camFromArgb_green() {
Cam16 cam = Cam16.fromInt(GREEN);
assertEquals(142.139, cam.getHue(), 0.001);
assertEquals(108.410, cam.getChroma(), 0.001);
assertEquals(79.331, cam.getJ(), 0.001);
assertEquals(85.587, cam.getM(), 0.001);
assertEquals(78.604, cam.getS(), 0.001);
assertEquals(138.520, cam.getQ(), 0.001);
}
@Test
public void camFromArgb_blue() {
Cam16 cam = Cam16.fromInt(BLUE);
assertEquals(282.788, cam.getHue(), 0.001);
assertEquals(87.230, cam.getChroma(), 0.001);
assertEquals(25.465, cam.getJ(), 0.001);
assertEquals(68.867, cam.getM(), 0.001);
assertEquals(93.674, cam.getS(), 0.001);
assertEquals(78.481, cam.getQ(), 0.001);
}
@Test
public void camFromArgb_white() {
Cam16 cam = Cam16.fromInt(WHITE);
assertEquals(209.492, cam.getHue(), 0.001);
assertEquals(2.869, cam.getChroma(), 0.001);
assertEquals(100.0, cam.getJ(), 0.001);
assertEquals(2.265, cam.getM(), 0.001);
assertEquals(12.068, cam.getS(), 0.001);
assertEquals(155.521, cam.getQ(), 0.001);
}
@Test
public void camFromArgb_black() {
Cam16 cam = Cam16.fromInt(BLACK);
assertEquals(0.0, cam.getHue(), 0.001);
assertEquals(0.0, cam.getChroma(), 0.001);
assertEquals(0.0, cam.getJ(), 0.001);
assertEquals(0.0, cam.getM(), 0.001);
assertEquals(0.0, cam.getS(), 0.001);
assertEquals(0.0, cam.getQ(), 0.001);
}
@Test
public void camToArgbToCam_red() {
Cam16 cam = Cam16.fromInt(RED);
int argb = cam.toInt();
assertEquals(RED, argb);
}
@Test
public void camToArgbToCam_green() {
Cam16 cam = Cam16.fromInt(GREEN);
int argb = cam.toInt();
assertEquals(GREEN, argb);
}
@Test
public void camToArgbToCam_blue() {
Cam16 cam = Cam16.fromInt(BLUE);
int argb = cam.toInt();
assertEquals(BLUE, argb);
}
@Test
public void viewingConditions_default() {
ViewingConditions vc = ViewingConditions.DEFAULT;
assertEquals(0.184, vc.getN(), 0.001);
assertEquals(29.981, vc.getAw(), 0.001);
assertEquals(1.016, vc.getNbb(), 0.001);
assertEquals(1.021, vc.getRgbD()[0], 0.001);
assertEquals(0.986, vc.getRgbD()[1], 0.001);
assertEquals(0.933, vc.getRgbD()[2], 0.001);
assertEquals(0.789, vc.getFlRoot(), 0.001);
}
private boolean colorIsOnBoundary(int argb) {
return ColorUtils.redFromArgb(argb) == 0
|| ColorUtils.redFromArgb(argb) == 255
|| ColorUtils.greenFromArgb(argb) == 0
|| ColorUtils.greenFromArgb(argb) == 255
|| ColorUtils.blueFromArgb(argb) == 0
|| ColorUtils.blueFromArgb(argb) == 255;
}
@Test
public void correctness() {
for (int hue = 15; hue < 360; hue += 30) {
for (int chroma = 0; chroma <= 100; chroma += 10) {
for (int tone = 20; tone <= 80; tone += 10) {
Hct hctColor = Hct.from((double) hue, (double) chroma, (double) tone);
if (chroma > 0) {
assertEquals(
"Incorrect hue for H" + hue + " C" + chroma + " T" + tone,
hue,
hctColor.getHue(),
4.0);
}
assertTrue(
"Negative chroma for H" + hue + " C" + chroma + " T" + tone,
hctColor.getChroma() >= 0.0);
assertTrue(
"Chroma too high for H" + hue + " C" + chroma + " T" + tone,
hctColor.getChroma() <= chroma + 2.5);
if (hctColor.getChroma() < chroma - 2.5) {
assertTrue(
"Color not on boundary for non-sRGB color for H"
+ hue
+ " C"
+ chroma
+ " T"
+ tone,
colorIsOnBoundary(hctColor.toInt()));
}
assertEquals(tone, hctColor.getTone(), 0.5);
}
}
}
}
@Test
public void relativity_redInBlack() {
final int colorToTest = RED;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xff9F5C51)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_BLACK_BACKGROUND).toInt());
}
@Test
public void relativity_redInWhite() {
final int colorToTest = RED;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xffFF5D48)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_WHITE_BACKGROUND).toInt());
}
@Test
public void relativity_greenInBlack() {
final int colorToTest = GREEN;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xffACD69D)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_BLACK_BACKGROUND).toInt());
}
@Test
public void relativity_greenInWhite() {
final int colorToTest = GREEN;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xff8EFF77)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_WHITE_BACKGROUND).toInt());
}
@Test
public void relativity_blueInBlack() {
final int colorToTest = BLUE;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xff343654)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_BLACK_BACKGROUND).toInt());
}
@Test
public void relativity_blueInWhite() {
final int colorToTest = BLUE;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xff3F49FF)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_WHITE_BACKGROUND).toInt());
}
@Test
public void relativity_whiteInBlack() {
final int colorToTest = WHITE;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xffFFFFFF)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_BLACK_BACKGROUND).toInt());
}
@Test
public void relativity_whiteInWhite() {
final int colorToTest = WHITE;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xffFFFFFF)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_WHITE_BACKGROUND).toInt());
}
@Test
public void relativity_midgrayInBlack() {
final int colorToTest = MIDGRAY;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xff605F5F)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_BLACK_BACKGROUND).toInt());
}
@Test
public void relativity_midgrayInWhite() {
final int colorToTest = MIDGRAY;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xff8E8E8E)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_WHITE_BACKGROUND).toInt());
}
@Test
public void relativity_blackInBlack() {
final int colorToTest = BLACK;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xff000000)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_BLACK_BACKGROUND).toInt());
}
@Test
public void relativity_blackInWhite() {
final int colorToTest = BLACK;
final Hct hct = Hct.fromInt(colorToTest);
assertThat(0xff000000)
.isSameColorAs(
hct.inViewingConditions(VIEWING_CONDITIONS_WHITE_BACKGROUND).toInt());
}
}

View File

@@ -1,99 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.google.common.truth.Truth.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.utils.MathUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@SmallTest
@RunWith(JUnit4.class)
public final class MathUtilsTest extends SysuiTestCase {
@Test
public void signum() {
assertThat(MathUtils.signum(1.5)).isEqualTo(1);
assertThat(MathUtils.signum(0)).isEqualTo(0);
assertThat(MathUtils.signum(-3.0)).isEqualTo(-1);
}
@Test
public void sanitizeDegreesInt() {
assertThat(MathUtils.sanitizeDegreesInt(0)).isEqualTo(0);
assertThat(MathUtils.sanitizeDegreesInt(30)).isEqualTo(30);
assertThat(MathUtils.sanitizeDegreesInt(150)).isEqualTo(150);
assertThat(MathUtils.sanitizeDegreesInt(360)).isEqualTo(0);
assertThat(MathUtils.sanitizeDegreesInt(450)).isEqualTo(90);
assertThat(MathUtils.sanitizeDegreesInt(1000000)).isEqualTo(280);
assertThat(MathUtils.sanitizeDegreesInt(-10)).isEqualTo(350);
assertThat(MathUtils.sanitizeDegreesInt(-90)).isEqualTo(270);
assertThat(MathUtils.sanitizeDegreesInt(-1000000)).isEqualTo(80);
}
@Test
public void sanitizeDegreesDouble() {
assertThat(MathUtils.sanitizeDegreesDouble(0.0)).isWithin(0.001).of(0.0);
assertThat(MathUtils.sanitizeDegreesDouble(30.0)).isWithin(0.001).of(30.0);
assertThat(MathUtils.sanitizeDegreesDouble(150.0)).isWithin(0.001).of(150.0);
assertThat(MathUtils.sanitizeDegreesDouble(360.0)).isWithin(0.001).of(0.0);
assertThat(MathUtils.sanitizeDegreesDouble(450.0)).isWithin(0.001).of(90.0);
assertThat(MathUtils.sanitizeDegreesDouble(1000000.0)).isWithin(0.001).of(280.0);
assertThat(MathUtils.sanitizeDegreesDouble(-10.0)).isWithin(0.001).of(350.0);
assertThat(MathUtils.sanitizeDegreesDouble(-90.0)).isWithin(0.001).of(270.0);
assertThat(MathUtils.sanitizeDegreesDouble(-1000000.0)).isWithin(0.001).of(80.0);
assertThat(MathUtils.sanitizeDegreesDouble(100.375)).isWithin(0.001).of(100.375);
assertThat(MathUtils.sanitizeDegreesDouble(123456.789)).isWithin(0.001).of(336.789);
assertThat(MathUtils.sanitizeDegreesDouble(-200.625)).isWithin(0.001).of(159.375);
assertThat(MathUtils.sanitizeDegreesDouble(-123456.789)).isWithin(0.001).of(23.211);
}
@Test
public void rotationDirection() {
for (double from = 0.0; from < 360.0; from += 15.0) {
for (double to = 7.5; to < 360.0; to += 15.0) {
double expectedAnswer = originalRotationDirection(from, to);
double actualAnswer = MathUtils.rotationDirection(from, to);
assertThat(actualAnswer).isEqualTo(expectedAnswer);
assertThat(Math.abs(actualAnswer)).isEqualTo(1.0);
}
}
}
// Original implementation for MathUtils.rotationDirection.
// Included here to test equivalence with new implementation.
private static double originalRotationDirection(double from, double to) {
double a = to - from;
double b = to - from + 360.0;
double c = to - from - 360.0;
double aAbs = Math.abs(a);
double bAbs = Math.abs(b);
double cAbs = Math.abs(c);
if (aAbs <= bAbs && aAbs <= cAbs) {
return a >= 0.0 ? 1.0 : -1.0;
} else if (bAbs <= aAbs && bAbs <= cAbs) {
return b >= 0.0 ? 1.0 : -1.0;
} else {
return c >= 0.0 ? 1.0 : -1.0;
}
}
}

View File

@@ -1,116 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.google.common.truth.Truth.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.hct.Cam16;
import com.android.systemui.monet.palettes.CorePalette;
import com.android.systemui.monet.palettes.TonalPalette;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@SmallTest
@RunWith(JUnit4.class)
public final class PalettesTest extends SysuiTestCase {
@Test
public void tones_ofBlue() {
int color = 0xff0000ff;
Cam16 cam = Cam16.fromInt(color);
TonalPalette tones = TonalPalette.fromHueAndChroma(cam.getHue(), cam.getChroma());
assertThat(tones.tone(100)).isEqualTo(0xFFFFFFFF);
assertThat(tones.tone(95)).isEqualTo(0xfff1efff);
assertThat(tones.tone(90)).isEqualTo(0xffe0e0ff);
assertThat(tones.tone(80)).isEqualTo(0xffbec2ff);
assertThat(tones.tone(70)).isEqualTo(0xff9da3ff);
assertThat(tones.tone(60)).isEqualTo(0xff7c84ff);
assertThat(tones.tone(50)).isEqualTo(0xff5a64ff);
assertThat(tones.tone(40)).isEqualTo(0xff343dff);
assertThat(tones.tone(30)).isEqualTo(0xff0000ef);
assertThat(tones.tone(20)).isEqualTo(0xff0001ac);
assertThat(tones.tone(10)).isEqualTo(0xff00006e);
assertThat(tones.tone(0)).isEqualTo(0xff000000);
}
@Test
public void keyTones_ofBlue() {
CorePalette core = CorePalette.of(0xff0000ff);
assertThat(core.a1.tone(100)).isEqualTo(0xFFFFFFFF);
assertThat(core.a1.tone(95)).isEqualTo(0xfff1efff);
assertThat(core.a1.tone(90)).isEqualTo(0xffe0e0ff);
assertThat(core.a1.tone(80)).isEqualTo(0xffbec2ff);
assertThat(core.a1.tone(70)).isEqualTo(0xff9da3ff);
assertThat(core.a1.tone(60)).isEqualTo(0xff7c84ff);
assertThat(core.a1.tone(50)).isEqualTo(0xff5a64ff);
assertThat(core.a1.tone(40)).isEqualTo(0xff343dff);
assertThat(core.a1.tone(30)).isEqualTo(0xff0000ef);
assertThat(core.a1.tone(20)).isEqualTo(0xff0001ac);
assertThat(core.a1.tone(10)).isEqualTo(0xff00006e);
assertThat(core.a1.tone(0)).isEqualTo(0xff000000);
assertThat(core.a2.tone(100)).isEqualTo(0xffffffff);
assertThat(core.a2.tone(95)).isEqualTo(0xfff1efff);
assertThat(core.a2.tone(90)).isEqualTo(0xffe1e0f9);
assertThat(core.a2.tone(80)).isEqualTo(0xffc5c4dd);
assertThat(core.a2.tone(70)).isEqualTo(0xffa9a9c1);
assertThat(core.a2.tone(60)).isEqualTo(0xff8f8fa6);
assertThat(core.a2.tone(50)).isEqualTo(0xff75758b);
assertThat(core.a2.tone(40)).isEqualTo(0xff5c5d72);
assertThat(core.a2.tone(30)).isEqualTo(0xff444559);
assertThat(core.a2.tone(20)).isEqualTo(0xff2e2f42);
assertThat(core.a2.tone(10)).isEqualTo(0xff191a2c);
assertThat(core.a2.tone(0)).isEqualTo(0xff000000);
}
@Test
public void keyTones_contentOfBlue() {
CorePalette core = CorePalette.contentOf(0xff0000ff);
assertThat(core.a1.tone(100)).isEqualTo(0xffffffff);
assertThat(core.a1.tone(95)).isEqualTo(0xfff1efff);
assertThat(core.a1.tone(90)).isEqualTo(0xffe0e0ff);
assertThat(core.a1.tone(80)).isEqualTo(0xffbec2ff);
assertThat(core.a1.tone(70)).isEqualTo(0xff9da3ff);
assertThat(core.a1.tone(60)).isEqualTo(0xff7c84ff);
assertThat(core.a1.tone(50)).isEqualTo(0xff5a64ff);
assertThat(core.a1.tone(40)).isEqualTo(0xff343dff);
assertThat(core.a1.tone(30)).isEqualTo(0xff0000ef);
assertThat(core.a1.tone(20)).isEqualTo(0xff0001ac);
assertThat(core.a1.tone(10)).isEqualTo(0xff00006e);
assertThat(core.a1.tone(0)).isEqualTo(0xff000000);
assertThat(core.a2.tone(100)).isEqualTo(0xffffffff);
assertThat(core.a2.tone(95)).isEqualTo(0xfff1efff);
assertThat(core.a2.tone(90)).isEqualTo(0xffe0e0ff);
assertThat(core.a2.tone(80)).isEqualTo(0xffc1c3f4);
assertThat(core.a2.tone(70)).isEqualTo(0xffa5a7d7);
assertThat(core.a2.tone(60)).isEqualTo(0xff8b8dbb);
assertThat(core.a2.tone(50)).isEqualTo(0xff7173a0);
assertThat(core.a2.tone(40)).isEqualTo(0xff585b86);
assertThat(core.a2.tone(30)).isEqualTo(0xff40436d);
assertThat(core.a2.tone(20)).isEqualTo(0xff2a2d55);
assertThat(core.a2.tone(10)).isEqualTo(0xff14173f);
assertThat(core.a2.tone(0)).isEqualTo(0xff000000);
}
}

View File

@@ -1,93 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.google.common.truth.Truth.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.quantize.QuantizerMap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Map;
@SmallTest
@RunWith(JUnit4.class)
public final class QuantizerMapTest extends SysuiTestCase {
private static final int RED = 0xffff0000;
private static final int GREEN = 0xff00ff00;
private static final int BLUE = 0xff0000ff;
private static final QuantizerMap quantizer = new QuantizerMap();
@Test
public void quantize_1R() {
Map<Integer, Integer> answer = quantizer.quantize(new int[]{RED}, 128).colorToCount;
assertThat(answer).hasSize(1);
assertThat(answer).containsEntry(RED, 1);
}
@Test
public void quantize_1G() {
Map<Integer, Integer> answer = quantizer.quantize(new int[]{GREEN}, 128).colorToCount;
assertThat(answer).hasSize(1);
assertThat(answer).containsEntry(GREEN, 1);
}
@Test
public void quantize_1B() {
Map<Integer, Integer> answer = quantizer.quantize(new int[]{BLUE}, 128).colorToCount;
assertThat(answer).hasSize(1);
assertThat(answer).containsEntry(BLUE, 1);
}
@Test
public void quantize_5B() {
Map<Integer, Integer> answer =
quantizer.quantize(new int[]{BLUE, BLUE, BLUE, BLUE, BLUE}, 128).colorToCount;
assertThat(answer).hasSize(1);
assertThat(answer).containsEntry(BLUE, 5);
}
@Test
public void quantize_2R3G() {
Map<Integer, Integer> answer =
quantizer.quantize(new int[]{RED, RED, GREEN, GREEN, GREEN}, 128).colorToCount;
assertThat(answer).hasSize(2);
assertThat(answer).containsEntry(RED, 2);
assertThat(answer).containsEntry(GREEN, 3);
}
@Test
public void quantize_1R1G1B() {
Map<Integer, Integer> answer =
quantizer.quantize(new int[]{RED, GREEN, BLUE}, 128).colorToCount;
assertThat(answer).hasSize(3);
assertThat(answer).containsEntry(RED, 1);
assertThat(answer).containsEntry(GREEN, 1);
assertThat(answer).containsEntry(BLUE, 1);
}
}

View File

@@ -1,4 +0,0 @@
The tests in this folder are imported from Google's internal source repository.
For instructions on importing, see:
frameworks/base/packages/SystemUI/tests/src/com/android/systemui/monet/README

View File

@@ -1,253 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeContent;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeContentTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test
public void testKeyColors() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff080CFF);
assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff656DD3);
assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff81009F);
assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767684);
assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff757589);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF1218FF);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF0001C3);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF000181);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF5660FF);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF2D36FF);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF0000E3);
}
@Test
public void lightTheme_minContrast_tertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFB042CC);
}
@Test
public void lightTheme_standardContrast_tertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF9221AF);
}
@Test
public void lightTheme_maxContrast_tertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF73008E);
}
@Test
public void lightTheme_minContrast_objectionableTertiaryContainerLightens() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, -1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFD03A71);
}
@Test
public void lightTheme_standardContrast_objectionableTertiaryContainerLightens() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, 0.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFAC1B57);
}
@Test
public void lightTheme_maxContrast_objectionableTertiaryContainerDarkens() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, 1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF870040);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFCBCDFF);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFCECFFF);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFD6D6FF);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF5660FF);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFFBEC2FF);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFFF6F4FF);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF0000E6);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF0000E6);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFFC4C6FF);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFF7A83FF);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFA4AAFF);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFF0001C6);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFCF60EA);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFEB8CFF);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF63007B);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFF12121D);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFF12121D);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFF12121D);
}
}

View File

@@ -1,199 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeExpressive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeExpressiveTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test
public void testKeyColors() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff35855F);
assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff8C6D8C);
assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff806EA1);
assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff79757F);
assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff7A7585);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffad603c);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff924b28);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff401400);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffffdbcc);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffffdbcc);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff6f3010);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff99512e);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff351000);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffffd0bc);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffad603c);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffffb595);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfffff3ee);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff743413);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff743413);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffffbb9e);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xfff99f75);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffffdbcc);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff622706);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
}

View File

@@ -1,254 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeFidelity;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeFidelityTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test
public void testKeyColors() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff080CFF);
assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff656DD3);
assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff9D0002);
assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767684);
assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff757589);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff1218ff);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff0001c3);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000181);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff5660ff);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff2d36ff);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e3);
}
@Test
public void lightTheme_minContrast_tertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffd93628);
}
@Test
public void lightTheme_standardContrast_tertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffb31910);
}
@Test
public void lightTheme_maxContrast_tertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xff8c0002);
}
@Test
public void lightTheme_minContrast_objectionableTertiaryContainerLightens() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, -1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffbcac5a);
}
@Test
public void lightTheme_standardContrast_objectionableTertiaryContainerLightens() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, 0.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffbcac5a);
}
@Test
public void lightTheme_maxContrast_objectionableTertiaryContainerDarkens() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, 1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xff4d4300);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffcbcdff);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffcecfff);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd6d6ff);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5660ff);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e6);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e6);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffc4c6ff);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff7a83ff);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffa4aaff);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff0001c6);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xfffe513e);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffFF9181);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff790001);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12121d);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12121d);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12121d);
}
}

View File

@@ -1,254 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeFruitSalad;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeFruitSaladTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test
public void testKeyColors() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff0091C0);
assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff3A7E9E);
assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff6E72AC);
assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777682);
assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff007ea7);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff006688);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff002635);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffC2E8FF);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffC2E8FF);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff004862);
}
@Test
public void lightTheme_minContrast_tertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF);
}
@Test
public void lightTheme_standardContrast_tertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF);
}
@Test
public void lightTheme_maxContrast_tertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xFF3A3E74);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff006C90);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff001E2B);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffACE1FF);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff007EA7);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF76D1FF);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFFECF7FF);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xFF004D67);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xFF004D67);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xFF83D5FF);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff55C0F2);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffC2E8FF);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff003E54);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffADB0EF);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffe0e0ff);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xff30346A);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131c);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131c);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131c);
}
}

View File

@@ -1,252 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.google.common.truth.Truth.assertThat;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeMonochrome;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeMonochromeTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test
public void testKeyColors() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff3c3c3c);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000000);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000000);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff5f5f5f);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3b3b3b);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3a3a3a);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd9d9d9);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffcdcdcd);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffcccccc);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffa3a3a3);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffd4d4d4);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffd5d5d5);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff393939);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff000000);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff404040);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffd1d1d1);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff000000);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff393939);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
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

@@ -1,217 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeNeutral;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeNeutralTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test
public void testKeyColors() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767685);
assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777680);
assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B);
assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff787678);
assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff787678);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff737383);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5d5d6c);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff21212e);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe2e1f3);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe2e1f3);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff414250);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff636372);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff1a1b27);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd9d8ea);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffcf8fa);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffcf8fa);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffcf8fa);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff737383);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffc6c5d6);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff454654);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff454654);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffcac9da);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffb5b3c4);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffe2e1f3);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff373846);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffb3b3cb);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffe1e0f9);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff37374b);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131315);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131315);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131315);
}
}

View File

@@ -1,253 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeRainbow;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeRainbowTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test
public void testKeyColors() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff696FC4);
assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B);
assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff936B84);
assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff676DC1);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5056A9);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff0F136A);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff34398B);
}
@Test
public void lightTheme_minContrast_tertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffffd8ee);
}
@Test
public void lightTheme_standardContrast_tertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffffd8ee);
}
@Test
public void lightTheme_maxContrast_tertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xff5A384E);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff565CB0);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff050865);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffd6d6ff);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff676DC1);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff383E8F);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff383E8F);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffc4c6ff);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffa9afff);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffe0e0ff);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff292f81);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffd5a8c3);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffffd8ee);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xff4f2e44);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
}

View File

@@ -1,201 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.scheme.Scheme;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeTest extends SysuiTestCase {
@Test
public void lightScheme_ofBlue() {
Scheme scheme = Scheme.light(0xff0000ff);
assertThat(scheme.getPrimary()).isSameColorAs(0xff343DFF);
}
@Test
public void darkScheme_ofBlue() {
Scheme scheme = Scheme.dark(0xff0000ff);
assertThat(scheme.getPrimary()).isSameColorAs(0xffBEC2FF);
}
@Test
public void thirdPartyScheme_light() {
Scheme scheme = Scheme.light(0xff6750A4);
assertThat(scheme.getPrimary()).isSameColorAs(0xff6750A4);
assertThat(scheme.getSecondary()).isSameColorAs(0xff625B71);
assertThat(scheme.getTertiary()).isSameColorAs(0xff7e5260);
assertThat(scheme.getSurface()).isSameColorAs(0xfffffbff);
assertThat(scheme.getOnSurface()).isSameColorAs(0xff1c1b1e);
}
@Test
public void thirdPartyScheme_dark() {
Scheme scheme = Scheme.dark(0xff6750A4);
assertThat(scheme.getPrimary()).isSameColorAs(0xffcfbcff);
assertThat(scheme.getSecondary()).isSameColorAs(0xffcbc2db);
assertThat(scheme.getTertiary()).isSameColorAs(0xffefb8c8);
assertThat(scheme.getSurface()).isSameColorAs(0xff1c1b1e);
assertThat(scheme.getOnSurface()).isSameColorAs(0xffe6e1e6);
}
@Test
public void lightSchemeFromHighChromaColor() {
Scheme scheme = Scheme.light(0xfffa2bec);
assertThat(scheme.getPrimary()).isSameColorAs(0xffab00a2);
assertThat(scheme.getOnPrimary()).isSameColorAs(0xffffffff);
assertThat(scheme.getPrimaryContainer()).isSameColorAs(0xffffd7f3);
assertThat(scheme.getOnPrimaryContainer()).isSameColorAs(0xff390035);
assertThat(scheme.getSecondary()).isSameColorAs(0xff6e5868);
assertThat(scheme.getOnSecondary()).isSameColorAs(0xffffffff);
assertThat(scheme.getSecondaryContainer()).isSameColorAs(0xfff8daee);
assertThat(scheme.getOnSecondaryContainer()).isSameColorAs(0xff271624);
assertThat(scheme.getTertiary()).isSameColorAs(0xff815343);
assertThat(scheme.getOnTertiary()).isSameColorAs(0xffffffff);
assertThat(scheme.getTertiaryContainer()).isSameColorAs(0xffffdbd0);
assertThat(scheme.getOnTertiaryContainer()).isSameColorAs(0xff321207);
assertThat(scheme.getError()).isSameColorAs(0xffba1a1a);
assertThat(scheme.getOnError()).isSameColorAs(0xffffffff);
assertThat(scheme.getErrorContainer()).isSameColorAs(0xffffdad6);
assertThat(scheme.getOnErrorContainer()).isSameColorAs(0xff410002);
assertThat(scheme.getBackground()).isSameColorAs(0xfffffbff);
assertThat(scheme.getOnBackground()).isSameColorAs(0xff1f1a1d);
assertThat(scheme.getSurface()).isSameColorAs(0xfffffbff);
assertThat(scheme.getOnSurface()).isSameColorAs(0xff1f1a1d);
assertThat(scheme.getSurfaceVariant()).isSameColorAs(0xffeedee7);
assertThat(scheme.getOnSurfaceVariant()).isSameColorAs(0xff4e444b);
assertThat(scheme.getOutline()).isSameColorAs(0xff80747b);
assertThat(scheme.getOutlineVariant()).isSameColorAs(0xffd2c2cb);
assertThat(scheme.getShadow()).isSameColorAs(0xff000000);
assertThat(scheme.getScrim()).isSameColorAs(0xff000000);
assertThat(scheme.getInverseSurface()).isSameColorAs(0xff342f32);
assertThat(scheme.getInverseOnSurface()).isSameColorAs(0xfff8eef2);
assertThat(scheme.getInversePrimary()).isSameColorAs(0xffffabee);
}
@Test
public void darkSchemeFromHighChromaColor() {
Scheme scheme = Scheme.dark(0xfffa2bec);
assertThat(scheme.getPrimary()).isSameColorAs(0xffffabee);
assertThat(scheme.getOnPrimary()).isSameColorAs(0xff5c0057);
assertThat(scheme.getPrimaryContainer()).isSameColorAs(0xff83007b);
assertThat(scheme.getOnPrimaryContainer()).isSameColorAs(0xffffd7f3);
assertThat(scheme.getSecondary()).isSameColorAs(0xffdbbed1);
assertThat(scheme.getOnSecondary()).isSameColorAs(0xff3e2a39);
assertThat(scheme.getSecondaryContainer()).isSameColorAs(0xff554050);
assertThat(scheme.getOnSecondaryContainer()).isSameColorAs(0xfff8daee);
assertThat(scheme.getTertiary()).isSameColorAs(0xfff5b9a5);
assertThat(scheme.getOnTertiary()).isSameColorAs(0xff4c2619);
assertThat(scheme.getTertiaryContainer()).isSameColorAs(0xff663c2d);
assertThat(scheme.getOnTertiaryContainer()).isSameColorAs(0xffffdbd0);
assertThat(scheme.getError()).isSameColorAs(0xffffb4ab);
assertThat(scheme.getOnError()).isSameColorAs(0xff690005);
assertThat(scheme.getErrorContainer()).isSameColorAs(0xff93000a);
assertThat(scheme.getOnErrorContainer()).isSameColorAs(0xffffb4ab);
assertThat(scheme.getBackground()).isSameColorAs(0xff1f1a1d);
assertThat(scheme.getOnBackground()).isSameColorAs(0xffeae0e4);
assertThat(scheme.getSurface()).isSameColorAs(0xff1f1a1d);
assertThat(scheme.getOnSurface()).isSameColorAs(0xffeae0e4);
assertThat(scheme.getSurfaceVariant()).isSameColorAs(0xff4e444b);
assertThat(scheme.getOnSurfaceVariant()).isSameColorAs(0xffd2c2cb);
assertThat(scheme.getOutline()).isSameColorAs(0xff9a8d95);
assertThat(scheme.getOutlineVariant()).isSameColorAs(0xff4e444b);
assertThat(scheme.getShadow()).isSameColorAs(0xff000000);
assertThat(scheme.getScrim()).isSameColorAs(0xff000000);
assertThat(scheme.getInverseSurface()).isSameColorAs(0xffeae0e4);
assertThat(scheme.getInverseOnSurface()).isSameColorAs(0xff342f32);
assertThat(scheme.getInversePrimary()).isSameColorAs(0xffab00a2);
}
@Test
public void lightContentSchemeFromHighChromaColor() {
Scheme scheme = Scheme.lightContent(0xfffa2bec);
assertThat(scheme.getPrimary()).isSameColorAs(0xffab00a2);
assertThat(scheme.getOnPrimary()).isSameColorAs(0xffffffff);
assertThat(scheme.getPrimaryContainer()).isSameColorAs(0xffffd7f3);
assertThat(scheme.getOnPrimaryContainer()).isSameColorAs(0xff390035);
assertThat(scheme.getSecondary()).isSameColorAs(0xff7f4e75);
assertThat(scheme.getOnSecondary()).isSameColorAs(0xffffffff);
assertThat(scheme.getSecondaryContainer()).isSameColorAs(0xffffd7f3);
assertThat(scheme.getOnSecondaryContainer()).isSameColorAs(0xff330b2f);
assertThat(scheme.getTertiary()).isSameColorAs(0xff9c4323);
assertThat(scheme.getOnTertiary()).isSameColorAs(0xffffffff);
assertThat(scheme.getTertiaryContainer()).isSameColorAs(0xffffdbd0);
assertThat(scheme.getOnTertiaryContainer()).isSameColorAs(0xff390c00);
assertThat(scheme.getError()).isSameColorAs(0xffba1a1a);
assertThat(scheme.getOnError()).isSameColorAs(0xffffffff);
assertThat(scheme.getErrorContainer()).isSameColorAs(0xffffdad6);
assertThat(scheme.getOnErrorContainer()).isSameColorAs(0xff410002);
assertThat(scheme.getBackground()).isSameColorAs(0xfffffbff);
assertThat(scheme.getOnBackground()).isSameColorAs(0xff1f1a1d);
assertThat(scheme.getSurface()).isSameColorAs(0xfffffbff);
assertThat(scheme.getOnSurface()).isSameColorAs(0xff1f1a1d);
assertThat(scheme.getSurfaceVariant()).isSameColorAs(0xffeedee7);
assertThat(scheme.getOnSurfaceVariant()).isSameColorAs(0xff4e444b);
assertThat(scheme.getOutline()).isSameColorAs(0xff80747b);
assertThat(scheme.getOutlineVariant()).isSameColorAs(0xffd2c2cb);
assertThat(scheme.getShadow()).isSameColorAs(0xff000000);
assertThat(scheme.getScrim()).isSameColorAs(0xff000000);
assertThat(scheme.getInverseSurface()).isSameColorAs(0xff342f32);
assertThat(scheme.getInverseOnSurface()).isSameColorAs(0xfff8eef2);
assertThat(scheme.getInversePrimary()).isSameColorAs(0xffffabee);
}
@Test
public void darkContentSchemeFromHighChromaColor() {
Scheme scheme = Scheme.darkContent(0xfffa2bec);
assertThat(scheme.getPrimary()).isSameColorAs(0xffffabee);
assertThat(scheme.getOnPrimary()).isSameColorAs(0xff5c0057);
assertThat(scheme.getPrimaryContainer()).isSameColorAs(0xff83007b);
assertThat(scheme.getOnPrimaryContainer()).isSameColorAs(0xffffd7f3);
assertThat(scheme.getSecondary()).isSameColorAs(0xfff0b4e1);
assertThat(scheme.getOnSecondary()).isSameColorAs(0xff4b2145);
assertThat(scheme.getSecondaryContainer()).isSameColorAs(0xff64375c);
assertThat(scheme.getOnSecondaryContainer()).isSameColorAs(0xffffd7f3);
assertThat(scheme.getTertiary()).isSameColorAs(0xffffb59c);
assertThat(scheme.getOnTertiary()).isSameColorAs(0xff5c1900);
assertThat(scheme.getTertiaryContainer()).isSameColorAs(0xff7d2c0d);
assertThat(scheme.getOnTertiaryContainer()).isSameColorAs(0xffffdbd0);
assertThat(scheme.getError()).isSameColorAs(0xffffb4ab);
assertThat(scheme.getOnError()).isSameColorAs(0xff690005);
assertThat(scheme.getErrorContainer()).isSameColorAs(0xff93000a);
assertThat(scheme.getOnErrorContainer()).isSameColorAs(0xffffb4ab);
assertThat(scheme.getBackground()).isSameColorAs(0xff1f1a1d);
assertThat(scheme.getOnBackground()).isSameColorAs(0xffeae0e4);
assertThat(scheme.getSurface()).isSameColorAs(0xff1f1a1d);
assertThat(scheme.getOnSurface()).isSameColorAs(0xffeae0e4);
assertThat(scheme.getSurfaceVariant()).isSameColorAs(0xff4e444b);
assertThat(scheme.getOnSurfaceVariant()).isSameColorAs(0xffd2c2cb);
assertThat(scheme.getOutline()).isSameColorAs(0xff9a8d95);
assertThat(scheme.getOutlineVariant()).isSameColorAs(0xff4e444b);
assertThat(scheme.getShadow()).isSameColorAs(0xff000000);
assertThat(scheme.getScrim()).isSameColorAs(0xff000000);
assertThat(scheme.getInverseSurface()).isSameColorAs(0xffeae0e4);
assertThat(scheme.getInverseOnSurface()).isSameColorAs(0xff342f32);
assertThat(scheme.getInversePrimary()).isSameColorAs(0xffab00a2);
}
}

View File

@@ -1,362 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeTonalSpot;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeTonalSpotTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test
public void testKeyColors() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff6E72AC);
assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B);
assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff936B84);
assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff78767A);
assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777680);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff6a6fb1);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff545999);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff161a59);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff383c7c);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff5a5fa0);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff0e1253);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd6d6ff);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_minContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xff5f5e65);
}
@Test
public void lightTheme_standardContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xff1b1b21);
}
@Test
public void lightTheme_maxContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xff1a1a20);
}
@Test
public void lightTheme_minContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xffcfcfe7);
}
@Test
public void lightTheme_standardContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void lightTheme_maxContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xffababc3);
}
@Test
public void lightTheme_minContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xfff3c3df);
}
@Test
public void lightTheme_standardContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void lightTheme_maxContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xffcda0bb);
}
@Test
public void lightTheme_minContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffffc2bb);
}
@Test
public void lightTheme_standardContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void lightTheme_maxContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffff8d80);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff6a6fb1);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3c4180);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3c4180);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffc4c6ff);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffabaff7);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff2e3271);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffd5a8c3);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffffd8ee);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff4f2e44);
}
@Test
public void darkTheme_minContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xfffffbff);
}
@Test
public void darkTheme_standardContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xff2e2f42);
}
@Test
public void darkTheme_maxContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xff505165);
}
@Test
public void darkTheme_minContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xfffffbff);
}
@Test
public void darkTheme_standardContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xff46263b);
}
@Test
public void darkTheme_maxContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xff6b485f);
}
@Test
public void darkTheme_minContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xfffffbff);
}
@Test
public void darkTheme_standardContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xff690005);
}
@Test
public void darkTheme_maxContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffa80710);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131318);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131318);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131318);
}
@Test
public void darkTheme_minContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xffa4a2a9);
}
@Test
public void darkTheme_standardContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xffe4e1e9);
}
@Test
public void darkTheme_maxContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xffe5e2ea);
}
}

View File

@@ -1,217 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeVibrant;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeVibrantTest extends SysuiTestCase {
private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
@Test
public void testKeyColors() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff080CFF);
assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff7B7296);
assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff886C9D);
assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777682);
assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767685);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5660ff);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff343dff);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000181);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e3);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff3e47ff);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff00006e);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd6d6ff);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5660ff);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000ef);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000ef);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffc4c6ff);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffa9afff);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff0001c6);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffc9a9df);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xfff2daff);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff472e5b);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
}

View File

@@ -1,72 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.google.common.truth.Truth.assertThat;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.score.Score;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@SmallTest
@RunWith(JUnit4.class)
public final class ScoreTest extends SysuiTestCase {
@Test
public void score_picksMostChromatic() {
Map<Integer, Integer> colorsToPopulation = new HashMap<>();
colorsToPopulation.put(0xFF0000FF, 1);
colorsToPopulation.put(0xFFFF0000, 1);
colorsToPopulation.put(0xFF00FF00, 1);
List<Integer> scores = Score.score(colorsToPopulation);
assertThat(scores.get(0)).isEqualTo(0xffff0000);
assertThat(scores.get(1)).isEqualTo(0xff00ff00);
assertThat(scores.get(2)).isEqualTo(0xff0000ff);
}
@Test
public void score_usesGblueFallback() {
Map<Integer, Integer> colorsToPopulation = new HashMap<>();
colorsToPopulation.put(0xFF000000, 1);
List<Integer> scores = Score.score(colorsToPopulation);
assertThat(scores).containsExactly(0xff4285f4);
}
@Test
public void score_dedupesNearbyHues() {
Map<Integer, Integer> colorsToPopulation = new HashMap<>();
colorsToPopulation.put(0xff008772, 1);
colorsToPopulation.put(0xff318477, 1);
List<Integer> scores = Score.score(colorsToPopulation);
assertThat(scores).containsExactly(0xff008772);
}
}

View File

@@ -1,127 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import static org.junit.Assert.assertEquals;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.temperature.TemperatureCache;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.List;
@SmallTest
@RunWith(JUnit4.class)
public final class TemperatureCacheTest extends SysuiTestCase {
@Test
public void testRawTemperature() {
final Hct blueHct = Hct.fromInt(0xff0000ff);
final double blueTemp = TemperatureCache.rawTemperature(blueHct);
assertEquals(-1.393, blueTemp, 0.001);
final Hct redHct = Hct.fromInt(0xffff0000);
final double redTemp = TemperatureCache.rawTemperature(redHct);
assertEquals(2.351, redTemp, 0.001);
final Hct greenHct = Hct.fromInt(0xff00ff00);
final double greenTemp = TemperatureCache.rawTemperature(greenHct);
assertEquals(-0.267, greenTemp, 0.001);
final Hct whiteHct = Hct.fromInt(0xffffffff);
final double whiteTemp = TemperatureCache.rawTemperature(whiteHct);
assertEquals(-0.5, whiteTemp, 0.001);
final Hct blackHct = Hct.fromInt(0xff000000);
final double blackTemp = TemperatureCache.rawTemperature(blackHct);
assertEquals(-0.5, blackTemp, 0.001);
}
@Test
public void testComplement() {
final int blueComplement =
new TemperatureCache(Hct.fromInt(0xff0000ff)).getComplement().toInt();
assertThat(0xff9D0002).isSameColorAs(blueComplement);
final int redComplement = new TemperatureCache(
Hct.fromInt(0xffff0000)).getComplement().toInt();
assertThat(0xff007BFC).isSameColorAs(redComplement);
final int greenComplement =
new TemperatureCache(Hct.fromInt(0xff00ff00)).getComplement().toInt();
assertThat(0xffFFD2C9).isSameColorAs(greenComplement);
final int whiteComplement =
new TemperatureCache(Hct.fromInt(0xffffffff)).getComplement().toInt();
assertThat(0xffffffff).isSameColorAs(whiteComplement);
final int blackComplement =
new TemperatureCache(Hct.fromInt(0xff000000)).getComplement().toInt();
assertThat(0xff000000).isSameColorAs(blackComplement);
}
@Test
public void testAnalogous() {
final List<Hct> blueAnalogous =
new TemperatureCache(Hct.fromInt(0xff0000ff)).getAnalogousColors();
assertThat(0xff00590C).isSameColorAs(blueAnalogous.get(0).toInt());
assertThat(0xff00564E).isSameColorAs(blueAnalogous.get(1).toInt());
assertThat(0xff0000ff).isSameColorAs(blueAnalogous.get(2).toInt());
assertThat(0xff6700CC).isSameColorAs(blueAnalogous.get(3).toInt());
assertThat(0xff81009F).isSameColorAs(blueAnalogous.get(4).toInt());
final List<Hct> redAnalogous =
new TemperatureCache(Hct.fromInt(0xffff0000)).getAnalogousColors();
assertThat(0xffF60082).isSameColorAs(redAnalogous.get(0).toInt());
assertThat(0xffFC004C).isSameColorAs(redAnalogous.get(1).toInt());
assertThat(0xffff0000).isSameColorAs(redAnalogous.get(2).toInt());
assertThat(0xffD95500).isSameColorAs(redAnalogous.get(3).toInt());
assertThat(0xffAF7200).isSameColorAs(redAnalogous.get(4).toInt());
final List<Hct> greenAnalogous =
new TemperatureCache(Hct.fromInt(0xff00ff00)).getAnalogousColors();
assertThat(0xffCEE900).isSameColorAs(greenAnalogous.get(0).toInt());
assertThat(0xff92F500).isSameColorAs(greenAnalogous.get(1).toInt());
assertThat(0xff00ff00).isSameColorAs(greenAnalogous.get(2).toInt());
assertThat(0xff00FD6F).isSameColorAs(greenAnalogous.get(3).toInt());
assertThat(0xff00FAB3).isSameColorAs(greenAnalogous.get(4).toInt());
final List<Hct> blackAnalogous =
new TemperatureCache(Hct.fromInt(0xff000000)).getAnalogousColors();
assertThat(0xff000000).isSameColorAs(blackAnalogous.get(0).toInt());
assertThat(0xff000000).isSameColorAs(blackAnalogous.get(1).toInt());
assertThat(0xff000000).isSameColorAs(blackAnalogous.get(2).toInt());
assertThat(0xff000000).isSameColorAs(blackAnalogous.get(3).toInt());
assertThat(0xff000000).isSameColorAs(blackAnalogous.get(4).toInt());
final List<Hct> whiteAnalogous =
new TemperatureCache(Hct.fromInt(0xffffffff)).getAnalogousColors();
assertThat(0xffffffff).isSameColorAs(whiteAnalogous.get(0).toInt());
assertThat(0xffffffff).isSameColorAs(whiteAnalogous.get(1).toInt());
assertThat(0xffffffff).isSameColorAs(whiteAnalogous.get(2).toInt());
assertThat(0xffffffff).isSameColorAs(whiteAnalogous.get(3).toInt());
assertThat(0xffffffff).isSameColorAs(whiteAnalogous.get(4).toInt());
}
}

View File

@@ -1,59 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.monet.utils;
import static com.google.common.truth.Truth.assertAbout;
import com.google.common.truth.FailureMetadata;
import com.google.common.truth.Subject;
/** Enables assertions involving colors as integers to log as hex codes instead of raw integers. */
public final class ArgbSubject extends Subject {
public static ArgbSubject assertThat(int argb) {
return assertAbout(ArgbSubject::new).that(argb);
}
private final int actual;
private ArgbSubject(FailureMetadata failureMetadata, int subject) {
super(failureMetadata, subject);
this.actual = subject;
}
@Override
protected String actualCustomStringRepresentation() {
return userFriendlyHexCode(actual);
}
public void isSameColorAs(int otherArgb) {
if (otherArgb != actual) {
failWithActual("color", userFriendlyHexCode(otherArgb));
}
}
private static String userFriendlyHexCode(int integer) {
String hexString = Integer.toHexString(integer);
if (hexString.length() > 6) {
return String.format("#%s", hexString.substring(hexString.length() - 6));
} else if (hexString.length() == 6) {
return String.format("#%s", hexString);
} else {
return String.format("??? #%s", hexString);
}
}
}