diff options
author | Maurice Lam <yukl@google.com> | 2015-05-21 10:39:27 -0700 |
---|---|---|
committer | Maurice Lam <yukl@google.com> | 2015-05-21 13:44:26 -0700 |
commit | 39619ac964ffe6b8737f2a128122bd3f84e75998 (patch) | |
tree | ce322432421baf602f9f3b6c27895177399a7807 | |
parent | bde9f28af53f6826c06e2afd8db5995f7f5ecff0 (diff) | |
download | setupwizard-39619ac964ffe6b8737f2a128122bd3f84e75998.tar.gz |
[SetupWizardLib] Fix illustration test
Fix illustration test by fixing the context's density to 3 px per dp.
Change-Id: I7ea296f5750d828f8254caa05011f4786c143d06
-rw-r--r-- | library/test/src/com/android/setupwizardlib/test/IllustrationTest.java | 9 |
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()); } } |