### Question:
TemplateLayout extends FrameLayout { @Override public void addView(View child, int index, ViewGroup.LayoutParams params) { container.addView(child, index, params); } TemplateLayout(Context context, int template, int containerId);  TemplateLayout(Context context, AttributeSet attrs); @TargetApi(VERSION_CODES.HONEYCOMB)  TemplateLayout(Context context, AttributeSet attrs, int defStyleAttr); @SuppressWarnings("TypeParameterUnusedInFormals") T findManagedViewById(int id); @SuppressWarnings("unchecked") M getMixin(Class<M> cls); @Override void addView(View child, int index, ViewGroup.LayoutParams params); @Keep @TargetApi(VERSION_CODES.HONEYCOMB) void setXFraction(float fraction); @Keep @TargetApi(VERSION_CODES.HONEYCOMB) float getXFraction();  }### Answer:
@Test public void testAddView() { TemplateLayout layout = new TemplateLayout(mContext, R.layout.test_template, R.id.suw_layout_content); TextView tv = new TextView(mContext); tv.setId(R.id.test_view_id); layout.addView(tv); View view = layout.findViewById(R.id.test_view_id); assertSame("The view added should be the same text view", tv, view); }
@Test public void testTemplate() { TemplateLayout layout = new TemplateLayout(mContext, R.layout.test_template, R.id.suw_layout_content); View templateView = layout.findViewById(R.id.test_template_view); assertNotNull("@id/test_template_view should exist in template", templateView); TextView tv = new TextView(mContext); tv.setId(R.id.test_view_id); layout.addView(tv); templateView = layout.findViewById(R.id.test_template_view); assertNotNull("@id/test_template_view should exist in template", templateView); View contentView = layout.findViewById(R.id.test_view_id); assertSame("The view added should be the same text view", tv, contentView); }