1#!/usr/bin/env python3 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 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 InputMethodClients(TestSuite): 23 24 def test_has_expected_rows(self): 25 return DiffTestBlueprint( 26 trace=Path('inputmethod_clients.textproto'), 27 query=""" 28 INCLUDE PERFETTO MODULE android.winscope.inputmethod; 29 SELECT 30 id, ts 31 FROM 32 android_inputmethod_clients; 33 """, 34 out=Csv(""" 35 "id","ts" 36 0,119232512509 37 1,119237883196 38 """)) 39 40 def test_has_expected_args(self): 41 return DiffTestBlueprint( 42 trace=Path('inputmethod_clients.textproto'), 43 query=""" 44 INCLUDE PERFETTO MODULE android.winscope.inputmethod; 45 SELECT 46 args.key, args.display_value 47 FROM 48 android_inputmethod_clients AS imc JOIN args ON imc.arg_set_id = args.arg_set_id 49 WHERE imc.id = 0 50 ORDER BY args.key 51 LIMIT 10; 52 """, 53 out=Csv(""" 54 "key","display_value" 55 "client.editor_info.field_id","2131362278" 56 "client.editor_info.ime_options","33554435" 57 "client.editor_info.input_type","1" 58 "client.editor_info.package_name","com.google.android.apps.nexuslauncher" 59 "client.editor_info.private_ime_options","com.google.android.inputmethod.latin.appSupportsSmartComposeAndDel,com.google.android.inputmethod.latin.canary.appSupportsSmartComposeAndDel,com.google.android.inputmethod.latin.dev.appSupportsSmartComposeAndDel" 60 "client.ime_focus_controller.has_ime_focus","true" 61 "client.ime_insets_source_consumer.insets_source_consumer.has_window_focus","true" 62 "client.ime_insets_source_consumer.insets_source_consumer.is_requested_visible","true" 63 "client.ime_insets_source_consumer.insets_source_consumer.source_control.leash.hash_code","135479902" 64 "client.ime_insets_source_consumer.insets_source_consumer.source_control.leash.layerId","105" 65 """)) 66 67 def test_table_has_raw_protos(self): 68 return DiffTestBlueprint( 69 trace=Path('inputmethod_clients.textproto'), 70 query=""" 71 INCLUDE PERFETTO MODULE android.winscope.inputmethod; 72 SELECT COUNT(*) FROM __intrinsic_inputmethod_clients 73 WHERE base64_proto_id IS NOT NULL 74 """, 75 out=Csv(""" 76 "COUNT(*)" 77 2 78 """)) 79