@Test public void testOwnerGlobalKey() { final Component root = getMultipleChildrenComponent(); final int layoutSpecId = root.getTypeId(); final int nestedLayoutSpecId = layoutSpecId - 1; final int columnSpecId = Column.create(mContext).build().getTypeId(); final LithoView lithoView = getLithoView(root); final String rootGlobalKey = ComponentKeyUtils.getKeyWithSeparator(layoutSpecId); final String nestedLayoutGlobalKey = ComponentKeyUtils.getKeyWithSeparator(layoutSpecId, columnSpecId, nestedLayoutSpecId); // Text Assert.assertEquals(rootGlobalKey, getComponentAt(lithoView, 0).getOwnerGlobalKey()); // TestViewComponent in child layout Assert.assertEquals(nestedLayoutGlobalKey, getComponentAt(lithoView, 1).getOwnerGlobalKey()); // CardClip in child Assert.assertEquals(nestedLayoutGlobalKey, getComponentAt(lithoView, 3).getOwnerGlobalKey()); // Text in child Assert.assertEquals(nestedLayoutGlobalKey, getComponentAt(lithoView, 4).getOwnerGlobalKey()); // CardClip Assert.assertEquals(rootGlobalKey, getComponentAt(lithoView, 6).getOwnerGlobalKey()); // TestViewComponent Assert.assertEquals(rootGlobalKey, getComponentAt(lithoView, 7).getOwnerGlobalKey()); }
@Test public void testOwnerGlobalKey() { final Component root = getMultipleChildrenComponent(); final int layoutSpecId = root.getTypeId(); final int nestedLayoutSpecId = layoutSpecId - 1; final int columnSpecId = Column.create(mContext).build().getTypeId(); final LithoView lithoView = getLithoView(root); final String rootGlobalKey = ComponentKeyUtils.getKeyWithSeparator(layoutSpecId); final String nestedLayoutGlobalKey = ComponentKeyUtils.getKeyWithSeparator(layoutSpecId, columnSpecId, nestedLayoutSpecId); // Text Assert.assertEquals(rootGlobalKey, getComponentAt(lithoView, 0).getOwnerGlobalKey()); // TestViewComponent in child layout Assert.assertEquals(nestedLayoutGlobalKey, getComponentAt(lithoView, 1).getOwnerGlobalKey()); // CardClip in child Assert.assertEquals(nestedLayoutGlobalKey, getComponentAt(lithoView, 3).getOwnerGlobalKey()); // Text in child Assert.assertEquals(nestedLayoutGlobalKey, getComponentAt(lithoView, 4).getOwnerGlobalKey()); // CardClip Assert.assertEquals(rootGlobalKey, getComponentAt(lithoView, 6).getOwnerGlobalKey()); // TestViewComponent Assert.assertEquals(rootGlobalKey, getComponentAt(lithoView, 7).getOwnerGlobalKey()); }