Source:
protected com.android.ide.common.api.INode dragInto ( com.android.ide.common.api.IViewRule rule , com.android.ide.common.api.INode targetNode , com.android.ide.common.api.Rect dragBounds , com.android.ide.common.api.Point dropPoint , com.android.ide.common.api.Point secondDropPoint , int insertIndex , int currentIndex , java.lang.String ... graphicsFragments ) { java.lang.String draggedButtonId = ( currentIndex == ( - 1 ) ) ? "@+id/DraggedButton" : targetNode.getChildren ( ) [ currentIndex ] . getStringAttr ( com.android.ide.common.layout.LayoutConstants.ANDROID_URI , com.android.ide.common.layout.LayoutConstants.ATTR_ID ) ; com.android.ide.common.api.IDragElement [ ] elements = com.android.ide.common.layout.TestDragElement.create ( com.android.ide.common.layout.TestDragElement.create ( "android.widget.Button" , dragBounds ) . id ( draggedButtonId ) ) ; com.android.ide.common.api.DropFeedback feedback = rule.onDropEnter ( targetNode , null , elements ) ; assertNotNull ( feedback ) ; assertFalse ( feedback.invalidTarget ) ; assertNotNull ( feedback.painter ) ; if ( currentIndex != ( - 1 ) ) { feedback.sameCanvas = true ; } feedback = rule.onDropMove ( targetNode , elements , feedback , dropPoint ) ; assertNotNull ( feedback ) ; if ( secondDropPoint != null ) { feedback = rule.onDropMove ( targetNode , elements , feedback , secondDropPoint ) ; assertNotNull ( feedback ) ; } if ( insertIndex == ( - 1 ) ) { assertTrue ( feedback.invalidTarget ) ; } else { assertFalse ( feedback.invalidTarget ) ; } com.android.ide.common.layout.TestGraphics graphics = new com.android.ide.common.layout.TestGraphics ( ) ; assertNotNull ( feedback.painter ) ; feedback.painter.paint ( graphics , targetNode , feedback ) ; java.lang.String drawn = graphics.getDrawn ( ) . toString ( ) ; for ( java.lang.String fragment : graphicsFragments ) { if ( ! ( drawn.contains ( fragment ) ) ) { java.lang.System.out.println ( ( "Could not find: " + fragment ) ) ; java.lang.System.out.println ( ( "Full graphics output: " + drawn ) ) ; } assertTrue ( ( ( fragment + " not found; full=" ) + drawn ) , drawn.contains ( fragment ) ) ; } if ( insertIndex == ( - 1 ) ) { return null ; } int childrenCountBefore = targetNode.getChildren ( ) . length ; rule.onDropped ( targetNode , elements , feedback , dropPoint ) ; if ( currentIndex == ( - 1 ) ) { assertEquals ( ( childrenCountBefore + 1 ) , targetNode.getChildren ( ) . length ) ; } else { ( ( com.android.ide.common.layout.TestNode ) ( targetNode ) ) . removeChild ( currentIndex ) ; assertEquals ( childrenCountBefore , targetNode.getChildren ( ) . length ) ; } java.lang.String actualId = targetNode.getChildren ( ) [ insertIndex ] . getStringAttr ( com.android.ide.common.layout.LayoutConstants.ANDROID_URI , com.android.ide.common.layout.LayoutConstants.ATTR_ID ) ; if ( ! ( draggedButtonId.equals ( actualId ) ) ) { java.util.List < java.lang.String > childrenIds = new java.util.ArrayList < java.lang.String > ( ) ; for ( com.android.ide.common.api.INode child : targetNode.getChildren ( ) ) { childrenIds.add ( child.getStringAttr ( com.android.ide.common.layout.LayoutConstants.ANDROID_URI , com.android.ide.common.layout.LayoutConstants.ATTR_ID ) ) ; } int index = childrenIds.indexOf ( draggedButtonId ) ; java.lang.String message = ( ( ( ( "Button found at index " + index ) + " instead of " ) + insertIndex ) + " among " ) + childrenIds ; java.lang.System.out.println ( message ) ; assertEquals ( message , draggedButtonId , actualId ) ; } return targetNode.getChildren ( ) [ insertIndex ] ; }

Target:
protected com.android.ide.common.api.INode dragInto ( com.android.ide.common.api.IViewRule rule , com.android.ide.common.api.INode targetNode , com.android.ide.common.api.Rect dragBounds , com.android.ide.common.api.Point dropPoint , com.android.ide.common.api.Point secondDropPoint , int insertIndex , int currentIndex , java.lang.String ... graphicsFragments ) { java.lang.String draggedButtonId = ( currentIndex == ( - 1 ) ) ? "@+id/DraggedButton" : targetNode.getChildren ( ) [ currentIndex ] . getStringAttr ( com.android.util.XmlUtils.ANDROID_URI , com.android.ide.common.layout.LayoutConstants.ATTR_ID ) ; com.android.ide.common.api.IDragElement [ ] elements = com.android.ide.common.layout.TestDragElement.create ( com.android.ide.common.layout.TestDragElement.create ( "android.widget.Button" , dragBounds ) . id ( draggedButtonId ) ) ; com.android.ide.common.api.DropFeedback feedback = rule.onDropEnter ( targetNode , null , elements ) ; assertNotNull ( feedback ) ; assertFalse ( feedback.invalidTarget ) ; assertNotNull ( feedback.painter ) ; if ( currentIndex != ( - 1 ) ) { feedback.sameCanvas = true ; } feedback = rule.onDropMove ( targetNode , elements , feedback , dropPoint ) ; assertNotNull ( feedback ) ; if ( secondDropPoint != null ) { feedback = rule.onDropMove ( targetNode , elements , feedback , secondDropPoint ) ; assertNotNull ( feedback ) ; } if ( insertIndex == ( - 1 ) ) { assertTrue ( feedback.invalidTarget ) ; } else { assertFalse ( feedback.invalidTarget ) ; } com.android.ide.common.layout.TestGraphics graphics = new com.android.ide.common.layout.TestGraphics ( ) ; assertNotNull ( feedback.painter ) ; feedback.painter.paint ( graphics , targetNode , feedback ) ; java.lang.String drawn = graphics.getDrawn ( ) . toString ( ) ; for ( java.lang.String fragment : graphicsFragments ) { if ( ! ( drawn.contains ( fragment ) ) ) { java.lang.System.out.println ( ( "Could not find: " + fragment ) ) ; java.lang.System.out.println ( ( "Full graphics output: " + drawn ) ) ; } assertTrue ( ( ( fragment + " not found; full=" ) + drawn ) , drawn.contains ( fragment ) ) ; } if ( insertIndex == ( - 1 ) ) { return null ; } int childrenCountBefore = targetNode.getChildren ( ) . length ; rule.onDropped ( targetNode , elements , feedback , dropPoint ) ; if ( currentIndex == ( - 1 ) ) { assertEquals ( ( childrenCountBefore + 1 ) , targetNode.getChildren ( ) . length ) ; } else { ( ( com.android.ide.common.layout.TestNode ) ( targetNode ) ) . removeChild ( currentIndex ) ; assertEquals ( childrenCountBefore , targetNode.getChildren ( ) . length ) ; } java.lang.String actualId = targetNode.getChildren ( ) [ insertIndex ] . getStringAttr ( com.android.util.XmlUtils.ANDROID_URI , com.android.ide.common.layout.LayoutConstants.ATTR_ID ) ; if ( ! ( draggedButtonId.equals ( actualId ) ) ) { java.util.List < java.lang.String > childrenIds = new java.util.ArrayList < java.lang.String > ( ) ; for ( com.android.ide.common.api.INode child : targetNode.getChildren ( ) ) { childrenIds.add ( child.getStringAttr ( com.android.util.XmlUtils.ANDROID_URI , com.android.ide.common.layout.LayoutConstants.ATTR_ID ) ) ; } int index = childrenIds.indexOf ( draggedButtonId ) ; java.lang.String message = ( ( ( ( "Button found at index " + index ) + " instead of " ) + insertIndex ) + " among " ) + childrenIds ; java.lang.System.out.println ( message ) ; assertEquals ( message , draggedButtonId , actualId ) ; } return targetNode.getChildren ( ) [ insertIndex ] ; }