|
| 1 | +/* |
| 2 | + * Copyright (C) 2020 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; |
| 18 | + |
| 19 | +import static android.view.InsetsState.ITYPE_IME; |
| 20 | +import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; |
| 21 | + |
| 22 | +import static org.junit.Assert.assertTrue; |
| 23 | + |
| 24 | +import android.graphics.PixelFormat; |
| 25 | +import android.platform.test.annotations.Presubmit; |
| 26 | +import android.view.InsetsSource; |
| 27 | + |
| 28 | +import androidx.test.filters.SmallTest; |
| 29 | + |
| 30 | +import org.junit.Before; |
| 31 | +import org.junit.Test; |
| 32 | +import org.junit.runner.RunWith; |
| 33 | + |
| 34 | +@SmallTest |
| 35 | +@Presubmit |
| 36 | +@RunWith(WindowTestRunner.class) |
| 37 | +public class ImeInsetsSourceProviderTest extends WindowTestsBase { |
| 38 | + |
| 39 | + private InsetsSource mImeSource = new InsetsSource(ITYPE_IME); |
| 40 | + private ImeInsetsSourceProvider mImeProvider; |
| 41 | + |
| 42 | + @Before |
| 43 | + public void setUp() throws Exception { |
| 44 | + mImeSource.setVisible(true); |
| 45 | + mImeProvider = new ImeInsetsSourceProvider(mImeSource, |
| 46 | + mDisplayContent.getInsetsStateController(), mDisplayContent); |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + public void testTransparentControlTargetWindowCanShowIme() { |
| 51 | + final WindowState appWin = createWindow(null, TYPE_APPLICATION, "app"); |
| 52 | + final WindowState popup = createWindow(appWin, TYPE_APPLICATION, "popup"); |
| 53 | + mDisplayContent.mInputMethodControlTarget = popup; |
| 54 | + mDisplayContent.mInputMethodTarget = appWin; |
| 55 | + popup.mAttrs.format = PixelFormat.TRANSPARENT; |
| 56 | + mImeProvider.scheduleShowImePostLayout(appWin); |
| 57 | + assertTrue(mImeProvider.isImeTargetFromDisplayContentAndImeSame()); |
| 58 | + } |
| 59 | +} |
0 commit comments