
package org.richfaces.renderkit.html.images.buttons;

import java.awt.Color;

import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.ajax4jsf.util.HtmlColor;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;

/**
 * @author Anton Belevich
 *
 */
public class SpinnerButtonImageTest extends AbstractAjax4JsfTestCase {

	
	public SpinnerButtonImageTest(String name) {
		super(name);
	}
	
	public void testSaveResources(){
		
		SpinnerButtonImage img = new SpinnerButtonUp();
	
		Skin skin = SkinFactory.getInstance().getSkin(facesContext);
		Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(facesContext);
		
		String skinParameter = "headerTextColor";
		String headerTextColor = (String) skin.getParameter(facesContext, skinParameter);
		
		if (null == headerTextColor || "".equals(headerTextColor))
			headerTextColor = (String) defaultSkin.getParameter(facesContext, skinParameter);
		
		headerTextColor = headerTextColor == null ? "#000000" : headerTextColor;
		
		Color color1 = HtmlColor.decode(headerTextColor);
		
		byte [] data = (byte []) img.getDataToStore(facesContext, null);
		
		assertNotNull(data);
		
		Integer results = (Integer)img.deserializeData(data);
	
		assertNotNull(results);
		
		Color color2 = new Color(results.intValue());
			
		assertEquals(color1, color2);
	}	

}
