summaryrefslogtreecommitdiff
path: root/tests/Internal/src
diff options
context:
space:
mode:
authorLucas Dupin <dupin@google.com>2017-07-26 20:29:38 -0700
committerLucas Dupin <dupin@google.com>2017-07-28 10:07:04 -0700
commit9324aa926a7fe74ed769525c3d93d4a55a378267 (patch)
treeac3eb11569430819fa4939593c15b1e06dbd5b14 /tests/Internal/src
parent48db7e6dcd78a9b5dda896ab022e4e4285af91b5 (diff)
Scrim opacity must satisfy GAR
Change-Id: Ic0a2423d73f0a3439a0dc4de8eb6e4719dbf36e1 Fixes: 63365056 Test: runtest -x tests/Internal/src/com/android/internal/graphics/ColorUtilsTest.java
Diffstat (limited to 'tests/Internal/src')
-rw-r--r--tests/Internal/src/com/android/internal/graphics/ColorUtilsTest.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/Internal/src/com/android/internal/graphics/ColorUtilsTest.java b/tests/Internal/src/com/android/internal/graphics/ColorUtilsTest.java
new file mode 100644
index 000000000000..73df9a09ea75
--- /dev/null
+++ b/tests/Internal/src/com/android/internal/graphics/ColorUtilsTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2017 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.internal.graphics;
+
+import android.graphics.Color;
+import android.support.test.filters.SmallTest;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+@SmallTest
+public class ColorUtilsTest {
+
+ @Test
+ public void calculateMinimumBackgroundAlpha_satisfiestContrast() {
+
+ int alpha = ColorUtils.calculateMinimumBackgroundAlpha(Color.WHITE, Color.BLACK, 4.5f);
+ assertTrue("Alpha doesn't need to be 255 to satisfy contrast", alpha < 255);
+
+ int worstCase = ColorUtils.blendARGB(Color.WHITE, Color.BLACK, alpha/255f);
+ worstCase = ColorUtils.setAlphaComponent(worstCase, 255);
+ double contrast = ColorUtils.calculateContrast(Color.WHITE, worstCase);
+ assertTrue("Blended color should satisfy contrast", contrast >= 4.5);
+
+ }
+}