1 /*
2  * Copyright (C) 2016 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 android.widget.cts;
18 
19 import android.content.Context;
20 import android.util.AttributeSet;
21 import android.view.KeyEvent;
22 import android.widget.EditText;
23 import android.widget.ListPopupWindow;
24 
25 public class MockViewForListPopupWindow extends EditText {
26     private ListPopupWindow mListPopupWindow;
27 
MockViewForListPopupWindow(Context context, AttributeSet attrs)28     public MockViewForListPopupWindow(Context context, AttributeSet attrs) {
29         super(context, attrs);
30     }
31 
MockViewForListPopupWindow(Context context)32     public MockViewForListPopupWindow(Context context) {
33         super(context);
34     }
35 
wireTo(ListPopupWindow listPopupWindow)36     public void wireTo(ListPopupWindow listPopupWindow) {
37         mListPopupWindow = listPopupWindow;
38     }
39 
40     @Override
onKeyPreIme(int keyCode, KeyEvent event)41     public boolean onKeyPreIme(int keyCode, KeyEvent event) {
42         if (mListPopupWindow != null) {
43             return mListPopupWindow.onKeyPreIme(keyCode, event);
44         }
45         return super.onKeyPreIme(keyCode, event);
46     }
47 
48     @Override
onKeyDown(int keyCode, KeyEvent event)49     public boolean onKeyDown(int keyCode, KeyEvent event) {
50         if (mListPopupWindow != null) {
51             return mListPopupWindow.onKeyDown(keyCode, event);
52         }
53         return super.onKeyDown(keyCode, event);
54     }
55 
56     @Override
onKeyUp(int keyCode, KeyEvent event)57     public boolean onKeyUp(int keyCode, KeyEvent event) {
58         if (mListPopupWindow != null) {
59             return mListPopupWindow.onKeyUp(keyCode, event);
60         }
61         return super.onKeyUp(keyCode, event);
62     }
63 }
64 
65