1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.server.wm; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import android.graphics.Rect; 22 import android.platform.test.annotations.Presubmit; 23 import android.view.WindowInsets; 24 import android.view.WindowMetrics; 25 26 import androidx.test.filters.SmallTest; 27 28 import com.android.compatibility.common.util.ApiTest; 29 30 import org.junit.Test; 31 32 /** 33 * Tests for {@link android.view.WindowMetrics} constructor 34 * 35 * Build/Install/Run: 36 * atest CtsWindowManagerDeviceTestCases:WindowMetricsTest 37 */ 38 @SmallTest 39 @Presubmit 40 @ApiTest(apis = "android.view.WindowMetrics") 41 public class WindowMetricsTest { 42 43 @Test testConstructor()44 public void testConstructor() { 45 final Rect bounds = new Rect(0, 0, 1000, 1000); 46 final WindowInsets windowInsets = WindowInsets.CONSUMED; 47 final float density = 1.0f; 48 final WindowMetrics windowMetrics = new WindowMetrics(bounds, windowInsets, density); 49 50 assertThat(windowMetrics.getBounds()).isEqualTo(bounds); 51 assertThat(windowMetrics.getWindowInsets()).isEqualTo(windowInsets); 52 assertThat(windowMetrics.getDensity()).isEqualTo(density); 53 } 54 } 55