/******************************************************************************* * Copyright (c) 2010 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.swt.internal.widgets.coolitemkit; import junit.framework.TestCase; import org.eclipse.rwt.Fixture; import org.eclipse.rwt.lifecycle.*; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.internal.widgets.Props; import org.eclipse.swt.widgets.*; public class CoolItemLCA_Test extends TestCase { public void testPreserveValues() { Display display = new Display(); Shell shell = new Shell( display, SWT.NONE ); CoolBar bar = new CoolBar( shell, SWT.FLAT ); CoolItem item = new CoolItem( bar, SWT.NONE ); Button button = new Button( bar, SWT.NONE ); Fixture.markInitialized( item ); item.setControl( button ); item.setSize( 30, 20 ); Rectangle rectangle = new Rectangle( 0, 0, item.getSize().x, item.getSize().y ); AbstractWidgetLCA lca = WidgetUtil.getLCA( item ); lca.preserveValues( item ); IWidgetAdapter adapter = WidgetUtil.getAdapter( item ); assertEquals( button, adapter.getPreserved( CoolItemLCA.PROP_CONTROL ) ); assertEquals( rectangle, adapter.getPreserved( Props.BOUNDS ) ); item.setControl( null ); lca.preserveValues( item ); assertNull( adapter.getPreserved( CoolItemLCA.PROP_CONTROL ) ); Fixture.clearPreserved(); display.dispose(); } protected void setUp() throws Exception { Fixture.setUp(); } protected void tearDown() throws Exception { Fixture.tearDown(); } }