summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2015-10-23 11:43:47 -0700
committerTony Wickham <twickham@google.com>2015-10-29 12:18:28 -0700
commita3c74d10a7d6e2ae8520e73176f939011e726ccf (patch)
treef3d76303f988a81182778a98876b2a23c96156c7 /tests
parentcbdb15389330aac3e4f5f404c20195ba13991dbb (diff)
downloadandroid_packages_apps_Trebuchet-a3c74d10a7d6e2ae8520e73176f939011e726ccf.tar.gz
android_packages_apps_Trebuchet-a3c74d10a7d6e2ae8520e73176f939011e726ccf.tar.bz2
android_packages_apps_Trebuchet-a3c74d10a7d6e2ae8520e73176f939011e726ccf.zip
Setting correct height for search bar widget options bundle.
- Seperate search bar height from its top and bottom paddings - Report this height plus 8dps top and bottom for the widget options - Use a separate bottom padding to adjust spacing between QSB and the workspace - Add tests to verify the height of the search bar in both normal and tall modes (ran on Nexus 6, 7, and 10) Change-Id: Ia7557785d1b38194eee869d0460456e8f33447d5
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/InvariantDeviceProfileTest.java75
1 files changed, 71 insertions, 4 deletions
diff --git a/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java b/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java
index a99ae4f95..db3f72f3a 100644
--- a/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java
+++ b/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java
@@ -15,15 +15,14 @@
*/
package com.android.launcher3;
+import android.content.res.Resources;
+import android.graphics.Point;
import android.graphics.PointF;
+import android.graphics.Rect;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
-import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.InvariantDeviceProfile;
-import com.android.launcher3.util.FocusLogic;
-
import java.util.ArrayList;
/**
@@ -123,4 +122,72 @@ public class InvariantDeviceProfileTest extends AndroidTestCase {
// Add more tests for other devices, however, running them once on a single device is enough
// for verifying that for a platform version, the WindowManager and DisplayMetrics is
// working as intended.
+
+ /**
+ * Make sure that the height for the QSB is what we expect in normal mode.
+ */
+ public void testQsbNormalHeight() {
+ Resources resources = getContext().getResources();
+ DeviceProfile landscapeProfile = mInvariantProfile.landscapeProfile;
+ DeviceProfile portraitProfile = mInvariantProfile.portraitProfile;
+ landscapeProfile.setSearchBarHeight(LauncherCallbacks.SEARCH_BAR_HEIGHT_NORMAL);
+ portraitProfile.setSearchBarHeight(LauncherCallbacks.SEARCH_BAR_HEIGHT_NORMAL);
+ Rect portraitBounds = portraitProfile.getSearchBarBounds(true); // RTL shouldn't matter.
+ int portraitHeight = (int) Utilities.dpiFromPx(portraitBounds.height(),
+ resources.getDisplayMetrics());
+ Rect landscapeBounds = landscapeProfile.getSearchBarBounds(true); // RTL shouldn't matter.
+ int landscapeHeight = (int) Utilities.dpiFromPx(landscapeBounds.height(),
+ resources.getDisplayMetrics());
+ if (portraitProfile.isTablet) {
+ assertEquals(8 + 48 + 24, portraitHeight);
+ } else {
+ assertEquals(8 + 48 + 12, portraitHeight);
+ }
+ // Make sure the height that we pass in the widget options bundle is the height of the
+ // search bar + 8dps padding top and bottom.
+ Point portraitDimens = portraitProfile.getSearchBarDimensForWidgetOpts(resources);
+ int portraitWidgetOptsHeight = portraitDimens.y;
+ Point landscapeDimens = landscapeProfile.getSearchBarDimensForWidgetOpts(resources);
+ int landscapeWidgetOptsHeight = landscapeDimens.y;
+ assertEquals(8 + 48 + 8, (int) Utilities.dpiFromPx(portraitWidgetOptsHeight,
+ resources.getDisplayMetrics()));
+ if (!landscapeProfile.isVerticalBarLayout()) {
+ assertEquals(portraitHeight, landscapeHeight);
+ assertEquals(portraitWidgetOptsHeight, landscapeWidgetOptsHeight);
+ }
+ }
+
+ /**
+ * Make sure that the height for the QSB is what we expect in tall mode.
+ */
+ public void testQsbTallHeight() {
+ Resources resources = getContext().getResources();
+ DeviceProfile landscapeProfile = mInvariantProfile.landscapeProfile;
+ DeviceProfile portraitProfile = mInvariantProfile.portraitProfile;
+ landscapeProfile.setSearchBarHeight(LauncherCallbacks.SEARCH_BAR_HEIGHT_TALL);
+ portraitProfile.setSearchBarHeight(LauncherCallbacks.SEARCH_BAR_HEIGHT_TALL);
+ Rect portraitBounds = portraitProfile.getSearchBarBounds(true); // RTL shouldn't matter.
+ int portraitHeight = (int) Utilities.dpiFromPx(portraitBounds.height(),
+ resources.getDisplayMetrics());
+ Rect landscapeBounds = landscapeProfile.getSearchBarBounds(true); // RTL shouldn't matter.
+ int landscapeHeight = (int) Utilities.dpiFromPx(landscapeBounds.height(),
+ resources.getDisplayMetrics());
+ if (portraitProfile.isTablet) {
+ assertEquals(8 + 80 + 24, portraitHeight);
+ } else {
+ assertEquals(8 + 80 + 2, portraitHeight);
+ }
+ // Make sure the height that we pass in the widget options bundle is the height of the
+ // search bar + 8dps padding top and bottom.
+ Point portraitDimens = portraitProfile.getSearchBarDimensForWidgetOpts(resources);
+ int portraitWidgetOptsHeight = portraitDimens.y;
+ Point landscapeDimens = landscapeProfile.getSearchBarDimensForWidgetOpts(resources);
+ int landscapeWidgetOptsHeight = landscapeDimens.y;
+ assertEquals(8 + 80 + 8, (int) Utilities.dpiFromPx(portraitWidgetOptsHeight,
+ resources.getDisplayMetrics()));
+ if (!landscapeProfile.isVerticalBarLayout()) {
+ assertEquals(portraitHeight, landscapeHeight);
+ assertEquals(portraitWidgetOptsHeight, landscapeWidgetOptsHeight);
+ }
+ }
}