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, DataPath, Metric 17from python.generators.diff_tests.testing import Csv, Json, TextProto 18from python.generators.diff_tests.testing import DiffTestBlueprint 19from python.generators.diff_tests.testing import TestSuite 20 21 22class AndroidGames(TestSuite): 23 # Ensure Android game intervention list are parsed correctly 24 def test_game_intervention_list(self): 25 return DiffTestBlueprint( 26 trace=TextProto(r""" 27 packet { 28 android_game_intervention_list { 29 parse_error: false 30 read_error: false 31 game_packages { 32 name: "com.test.game1" 33 uid: 1001 34 current_mode: 1 35 game_mode_info { 36 mode: 1 37 use_angle: true 38 resolution_downscale: 1.0 39 fps: 0.0 40 } 41 game_mode_info { 42 mode: 2 43 use_angle: false 44 resolution_downscale: 1.0 45 fps: 60.0 46 } 47 game_mode_info { 48 mode: 3 49 use_angle: true 50 resolution_downscale: 0.75 51 fps: 120.0 52 } 53 } 54 game_packages { 55 name: "com.test.game2" 56 uid: 1002 57 current_mode: 3 58 game_mode_info { 59 mode: 1 60 use_angle: false 61 resolution_downscale: 1.0 62 fps: 0.0 63 } 64 game_mode_info { 65 mode: 3 66 use_angle: false 67 resolution_downscale: 0.95 68 fps: 45.0 69 } 70 } 71 } 72 } 73 """), 74 query=""" 75 SELECT 76 package_name, 77 uid, 78 current_mode, 79 standard_mode_supported, 80 standard_mode_downscale, 81 standard_mode_use_angle, 82 standard_mode_fps, 83 perf_mode_supported, 84 perf_mode_downscale, 85 perf_mode_use_angle, 86 perf_mode_fps, 87 battery_mode_supported, 88 battery_mode_downscale, 89 battery_mode_use_angle, 90 battery_mode_fps 91 FROM android_game_intervention_list 92 ORDER BY package_name; 93 """, 94 out=Path('game_intervention_list_test.out')) 95