summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Chen <charlesccchen@google.com>2020-02-13 16:41:32 +0800
committerCharles Chen <charlesccchen@google.com>2020-05-04 11:41:13 +0800
commit49f329ca66e3cf06a8c6086b77333c68fef5cf5b (patch)
treee0f253b3b905055bd548bd8490669f667113f990 /tests
parentd827ec8bbd33aec9435575ce55776766e746cdf9 (diff)
Add WindowMetricsHelper
This metrics now is used for calculating the value reported by Display#getSize. It could be extended to have more function later. Also replace getCurrentMetrics usages to make them report Display#getSize value. Bug: 148904274 Test: atest WindowMetricsHelperTest Change-Id: I182b6e63f7c28752eee22839cb9e69f073046c3f
Diffstat (limited to 'tests')
-rw-r--r--tests/GamePerformance/src/android/gameperformance/CustomControlView.java18
-rw-r--r--tests/MirrorSurfaceTest/src/com/google/android/test/mirrorsurface/MirrorSurfaceActivity.java4
-rw-r--r--tests/utils/testutils/java/com/android/server/wm/test/filters/FrameworksTestsFilter.java3
3 files changed, 15 insertions, 10 deletions
diff --git a/tests/GamePerformance/src/android/gameperformance/CustomControlView.java b/tests/GamePerformance/src/android/gameperformance/CustomControlView.java
index e63736b9ee61..8d11a416c8a8 100644
--- a/tests/GamePerformance/src/android/gameperformance/CustomControlView.java
+++ b/tests/GamePerformance/src/android/gameperformance/CustomControlView.java
@@ -15,20 +15,21 @@
*/
package android.gameperformance;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
import android.annotation.MainThread;
import android.annotation.NonNull;
import android.annotation.WorkerThread;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
-import android.graphics.Point;
import android.graphics.drawable.AnimationDrawable;
+import android.view.WindowManager;
import android.widget.AbsoluteLayout;
import android.widget.ImageView;
+import android.window.WindowMetricsHelper;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
/**
* View that holds requested number of UI controls as ImageView with an infinite animation.
@@ -42,9 +43,10 @@ public class CustomControlView extends AbsoluteLayout {
public CustomControlView(@NonNull Context context) {
super(context);
- final Point size = new Point();
- context.getDisplay().getSize(size);
- mPerRowControlCount = size.x / CONTROL_DIMENSION;
+ final WindowManager wm = context.getSystemService(WindowManager.class);
+ final int width = WindowMetricsHelper.getBoundsExcludingNavigationBarAndCutout(
+ wm.getCurrentWindowMetrics()).width();
+ mPerRowControlCount = width / CONTROL_DIMENSION;
}
/**
diff --git a/tests/MirrorSurfaceTest/src/com/google/android/test/mirrorsurface/MirrorSurfaceActivity.java b/tests/MirrorSurfaceTest/src/com/google/android/test/mirrorsurface/MirrorSurfaceActivity.java
index 31532a226800..8afe8411a790 100644
--- a/tests/MirrorSurfaceTest/src/com/google/android/test/mirrorsurface/MirrorSurfaceActivity.java
+++ b/tests/MirrorSurfaceTest/src/com/google/android/test/mirrorsurface/MirrorSurfaceActivity.java
@@ -39,6 +39,7 @@ import android.view.WindowManagerGlobal;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
+import android.window.WindowMetricsHelper;
public class MirrorSurfaceActivity extends Activity implements View.OnClickListener,
View.OnLongClickListener, View.OnTouchListener {
@@ -89,7 +90,8 @@ public class MirrorSurfaceActivity extends Activity implements View.OnClickListe
.getSystemService(WindowManager.class);
mIWm = WindowManagerGlobal.getWindowManagerService();
- Rect windowBounds = mWm.getCurrentWindowMetrics().getBounds();
+ Rect windowBounds = WindowMetricsHelper.getBoundsExcludingNavigationBarAndCutout(
+ mWm.getCurrentWindowMetrics());
mWindowBounds.set(0, 0, windowBounds.width(), windowBounds.height());
mScaleText = findViewById(R.id.scale);
diff --git a/tests/utils/testutils/java/com/android/server/wm/test/filters/FrameworksTestsFilter.java b/tests/utils/testutils/java/com/android/server/wm/test/filters/FrameworksTestsFilter.java
index 0dd45bad8a01..ea803f2aba8b 100644
--- a/tests/utils/testutils/java/com/android/server/wm/test/filters/FrameworksTestsFilter.java
+++ b/tests/utils/testutils/java/com/android/server/wm/test/filters/FrameworksTestsFilter.java
@@ -48,7 +48,8 @@ public final class FrameworksTestsFilter extends SelectTest {
"android.view.InsetsStateTest",
"android.view.WindowMetricsTest",
"android.view.PendingInsetsControllerTest",
- "android.app.WindowContextTest"
+ "android.app.WindowContextTest",
+ "android.window.WindowMetricsHelperTest"
};
public FrameworksTestsFilter(Bundle testArgs) {