/******************************************************************************* * Copyright (c) 2013 EclipseSource and others. * 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: * EclipseSource - initial API and implementation ******************************************************************************/ package org.eclipse.ui.forms.internal.widgets.togglehyperlinkkit; import static org.eclipse.rap.rwt.internal.protocol.ClientMessageConst.EVENT_DEFAULT_SELECTION; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import org.eclipse.rap.json.JsonObject; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Event; import org.eclipse.ui.forms.widgets.ToggleHyperlink; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @SuppressWarnings( "restriction" ) public class ToggleHyperlinkOperationHandler_Test { private ToggleHyperlink hyperlink; private ToggleHyperlinkOperationHandler handler; @Before public void setUp() { hyperlink = mock( ToggleHyperlink.class ); handler = new ToggleHyperlinkOperationHandler( hyperlink ); } @Test public void testHandleNotifyDefaultSelection() { JsonObject properties = new JsonObject().add( "altKey", true ).add( "shiftKey", true ); handler.handleNotify( EVENT_DEFAULT_SELECTION, properties ); ArgumentCaptor<Event> captor = ArgumentCaptor.forClass( Event.class ); verify( hyperlink ).notifyListeners( eq( SWT.DefaultSelection ), captor.capture() ); assertEquals( SWT.ALT | SWT.SHIFT, captor.getValue().stateMask ); } }