• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright (C) 2023 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 a
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
16from python.generators.diff_tests.testing import Path
17from python.generators.diff_tests.testing import Csv
18from python.generators.diff_tests.testing import DiffTestBlueprint
19from python.generators.diff_tests.testing import TestSuite
20
21
22class SurfaceFlingerLayers(TestSuite):
23
24  def test_snapshot_table(self):
25    return DiffTestBlueprint(
26        trace=Path('surfaceflinger_layers.textproto'),
27        query="""
28        SELECT
29          id, ts
30        FROM
31          surfaceflinger_layers_snapshot;
32        """,
33        out=Csv("""
34        "id","ts"
35        0,2748300281655
36        1,2749500341063
37        """))
38
39  def test_snapshot_args(self):
40    return DiffTestBlueprint(
41        trace=Path('surfaceflinger_layers.textproto'),
42        query="""
43        SELECT
44          args.key, args.display_value
45        FROM
46          surfaceflinger_layers_snapshot AS sfs JOIN args ON sfs.arg_set_id = args.arg_set_id
47        WHERE sfs.id = 0 and args.key != "hwc_blob"
48        ORDER BY args.key;
49        """,
50        out=Csv("""
51        "key","display_value"
52        "displays[0].id","4619827677550801152"
53        "displays[0].is_virtual","false"
54        "displays[0].layer_stack","0"
55        "displays[0].layer_stack_space_rect.bottom","2400"
56        "displays[0].layer_stack_space_rect.left","0"
57        "displays[0].layer_stack_space_rect.right","1080"
58        "displays[0].layer_stack_space_rect.top","0"
59        "displays[0].name","Common Panel"
60        "displays[0].size.h","2400"
61        "displays[0].size.w","1080"
62        "displays[0].transform.type","0"
63        "elapsed_realtime_nanos","2748300281655"
64        "vsync_id","24766"
65        "where","visibleRegionsDirty"
66        """))
67
68  def test_layer_table(self):
69    return DiffTestBlueprint(
70        trace=Path('surfaceflinger_layers.textproto'),
71        query="""
72        SELECT
73          id, snapshot_id
74        FROM
75          surfaceflinger_layer;
76        """,
77        out=Csv("""
78        "id","snapshot_id"
79        0,0
80        1,0
81        2,1
82        3,1
83        """))
84
85  def test_tables_have_raw_protos(self):
86    return DiffTestBlueprint(
87        trace=Path('surfaceflinger_layers.textproto'),
88        query="""
89        SELECT COUNT(*) FROM surfaceflinger_layers_snapshot
90        WHERE base64_proto_id IS NOT NULL
91        UNION ALL
92        SELECT COUNT(*) FROM surfaceflinger_layer
93        WHERE base64_proto_id IS NOT NULL
94        """,
95        out=Csv("""
96        "COUNT(*)"
97        2
98        4
99        """))
100