1 package com.xtremelabs.robolectric.tester.android.view; 2 3 import com.xtremelabs.robolectric.Robolectric; 4 5 import android.app.Application; 6 import android.content.Intent; 7 import android.graphics.drawable.Drawable; 8 import android.view.*; 9 10 public class TestMenuItem implements MenuItem { 11 12 private int itemId; 13 private CharSequence title; 14 private boolean enabled = true; 15 private OnMenuItemClickListener menuItemClickListener; 16 public int iconRes; 17 private Intent intent; 18 private boolean visible = true; 19 private SubMenu subMenu; 20 TestMenuItem()21 public TestMenuItem() { 22 super(); 23 } 24 TestMenuItem(int itemId)25 public TestMenuItem(int itemId) { 26 super(); 27 this.itemId = itemId; 28 } 29 setItemId(int itemId)30 public void setItemId(int itemId) { 31 this.itemId = itemId; 32 } 33 34 @Override getItemId()35 public int getItemId() { 36 return itemId; 37 } 38 39 @Override getGroupId()40 public int getGroupId() { 41 return 0; 42 } 43 44 @Override getOrder()45 public int getOrder() { 46 return 0; 47 } 48 49 @Override setTitle(CharSequence title)50 public MenuItem setTitle(CharSequence title) { 51 this.title = title; 52 return this; 53 } 54 55 @Override setTitle(int title)56 public MenuItem setTitle(int title) { 57 return null; 58 } 59 60 @Override getTitle()61 public CharSequence getTitle() { 62 return title; 63 } 64 65 @Override setTitleCondensed(CharSequence title)66 public MenuItem setTitleCondensed(CharSequence title) { 67 return null; 68 } 69 70 @Override getTitleCondensed()71 public CharSequence getTitleCondensed() { 72 return null; 73 } 74 75 @Override setIcon(Drawable icon)76 public MenuItem setIcon(Drawable icon) { 77 return null; 78 } 79 80 @Override setIcon(int iconRes)81 public MenuItem setIcon(int iconRes) { 82 this.iconRes = iconRes; 83 return this; 84 } 85 86 @Override getIcon()87 public Drawable getIcon() { 88 return null; 89 } 90 91 @Override setIntent(Intent intent)92 public MenuItem setIntent(Intent intent) { 93 this.intent = intent; 94 return this; 95 } 96 97 @Override getIntent()98 public Intent getIntent() { 99 return this.intent; 100 } 101 102 @Override setShortcut(char numericChar, char alphaChar)103 public MenuItem setShortcut(char numericChar, char alphaChar) { 104 return null; 105 } 106 107 @Override setNumericShortcut(char numericChar)108 public MenuItem setNumericShortcut(char numericChar) { 109 return null; 110 } 111 112 @Override getNumericShortcut()113 public char getNumericShortcut() { 114 return 0; 115 } 116 117 @Override setAlphabeticShortcut(char alphaChar)118 public MenuItem setAlphabeticShortcut(char alphaChar) { 119 return null; 120 } 121 122 @Override getAlphabeticShortcut()123 public char getAlphabeticShortcut() { 124 return 0; 125 } 126 127 @Override setCheckable(boolean checkable)128 public MenuItem setCheckable(boolean checkable) { 129 return null; 130 } 131 132 @Override isCheckable()133 public boolean isCheckable() { 134 return false; 135 } 136 137 @Override setChecked(boolean checked)138 public MenuItem setChecked(boolean checked) { 139 return null; 140 } 141 142 @Override isChecked()143 public boolean isChecked() { 144 return false; 145 } 146 147 @Override setVisible(boolean visible)148 public MenuItem setVisible(boolean visible) { 149 this.visible = visible; 150 return this; 151 } 152 153 @Override isVisible()154 public boolean isVisible() { 155 return visible; 156 } 157 158 @Override setEnabled(boolean enabled)159 public MenuItem setEnabled(boolean enabled) { 160 this.enabled = enabled; 161 return this; 162 } 163 164 @Override isEnabled()165 public boolean isEnabled() { 166 return enabled; 167 } 168 169 @Override hasSubMenu()170 public boolean hasSubMenu() { 171 return subMenu != null; 172 } 173 174 @Override getSubMenu()175 public SubMenu getSubMenu() { 176 return subMenu; 177 } 178 setSubMenu(SubMenu subMenu)179 public void setSubMenu(SubMenu subMenu) { 180 this.subMenu = subMenu; 181 } 182 183 @Override setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener)184 public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) { 185 this.menuItemClickListener = menuItemClickListener; 186 return this; 187 } 188 189 @Override getMenuInfo()190 public ContextMenu.ContextMenuInfo getMenuInfo() { 191 return null; 192 } 193 click()194 public void click() { 195 if (enabled && menuItemClickListener != null) { 196 menuItemClickListener.onMenuItemClick(this); 197 } else if (enabled && intent != null) { 198 Robolectric.application.startActivity(intent); 199 } 200 } 201 202 @Override setShowAsAction(int actionEnum)203 public void setShowAsAction(int actionEnum) { 204 } 205 206 @Override setShowAsActionFlags(int actionEnum)207 public MenuItem setShowAsActionFlags(int actionEnum) { 208 return null; 209 } 210 211 @Override setActionView(View view)212 public MenuItem setActionView(View view) { 213 return null; 214 } 215 216 @Override setActionView(int resId)217 public MenuItem setActionView(int resId) { 218 return null; 219 } 220 221 @Override getActionView()222 public View getActionView() { 223 return null; 224 } 225 226 @Override setActionProvider(ActionProvider actionProvider)227 public MenuItem setActionProvider(ActionProvider actionProvider) { 228 return null; 229 } 230 231 @Override getActionProvider()232 public ActionProvider getActionProvider() { 233 return null; 234 } 235 236 @Override expandActionView()237 public boolean expandActionView() { 238 return false; 239 } 240 241 @Override collapseActionView()242 public boolean collapseActionView() { 243 return false; 244 } 245 246 @Override isActionViewExpanded()247 public boolean isActionViewExpanded() { 248 return false; 249 } 250 251 @Override setOnActionExpandListener(OnActionExpandListener listener)252 public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { 253 return null; 254 } 255 }