Toast { private static android.widget.Toast createOrUpdateToastFromToastBean(android.widget.Toast toast, @NonNull ToastBean bean) { int duration; if (bean.mDuration == android.widget.Toast.LENGTH_SHORT) { duration = android.widget.Toast.LENGTH_SHORT; } else { duration = android.widget.Toast.LENGTH_LONG; } if (toast == null) { if (!TextUtils.isEmpty(bean.text)) { toast = android.widget.Toast.makeText(bean.mContext, bean.text, duration); bean.mView = toast.getView(); } else if (bean.resId != -1) { toast = android.widget.Toast.makeText(bean.mContext, bean.resId, duration); bean.mView = toast.getView(); } else { toast = new android.widget.Toast(bean.mContext); toast.setView(bean.mView); } } else { if (!TextUtils.isEmpty(bean.text)) { mToast.setText(bean.text); } else if (bean.resId != -1) { mToast.setText(bean.resId); } else if (bean.mView != null) { mToast.setView(bean.mView); } } toast.setGravity(bean.mGravity, bean.mX, bean.mY); toast.setMargin(bean.mHorizontalMargin, bean.mHorizontalMargin); return toast; }  static void onConfigurationChanged(Configuration newConfig); static void release(); static void cancel(); static void show(Context context, CharSequence text, @Duration int duration); static void show(Context context, @StringRes int resId, @Duration int duration); static void show(Context context, View view, @Duration int duration); static void show(@NonNull ToastBean portrait,@NonNull ToastBean landscape); static void show(@NonNull ToastBean bean); @Policy static int getPolicy(); static void setPolicy(@Policy int mPolicy); static final int ONE_FIRST; static final int ONE_LAST; static final int MANY_IN_ORDER; static final int LENGTH_SHORT; static final int LENGTH_LONG; }
@Test public void testCreateOrUpdateToastFromToastBean() throws Exception { mockStatic(Toast.class); PowerMockito.doReturn(null).when(Toast.class, "createOrUpdateToastFromToastBean", any(android.widget.Toast.class), any(Toast.ToastBean.class)); Method m = PowerMockito.method(Toast.class,"createOrUpdateToastFromToastBean",android.widget.Toast.class,Toast.ToastBean.class); m.setAccessible(true); m.invoke(null,null,null); m.setAccessible(false); PowerMockito.verifyPrivate(Toast.class).invoke("createOrUpdateToastFromToastBean",null,null); }