1 package com.xtremelabs.robolectric.tester.android.view; 2 3 import android.content.Context; 4 import android.content.res.Configuration; 5 import android.graphics.drawable.Drawable; 6 import android.net.Uri; 7 import android.os.Bundle; 8 import android.view.InputQueue; 9 import android.view.KeyEvent; 10 import android.view.LayoutInflater; 11 import android.view.MotionEvent; 12 import android.view.SurfaceHolder; 13 import android.view.View; 14 import android.view.ViewGroup; 15 import android.view.Window; 16 import android.view.WindowManager; 17 import com.xtremelabs.robolectric.Robolectric; 18 19 public class TestWindow extends Window { 20 public int flags; 21 public int requestedFeatureId; 22 public int featureDrawableResourceFeatureId; 23 public int featureDrawableResourceResId; 24 public int softInputMode; 25 private TestWindowManager windowManager; 26 TestWindow(Context context)27 public TestWindow(Context context) { 28 super(context); 29 windowManager = new TestWindowManager(); 30 } 31 requestFeature(int featureId)32 @Override public boolean requestFeature(int featureId) { 33 this.requestedFeatureId = featureId; 34 return true; 35 } 36 setFlags(int flags, int mask)37 @Override public void setFlags(int flags, int mask) { 38 this.flags = (flags & ~mask) | (flags & mask); 39 } 40 addFlags(int flags)41 @Override public void addFlags(int flags) { 42 setFlags(flags, flags); 43 } 44 45 @Override getWindowManager()46 public WindowManager getWindowManager() { 47 return windowManager; 48 } 49 isFloating()50 @Override public boolean isFloating() { 51 return false; 52 } 53 takeSurface(SurfaceHolder.Callback2 callback2)54 @Override public void takeSurface(SurfaceHolder.Callback2 callback2) { 55 } 56 takeInputQueue(InputQueue.Callback callback)57 @Override public void takeInputQueue(InputQueue.Callback callback) { 58 } 59 setContentView(int layoutResID)60 @Override public void setContentView(int layoutResID) { 61 } 62 setContentView(View view)63 @Override public void setContentView(View view) { 64 } 65 setContentView(View view, ViewGroup.LayoutParams params)66 @Override public void setContentView(View view, ViewGroup.LayoutParams params) { 67 } 68 addContentView(View view, ViewGroup.LayoutParams params)69 @Override public void addContentView(View view, ViewGroup.LayoutParams params) { 70 } 71 getCurrentFocus()72 @Override public View getCurrentFocus() { 73 return null; 74 } 75 getLayoutInflater()76 @Override public LayoutInflater getLayoutInflater() { 77 return null; 78 } 79 setTitle(CharSequence title)80 @Override public void setTitle(CharSequence title) { 81 } 82 setTitleColor(int textColor)83 @Override public void setTitleColor(int textColor) { 84 } 85 openPanel(int featureId, KeyEvent event)86 @Override public void openPanel(int featureId, KeyEvent event) { 87 } 88 closePanel(int featureId)89 @Override public void closePanel(int featureId) { 90 } 91 togglePanel(int featureId, KeyEvent event)92 @Override public void togglePanel(int featureId, KeyEvent event) { 93 } 94 performPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags)95 @Override public boolean performPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags) { 96 return false; 97 } 98 performPanelIdentifierAction(int featureId, int id, int flags)99 @Override public boolean performPanelIdentifierAction(int featureId, int id, int flags) { 100 return false; 101 } 102 closeAllPanels()103 @Override public void closeAllPanels() { 104 } 105 performContextMenuIdentifierAction(int id, int flags)106 @Override public boolean performContextMenuIdentifierAction(int id, int flags) { 107 return false; 108 } 109 onConfigurationChanged(Configuration newConfig)110 @Override public void onConfigurationChanged(Configuration newConfig) { 111 } 112 setBackgroundDrawable(Drawable drawable)113 @Override public void setBackgroundDrawable(Drawable drawable) { 114 } 115 setFeatureDrawableResource(int featureId, int resId)116 @Override public void setFeatureDrawableResource(int featureId, int resId) { 117 featureDrawableResourceFeatureId = featureId; 118 featureDrawableResourceResId = resId; 119 } 120 setFeatureDrawableUri(int featureId, Uri uri)121 @Override public void setFeatureDrawableUri(int featureId, Uri uri) { 122 } 123 setFeatureDrawable(int featureId, Drawable drawable)124 @Override public void setFeatureDrawable(int featureId, Drawable drawable) { 125 } 126 setFeatureDrawableAlpha(int featureId, int alpha)127 @Override public void setFeatureDrawableAlpha(int featureId, int alpha) { 128 } 129 setFeatureInt(int featureId, int value)130 @Override public void setFeatureInt(int featureId, int value) { 131 } 132 takeKeyEvents(boolean get)133 @Override public void takeKeyEvents(boolean get) { 134 } 135 superDispatchKeyEvent(KeyEvent event)136 @Override public boolean superDispatchKeyEvent(KeyEvent event) { 137 return false; 138 } 139 superDispatchTouchEvent(MotionEvent event)140 @Override public boolean superDispatchTouchEvent(MotionEvent event) { 141 return false; 142 } 143 superDispatchTrackballEvent(MotionEvent event)144 @Override public boolean superDispatchTrackballEvent(MotionEvent event) { 145 return false; 146 } 147 getDecorView()148 @Override public View getDecorView() { 149 return new View(Robolectric.application); 150 } 151 peekDecorView()152 @Override public View peekDecorView() { 153 return null; 154 } 155 saveHierarchyState()156 @Override public Bundle saveHierarchyState() { 157 return null; 158 } 159 restoreHierarchyState(Bundle savedInstanceState)160 @Override public void restoreHierarchyState(Bundle savedInstanceState) { 161 } 162 onActive()163 @Override protected void onActive() { 164 } 165 setChildDrawable(int featureId, Drawable drawable)166 @Override public void setChildDrawable(int featureId, Drawable drawable) { 167 } 168 setChildInt(int featureId, int value)169 @Override public void setChildInt(int featureId, int value) { 170 } 171 isShortcutKey(int keyCode, KeyEvent event)172 @Override public boolean isShortcutKey(int keyCode, KeyEvent event) { 173 return false; 174 } 175 setVolumeControlStream(int streamType)176 @Override public void setVolumeControlStream(int streamType) { 177 } 178 getVolumeControlStream()179 @Override public int getVolumeControlStream() { 180 return 0; 181 } 182 setSoftInputMode(int softInputMode)183 @Override public void setSoftInputMode(int softInputMode) { 184 this.softInputMode = softInputMode; 185 } 186 invalidatePanelMenu(int featureId)187 @Override public void invalidatePanelMenu(int featureId) { 188 } 189 superDispatchKeyShortcutEvent(KeyEvent event)190 @Override public boolean superDispatchKeyShortcutEvent(KeyEvent event) { 191 return false; 192 } 193 superDispatchGenericMotionEvent(MotionEvent event)194 @Override public boolean superDispatchGenericMotionEvent(MotionEvent event) { 195 return false; 196 } 197 } 198