|  | @@ -29,6 +29,7 @@ import org.mockito.ArgumentCaptor;
 | 
	
		
			
			| 29 | 29 |  import org.mockito.Mockito;
 | 
	
		
			
			| 30 | 30 |  
 | 
	
		
			
			| 31 | 31 |  import static org.assertj.core.api.Java6Assertions.assertThat;
 | 
	
		
			
			|  | 32 | +import static org.mockito.ArgumentMatchers.any;
 | 
	
		
			
			| 32 | 33 |  import static org.mockito.ArgumentMatchers.eq;
 | 
	
		
			
			| 33 | 34 |  import static org.mockito.Mockito.mock;
 | 
	
		
			
			| 34 | 35 |  import static org.mockito.Mockito.spy;
 | 
	
	
		
			
			|  | @@ -338,11 +339,51 @@ public class StackControllerTest extends BaseTest {
 | 
	
		
			
			| 338 | 339 |          });
 | 
	
		
			
			| 339 | 340 |      }
 | 
	
		
			
			| 340 | 341 |  
 | 
	
		
			
			|  | 342 | +    @Test
 | 
	
		
			
			|  | 343 | +    public void popToRoot_onlyTopChildIsAnimated() {
 | 
	
		
			
			|  | 344 | +        child1.options.animated = new Bool(false);
 | 
	
		
			
			|  | 345 | +        child2.options.animated = new Bool(false);
 | 
	
		
			
			|  | 346 | +        child3.options.animated = new Bool(false);
 | 
	
		
			
			|  | 347 | +
 | 
	
		
			
			|  | 348 | +        uut.push(child1, new CommandListenerAdapter());
 | 
	
		
			
			|  | 349 | +        uut.push(child2, new CommandListenerAdapter());
 | 
	
		
			
			|  | 350 | +        uut.push(child3, new CommandListenerAdapter());
 | 
	
		
			
			|  | 351 | +
 | 
	
		
			
			|  | 352 | +        uut.popToRoot(new CommandListenerAdapter() {
 | 
	
		
			
			|  | 353 | +            @Override
 | 
	
		
			
			|  | 354 | +            public void onSuccess(String childId) {
 | 
	
		
			
			|  | 355 | +                verify(animator, times(1)).animatePop(eq(child3.getView()), any());
 | 
	
		
			
			|  | 356 | +            }
 | 
	
		
			
			|  | 357 | +        });
 | 
	
		
			
			|  | 358 | +    }
 | 
	
		
			
			|  | 359 | +
 | 
	
		
			
			|  | 360 | +    @Test
 | 
	
		
			
			|  | 361 | +    public void popToRoot_topChildrenAreDestroyed() {
 | 
	
		
			
			|  | 362 | +        child1.options.animated = new Bool(false);
 | 
	
		
			
			|  | 363 | +        child2.options.animated = new Bool(false);
 | 
	
		
			
			|  | 364 | +        child3.options.animated = new Bool(false);
 | 
	
		
			
			|  | 365 | +
 | 
	
		
			
			|  | 366 | +        uut.push(child1, new CommandListenerAdapter());
 | 
	
		
			
			|  | 367 | +        uut.push(child2, new CommandListenerAdapter());
 | 
	
		
			
			|  | 368 | +        uut.push(child3, new CommandListenerAdapter());
 | 
	
		
			
			|  | 369 | +
 | 
	
		
			
			|  | 370 | +        uut.popToRoot(new CommandListenerAdapter() {
 | 
	
		
			
			|  | 371 | +            @Override
 | 
	
		
			
			|  | 372 | +            public void onSuccess(String childId) {
 | 
	
		
			
			|  | 373 | +                verify(child1, times(0)).destroy();
 | 
	
		
			
			|  | 374 | +                verify(child2, times(1)).destroy();
 | 
	
		
			
			|  | 375 | +                verify(child3, times(1)).destroy();
 | 
	
		
			
			|  | 376 | +            }
 | 
	
		
			
			|  | 377 | +        });
 | 
	
		
			
			|  | 378 | +    }
 | 
	
		
			
			|  | 379 | +
 | 
	
		
			
			| 341 | 380 |      @Test
 | 
	
		
			
			| 342 | 381 |      public void popToRoot_EmptyStackDoesNothing() {
 | 
	
		
			
			| 343 | 382 |          assertThat(uut.isEmpty()).isTrue();
 | 
	
		
			
			| 344 |  | -        uut.popToRoot(new CommandListenerAdapter());
 | 
	
		
			
			|  | 383 | +        CommandListenerAdapter listener = spy(new CommandListenerAdapter());
 | 
	
		
			
			|  | 384 | +        uut.popToRoot(listener);
 | 
	
		
			
			| 345 | 385 |          assertThat(uut.isEmpty()).isTrue();
 | 
	
		
			
			|  | 386 | +        verify(listener, times(1)).onError(any());
 | 
	
		
			
			| 346 | 387 |      }
 | 
	
		
			
			| 347 | 388 |  
 | 
	
		
			
			| 348 | 389 |      @Test
 |