summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Lucas Dupin <dupin@google.com> 2017-06-13 10:47:15 -0700
committer Lucas Dupin <dupin@google.com> 2017-06-14 10:00:38 -0700
commit1cd133a4d090b694f57dae3cbdda9cfe0600aef4 (patch)
tree68bf890e3cc9896a6956f6b7abbb74237432cd4a
parentc02e6c396e59287b44b86b0f6a83647d01921196 (diff)
Fixed flaky test
Change-Id: I88a39a8eb4fd6da6dc5b156aa475330299ffb9b9 Fixes: 62568528 Test: runtest systemui
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java b/packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java
index b6ffc98c97a6..7ed1e2c966d3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/colorextraction/SysuiColorExtractorTests.java
@@ -18,32 +18,35 @@ package com.android.systemui.colorextraction;
import static org.junit.Assert.assertEquals;
+import android.app.WallpaperColors;
import android.app.WallpaperManager;
import android.graphics.Color;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.util.Pair;
import com.android.systemui.SysuiTestCase;
import com.google.android.colorextraction.ColorExtractor;
import com.google.android.colorextraction.types.Tonal;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Tests color extraction generation.
*/
-@Ignore
@SmallTest
@RunWith(AndroidJUnit4.class)
public class SysuiColorExtractorTests extends SysuiTestCase {
- private static int[] sWhich = new int[] {
+ private static int[] sWhich = new int[]{
WallpaperManager.FLAG_SYSTEM,
WallpaperManager.FLAG_LOCK};
- private static int[] sTypes = new int[] {
+ private static int[] sTypes = new int[]{
ColorExtractor.TYPE_NORMAL,
ColorExtractor.TYPE_DARK,
ColorExtractor.TYPE_EXTRA_DARK};
@@ -55,6 +58,7 @@ public class SysuiColorExtractorTests extends SysuiTestCase {
fallbackColors.setSecondaryColor(ColorExtractor.FALLBACK_COLOR);
SysuiColorExtractor extractor = new SysuiColorExtractor(getContext(), new Tonal(), false);
+ simulateEvent(extractor);
extractor.setWallpaperVisible(false);
for (int which : sWhich) {
@@ -79,6 +83,7 @@ public class SysuiColorExtractorTests extends SysuiTestCase {
outGradientColorsExtraDark.set(colors);
return true;
}, false);
+ simulateEvent(extractor);
extractor.setWallpaperVisible(true);
for (int which : sWhich) {
@@ -88,4 +93,12 @@ public class SysuiColorExtractorTests extends SysuiTestCase {
}
}
}
-}
+
+ private void simulateEvent(SysuiColorExtractor extractor) {
+ // Let's fake a color event
+ List<Pair<Color, Integer>> dummyColors = new ArrayList<>();
+ dummyColors.add(new Pair<>(Color.valueOf(Color.BLACK), 1));
+ extractor.onColorsChanged(new WallpaperColors(dummyColors),
+ WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK);
+ }
+} \ No newline at end of file