### Question:
ViewHelper { public static boolean belongTo(@NonNull ViewGroup parent, @NonNull View child) { ViewParent viewParent = child.getParent(); if (viewParent instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) viewParent; return viewGroup.equals(parent) || belongTo(parent, viewGroup); } else { return false; } }  static boolean belongTo(@NonNull ViewGroup parent, @NonNull View child);  }### Answer:
@Test public void belongTo_positive1() { FrameLayout container = new FrameLayout(context); View view = new View(context); container.addView(view); boolean result = ViewHelper.belongTo(container, view); assertTrue(result); }
@Test public void belongTo_positive2() { FrameLayout container = new FrameLayout(context); FrameLayout viewContainer = new FrameLayout(context); View view = new View(context); viewContainer.addView(view); container.addView(viewContainer); boolean result = ViewHelper.belongTo(container, view); assertTrue(result); }
@Test public void belongTo_negative1() { FrameLayout container = new FrameLayout(context); View view = new View(context); boolean result = ViewHelper.belongTo(container, view); assertFalse(result); }
@Test public void belongTo_negative2() { FrameLayout container = new FrameLayout(context); FrameLayout viewContainer = new FrameLayout(context); View view = new View(context); viewContainer.addView(view); boolean result = ViewHelper.belongTo(container, view); assertFalse(result); }