• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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.server.wm.flicker.service.processors
18 
19 import com.android.server.wm.flicker.readLayerTraceFromFile
20 import com.android.server.wm.flicker.readWmTraceFromFile
21 import com.android.server.wm.traces.common.service.processors.PipResizeProcessor
22 import com.google.common.truth.Truth
23 import org.junit.FixMethodOrder
24 import org.junit.Test
25 import org.junit.runners.MethodSorters
26 
27 /**
28  * Contains [PipResizeProcessor] tests. To run this test:
29  * `atest FlickerLibTest:PipResizeProcessorTest`
30  */
31 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
32 class PipResizeProcessorTest {
<lambda>null33     private val processor = PipResizeProcessor { }
34 
<lambda>null35     private val tagsPipResizingToExpand by lazy {
36         val wmTrace = readWmTraceFromFile(
37             "tagprocessors/pip/resize/expand/WindowManagerTrace.winscope"
38         )
39         val layersTrace = readLayerTraceFromFile(
40             "tagprocessors/pip/resize/expand/SurfaceFlingerTrace.winscope"
41         )
42         processor.generateTags(wmTrace, layersTrace)
43     }
44 
<lambda>null45     private val tagsPipResizingToShrink by lazy {
46         val wmTrace = readWmTraceFromFile(
47             "tagprocessors/pip/resize/shrink/WindowManagerTrace.winscope"
48         )
49         val layersTrace = readLayerTraceFromFile(
50             "tagprocessors/pip/resize/shrink/SurfaceFlingerTrace.winscope"
51         )
52         processor.generateTags(wmTrace, layersTrace)
53     }
54 
55     @Test
generatesPipResizeTagsOnExpandnull56     fun generatesPipResizeTagsOnExpand() {
57         val tagTrace = tagsPipResizingToExpand
58         Truth.assertWithMessage("Should have 2 pip resize tags")
59             .that(tagTrace)
60             .hasSize(2)
61         val startTagTimestamp = 175188084434996 // 2d0h39m48s84ms
62         val endTagTimestamp = 175188414547217 // 2d0h39m48s414ms
63         Truth.assertThat(tagTrace.first().timestamp).isEqualTo(startTagTimestamp)
64         Truth.assertThat(tagTrace.last().timestamp).isEqualTo(endTagTimestamp)
65     }
66 
67     @Test
generatesPipResizeTagsOnShrinknull68     fun generatesPipResizeTagsOnShrink() {
69         val tagTrace = tagsPipResizingToShrink
70         Truth.assertWithMessage("Should have 2 pip resize tags")
71             .that(tagTrace)
72             .hasSize(2)
73         val startTagTimestamp = 183718779433562 // 2d3h1m58s779ms
74         val endTagTimestamp = 183719115416407 // 2d3h1m59s115ms
75         Truth.assertThat(tagTrace.first().timestamp).isEqualTo(startTagTimestamp)
76         Truth.assertThat(tagTrace.last().timestamp).isEqualTo(endTagTimestamp)
77     }
78 }