TodoListController { public void observeItemHeight(View itemView) { itemView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { emitItemHeightIfNot(itemView); itemView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); } TodoListController(@NonNull Context context, @NonNull List<TodoItemViewModel> items,
                              @NonNull EventBus eventBus); void setItems(List<TodoItemViewModel> items); void bindFooterAction(TodoFooterViewHolder holder); void bindItemAction(TodoItemViewHolder viewHolder, TodoItemViewModel viewModel); void observeItemHeight(View itemView); void resetState();  }
@Test public void testObserveHeightExist() throws Exception { mTodoListController.observeItemHeight(mFooterView); assertEquals(1010, mFooterView.getLayoutParams().height); }
@Test public void testObserveHeightExistOnlyFirstTime() throws Exception { mTodoListController.observeItemHeight(mFooterView); when(mFooterView.getHeight()).thenReturn(100); mTodoListController.observeItemHeight(mFooterView); assertEquals(1010, mFooterView.getLayoutParams().height); }
@Test public void testObserveItemHeight() throws Exception { mTodoListController.observeItemHeight(mockFooterView()); }