package com.codeaffine.eclipse.swt.widget.scrollable;

import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;

import org.junit.Before;
import org.junit.Test;

import com.codeaffine.eclipse.swt.widget.scrollable.context.ScrollableControl;

/**
 * Copyright (c) 2014 - 2016 Frank Appel
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Frank Appel - initial API and implementation
 */
public class ScrollableRedrawStateTest {

  private ScrollableRedrawState redrawState;
  private ScrollableControl<?> scrollable;

  @Before
  public void setUp() {
    scrollable = mock( ScrollableControl.class );
    redrawState = new ScrollableRedrawState( scrollable );
  }

  @Test
  public void updateWithRedrawSuspension() {
    redrawState.update( false );

    verify( scrollable ).setRedraw( false );
  }

  @Test
  public void updateWithRedrawSuspensionIfAlreadySuspended() {
    redrawState.update( false );
    reset( new ScrollableControl[] { scrollable } );

    redrawState.update( false );

    verify( scrollable, never() ).setRedraw( anyBoolean() );
  }

  @Test
  public void updateToResolveRedrawSuspension() {
    redrawState.update( false );
    reset( new ScrollableControl[] { scrollable } );

    redrawState.update( true );

    verify( scrollable ).setRedraw( true );
  }

  @Test
  public void updateToResolveRedrawSuspensionIfAlreadyResolved() {
    redrawState.update( false );
    redrawState.update( true );
    reset( new ScrollableControl[] { scrollable } );

    redrawState.update( true );

    verify( scrollable, never() ).setRedraw( anyBoolean() );
  }
}
@@ -1,8 +1,373 @@
+/**%0A * Copyright (c) 2014 - 2016 Frank Appel%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the Eclipse Public License v1.0%0A * which accompanies this distribution, and is available at%0A * http://www.eclipse.org/legal/epl-v10.html%0A *%0A * Contributors:%0A *   Frank Appel - initial API and implementation%0A */%0A
 package 
@@ -758,373 +758,8 @@
 l;%0A%0A
-/**%0A * Copyright (c) 2014 - 2016 Frank Appel%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the Eclipse Public License v1.0%0A * which accompanies this distribution, and is available at%0A * http://www.eclipse.org/legal/epl-v10.html%0A *%0A * Contributors:%0A *   Frank Appel - initial API and implementation%0A */%0A
 publ

Put license text at header position in ScrollableRedrawStateTest