1 /* <lambda>null2 * Copyright 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 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.input.screenshot 18 19 import android.content.Context 20 import android.hardware.input.KeyboardLayout 21 import android.os.LocaleList 22 import android.platform.test.flag.junit.SetFlagsRule 23 import com.android.hardware.input.Flags 24 import java.util.Locale 25 import org.junit.Rule 26 import org.junit.Test 27 import org.junit.rules.RuleChain 28 import org.junit.runner.RunWith 29 import org.junit.runners.Parameterized 30 import platform.test.screenshot.DeviceEmulationSpec 31 32 /** A screenshot test for Keyboard layout preview for JIS physical layout. */ 33 @RunWith(Parameterized::class) 34 class KeyboardLayoutPreviewJisScreenshotTest(emulationSpec: DeviceEmulationSpec) { 35 companion object { 36 @Parameterized.Parameters(name = "{0}") 37 @JvmStatic 38 fun getTestSpecs() = DeviceEmulationSpec.PhoneMinimal 39 } 40 41 val setFlagsRule = SetFlagsRule() 42 val screenshotRule = InputScreenshotTestRule( 43 emulationSpec, 44 "frameworks/base/tests/InputScreenshotTest/assets" 45 ) 46 47 @get:Rule 48 val ruleChain = RuleChain.outerRule(screenshotRule).around(setFlagsRule) 49 50 @Test 51 fun test() { 52 setFlagsRule.enableFlags(Flags.FLAG_KEYBOARD_LAYOUT_PREVIEW_FLAG) 53 screenshotRule.screenshotTest("layout-preview-jis") { 54 context: Context -> LayoutPreview.createLayoutPreview( 55 context, 56 KeyboardLayout( 57 "descriptor", 58 "layout", 59 /* collection= */null, 60 /* priority= */0, 61 LocaleList(Locale.JAPAN), 62 /* layoutType= */0, 63 /* vid= */0, 64 /* pid= */0 65 ) 66 ) 67 } 68 } 69 70 }