• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 com.android.wm.shell.common
18 
19 import android.content.res.Resources
20 import android.graphics.RectF
21 import android.util.DisplayMetrics
22 import android.view.DisplayInfo
23 import org.mockito.Mockito.spy
24 
25 /** Utility class for tests of [DesktopModeWindowDecorViewModel] */
26 object MultiDisplayTestUtil {
27     // We have two displays, display#1 is placed on middle top of display#0:
28     //   +---+
29     //   | 1 |
30     // +-+---+-+
31     // |   0   |
32     // +-------+
33     val DISPLAY_GLOBAL_BOUNDS_0 = RectF(0f, 0f, 1200f, 800f)
34     val DISPLAY_GLOBAL_BOUNDS_1 = RectF(100f, -1000f, 1100f, 0f)
35     val DISPLAY_DPI_0 = DisplayMetrics.DENSITY_DEFAULT
36     val DISPLAY_DPI_1 = DisplayMetrics.DENSITY_DEFAULT * 2
37 
createSpyDisplayLayoutnull38     fun createSpyDisplayLayout(globalBounds: RectF, dpi: Int, resources: Resources): DisplayLayout {
39         val displayInfo = DisplayInfo()
40         displayInfo.logicalDensityDpi = dpi
41         val displayLayout = spy(DisplayLayout(displayInfo, resources, true, true))
42         displayLayout.setGlobalBoundsDp(globalBounds)
43         return displayLayout
44     }
45 }
46