summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2015-05-21 21:19:30 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-21 21:19:31 +0000
commitb5c78954c32ef124b5df7ab539d6579cb4506f50 (patch)
tree6df4d2cd7b50fc0b3440bcde4d5f7d60d6c874ee
parent173c7bc879c47660f943f2a3cd67ed440f55d3d3 (diff)
parent39619ac964ffe6b8737f2a128122bd3f84e75998 (diff)
downloadsetupwizard-b5c78954c32ef124b5df7ab539d6579cb4506f50.tar.gz
Merge "[SetupWizardLib] Fix illustration test" into ub-setupwizard-alatar
-rw-r--r--library/test/src/com/android/setupwizardlib/test/IllustrationTest.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/library/test/src/com/android/setupwizardlib/test/IllustrationTest.java b/library/test/src/com/android/setupwizardlib/test/IllustrationTest.java
index 43231bd..709e89d 100644
--- a/library/test/src/com/android/setupwizardlib/test/IllustrationTest.java
+++ b/library/test/src/com/android/setupwizardlib/test/IllustrationTest.java
@@ -16,6 +16,7 @@
package com.android.setupwizardlib.test;
+import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -35,7 +36,11 @@ public class IllustrationTest extends AndroidTestCase {
@SmallTest
public void testAspectRatio() {
- final Illustration illustration = new Illustration(getContext());
+ final Context context = getContext();
+ // Force the context to be xhdpi
+ context.getResources().getDisplayMetrics().density = 2.0f;
+
+ final Illustration illustration = new Illustration(context);
illustration.setAspectRatio(3.0f);
final Drawable backgroundDrawable = new ColorDrawable(Color.RED);
final Drawable illustrationDrawable = new ColorDrawable(Color.BLUE);
@@ -44,7 +49,7 @@ public class IllustrationTest extends AndroidTestCase {
illustration.measure(View.MeasureSpec.makeMeasureSpec(300, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
- // (300 / 3) round down to nearest mod 8 = 96
+ // (300px / 3) round down to nearest mod (8dp = 16px) = 96px
assertEquals("Top padding should be 96", 96, illustration.getPaddingTop());
}
}