JBoss Rich Faces SVN: r358 - trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-11 09:02:47 -0400 (Wed, 11 Apr 2007)
New Revision: 358
Modified:
trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java
Log:
test updated
Modified: trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java
===================================================================
--- trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java 2007-04-11 13:02:10 UTC (rev 357)
+++ trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java 2007-04-11 13:02:47 UTC (rev 358)
@@ -23,6 +23,9 @@
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+/**
+ * Unit test for TabPanelRenderer.
+ */
public class TabPanelRendererBaseTest extends AbstractAjax4JsfTestCase {
private static String STYLE = "test1:1;test2:2; test3: 3; test4 :4;test5 : 5; test6:6; test7:;test8; test9";
19 years
JBoss Rich Faces SVN: r357 - in trunk/richfaces/datascroller/src: main/java/org/richfaces/renderkit/html and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-11 09:02:10 -0400 (Wed, 11 Apr 2007)
New Revision: 357
Added:
trunk/richfaces/datascroller/src/test/java/org/richfaces/event/
trunk/richfaces/datascroller/src/test/java/org/richfaces/event/DataScrollerEventTest.java
Modified:
trunk/richfaces/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
trunk/richfaces/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java
Log:
test updated
Modified: trunk/richfaces/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
===================================================================
--- trunk/richfaces/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-04-11 13:00:35 UTC (rev 356)
+++ trunk/richfaces/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-04-11 13:02:10 UTC (rev 357)
@@ -38,8 +38,8 @@
* Creates a new ScrollerEvent.
*
* @param component the source of the event
- * @param thisOldScrollerVal the previously showing item identifier
- * @param thisNewSliderVal the currently showing item identifier
+ * @param thisOldScrolVal the previously showing item identifier
+ * @param thisNewScrolVal the currently showing item identifier
*/
public DataScrollerEvent(UIComponent component, String thisOldScrolVal, String thisNewScrolVal) {
super(component);
@@ -66,6 +66,6 @@
* @param listener the slider listener
*/
public void processListener(FacesListener listener){
- ((DataScrollerListener) listener).processScroller(this);
+ ((DataScrollerListener) listener).processScroller(this);
}
}
Modified: trunk/richfaces/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java
===================================================================
--- trunk/richfaces/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2007-04-11 13:00:35 UTC (rev 356)
+++ trunk/richfaces/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2007-04-11 13:02:10 UTC (rev 357)
@@ -21,210 +21,190 @@
package org.richfaces.renderkit.html;
-import java.io.IOException;
-import java.util.Map;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.richfaces.component.UIDatascroller;
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.richfaces.component.UIDatascroller;
import org.richfaces.event.DataScrollerEvent;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.Map;
+public class DataScrollerRenderer extends HeaderResourcesRendererBase {
-public class DataScrollerRenderer extends HeaderResourcesRendererBase {
-
- protected Class getComponentClass() {
- return UIDatascroller.class;
- }
+ protected Class getComponentClass() {
+ return UIDatascroller.class;
+ }
- public void encodeBegin(FacesContext context, UIComponent component)
- throws IOException {
-
- UIDatascroller scroller = (UIDatascroller) component;
-
- //if ((scroller.getRowCount()-scroller.getFirstRow())<scroller.getRows() && scroller.getRowCount()>=scroller.getRows()){
- // scroller.setFirstRow(scroller.getRowCount()-scroller.getRows()+1);
- //}
-
- if (scroller.getHandleValue()==null){
- scroller.setHandleValue("1");
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+
+ UIDatascroller scroller = (UIDatascroller) component;
+
+ //if ((scroller.getRowCount()-scroller.getFirstRow())<scroller.getRows() && scroller.getRowCount()>=scroller.getRows()){
+ // scroller.setFirstRow(scroller.getRowCount()-scroller.getRows()+1);
+ //}
+
+ if (scroller.getHandleValue() == null) {
+ scroller.setHandleValue("1");
}
-
- if (scroller.getPageCount() < Integer.parseInt(scroller.getHandleValue())){
-
- scroller.setPageIndex(scroller.getPageCount()-1);
- scroller.setHandleValue(Integer.toString(scroller.getPageCount()));
- }
- else{
-
- scroller.setPageIndex(Integer.parseInt(scroller.getHandleValue())-1);
- }
-
-
-
- if (!(scroller.getPageCount()==1) || (scroller.isRenderIfSinglePage())){
- super.encodeBegin(context, component);
+
+ if (scroller.getPageCount() < Integer.parseInt(scroller.getHandleValue()))
+ {
+
+ scroller.setPageIndex(scroller.getPageCount() - 1);
+ scroller.setHandleValue(Integer.toString(scroller.getPageCount()));
+ } else {
+
+ scroller.setPageIndex(Integer.parseInt(scroller.getHandleValue()) - 1);
}
+
+
+ if (!(scroller.getPageCount() == 1) || (scroller.isRenderIfSinglePage()))
+ {
+ super.encodeBegin(context, component);
+ }
}
public void encodeEnd(FacesContext context, UIComponent component)
- throws IOException {
- UIDatascroller scroller = (UIDatascroller) component;
-
- if (!(scroller.getPageCount()==1) || (scroller.isRenderIfSinglePage())){
- super.encodeEnd(context, component);
- }
+ throws IOException {
+ UIDatascroller scroller = (UIDatascroller) component;
+
+ if (!(scroller.getPageCount() == 1) || (scroller.isRenderIfSinglePage()))
+ {
+ super.encodeEnd(context, component);
+ }
}
-
- //public static final String RENDERER_TYPE = Datascroller.RENDERER_TYPE;
+ private static final String PARAM_SUFFIX = "_parameter";
- private static final String PARAM_SUFFIX = "_parameter";
+ public void decode(FacesContext context, UIComponent component) {
- public void decode(FacesContext context, UIComponent component) {
-
- String param = (String) getParamMap(context).get(
- component.getClientId(context) + PARAM_SUFFIX);
- UIDatascroller scroller = (UIDatascroller) component;
- if (scroller.getHandleValue()==null){
- scroller.setHandleValue("1");
+ String param = (String) getParamMap(context).get(
+ component.getClientId(context) + PARAM_SUFFIX);
+ UIDatascroller scroller = (UIDatascroller) component;
+ if (scroller.getHandleValue() == null) {
+ scroller.setHandleValue("1");
}
- if (param != null) {
- //UIDatascroller scroller = (UIDatascroller) component;
- scroller.setPage(param);
- scroller.getPageIndex();
- String oldScrolVal = scroller.getHandleValue();
- String newScrolVal = Integer.toString(scroller.getPageIndex());
- if (!newScrolVal.equals(oldScrolVal)) {
+ if (param != null) {
+ //UIDatascroller scroller = (UIDatascroller) component;
+ scroller.setPage(param);
+ scroller.getPageIndex();
+ String oldScrolVal = scroller.getHandleValue();
+ String newScrolVal = Integer.toString(scroller.getPageIndex());
+ if (!newScrolVal.equals(oldScrolVal)) {
- scroller.setHandleValue(newScrolVal);
- DataScrollerEvent event = new DataScrollerEvent(scroller, oldScrolVal, newScrolVal);
- event.queue();
+ scroller.setHandleValue(newScrolVal);
+ DataScrollerEvent event = new DataScrollerEvent(scroller, oldScrolVal, newScrolVal);
+ event.queue();
- AjaxRendererUtils.addRegionByName(context, component, component.getId());
- AjaxRendererUtils.addRegionByName(context, component, scroller.getFor());
- }
-
-
- }
-
-
-
-
-
-
-
+ AjaxRendererUtils.addRegionByName(context, component, component.getId());
+ AjaxRendererUtils.addRegionByName(context, component, scroller.getFor());
+ }
+ }
+ }
- }
+ public void renderPager(FacesContext context, UIComponent component) throws IOException {
+ ResponseWriter out = context.getResponseWriter();
+ UIDatascroller scroller = (UIDatascroller) component;
+ int currentPage = scroller.getPageIndex();
+ int maxPages = scroller.getMaxPages();
+ if (maxPages <= 1) {
+ maxPages = 1;
+ }
+ int pageCount = scroller.getPageCount();
+ if (pageCount <= 1) {
+ return;
+ }
+ int pageIndex = scroller.getPageIndex();
+ int delta = maxPages / 2;
- public void renderPager(FacesContext context, UIComponent component) throws IOException{
- ResponseWriter out = context.getResponseWriter();
- UIDatascroller scroller=(UIDatascroller)component;
- int currentPage = scroller.getPageIndex();
+ int pages;
+ int start;
+ if (pageCount > maxPages && pageIndex > delta) {
+ pages = maxPages;
+ start = pageIndex - pages / 2 - 1;
+ if (start + pages > pageCount) {
+ start = pageCount - pages;
+ }
+ } else {
+ pages = pageCount < maxPages ? pageCount : maxPages;
+ start = 0;
+ }
- int maxPages = scroller.getMaxPages();
- if (maxPages <= 1) {
- maxPages = 1;
- }
- int pageCount = scroller.getPageCount();
- if (pageCount <= 1) {
- return;
- }
- int pageIndex = scroller.getPageIndex();
- int delta = maxPages / 2;
+ for (int i = start, size = start + pages; i < size; i++) {
+ //String styleClass;
+ //String style;
- int pages;
- int start;
- if (pageCount > maxPages && pageIndex > delta) {
- pages = maxPages;
- start = pageIndex - pages / 2 - 1;
- if (start + pages > pageCount) {
- start = pageCount - pages;
- }
- }
- else {
- pages = pageCount < maxPages ? pageCount : maxPages;
- start = 0;
- }
+ boolean isCurrentPage = (i + 1 == currentPage);
+ /*
+ if (isCurrentPage) {
+ styleClass = scroller.getSelectedStyleClass();
+ style = scroller.getSelectedStyle();
+ }
+ else {
+ styleClass = scroller.getStyleClass();
+ style = scroller.getStyle();
+ }
- for (int i = start, size = start + pages; i < size; i++) {
- //String styleClass;
- //String style;
+ if (style==null){
+ style="";
+ }
+ if (styleClass==null){
+ styleClass="";
+ }
+ */
- boolean isCurrentPage = (i + 1 == currentPage);
- /*
- if (isCurrentPage) {
- styleClass = scroller.getSelectedStyleClass();
- style = scroller.getSelectedStyle();
- }
- else {
- styleClass = scroller.getStyleClass();
- style = scroller.getStyle();
- }
-
- if (style==null){
- style="";
- }
- if (styleClass==null){
- styleClass="";
- }
- */
-
- out.startElement("td", component);
- if (isCurrentPage){
- out.writeAttribute("align", "center", null);
- //out.writeAttribute("class", "dr-dscr-act rich-datascr-act "+scroller.getStyleClass(), null);
- out.writeAttribute("class", "dr-dscr-act rich-datascr-act", null);
- out.writeAttribute("style", ""+scroller.getSelectedStyle(), null);
- }
- else{
- out.writeAttribute("align", "center", null);
- //out.writeAttribute("class", "dr-dscr-inact rich-datascr-inact "+scroller.getStyleClass(), null);
- out.writeAttribute("class", "dr-dscr-inact rich-datascr-inact", null);
- //out.writeAttribute("style", ""+scroller.getStyle(), null);
- out.writeAttribute("onclick", getOnClick(context, component,Integer.toString(i+1)) , null);
- }
- out.writeText(Integer.toString(i + 1), null);
- //renderChild(context, link);
- out.endElement("td");
- }
+ out.startElement("td", component);
+ if (isCurrentPage) {
+ out.writeAttribute("align", "center", null);
+ //out.writeAttribute("class", "dr-dscr-act rich-datascr-act "+scroller.getStyleClass(), null);
+ out.writeAttribute("class", "dr-dscr-act rich-datascr-act", null);
+ out.writeAttribute("style", "" + scroller.getSelectedStyle(), null);
+ } else {
+ out.writeAttribute("align", "center", null);
+ //out.writeAttribute("class", "dr-dscr-inact rich-datascr-inact "+scroller.getStyleClass(), null);
+ out.writeAttribute("class", "dr-dscr-inact rich-datascr-inact", null);
+ //out.writeAttribute("style", ""+scroller.getStyle(), null);
+ out.writeAttribute("onclick", getOnClick(context, component, Integer.toString(i + 1)), null);
+ }
+ out.writeText(Integer.toString(i + 1), null);
+ //renderChild(context, link);
+ out.endElement("td");
+ }
- }
+ }
+ private Map getParamMap(FacesContext context) {
+ return context.getExternalContext().getRequestParameterMap();
+ }
+ public String getOnClick(FacesContext context, UIComponent component, String value) {
- private Map getParamMap(FacesContext context) {
- return context.getExternalContext().getRequestParameterMap();
- }
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(component,
+ context);
+ UIDatascroller scroller = (UIDatascroller) component;
+ Map eventOptions = AjaxRendererUtils.buildEventOptions(context, component);
+ Map parameters = (Map) eventOptions.get("parameters");
+ parameters.put(scroller.getClientId(context) + PARAM_SUFFIX, value);
+ function.addParameter(eventOptions);
+ StringBuffer buffer = new StringBuffer();
+ function.appendScript(buffer);
+ buffer.append("; return false;");
+ String script = buffer.toString();
+ return script;
+ }
-
- public String getOnClick(FacesContext context, UIComponent component,String value) {
-
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(component,
- context);
- UIDatascroller scroller=(UIDatascroller)component;
- Map eventOptions = AjaxRendererUtils.buildEventOptions(context,component);
- Map parameters = (Map) eventOptions.get("parameters");
- parameters.put(scroller.getClientId(context) + PARAM_SUFFIX, value);
- function.addParameter(eventOptions);
- StringBuffer buffer = new StringBuffer();
- function.appendScript(buffer);
- buffer.append("; return false;");
- String script = buffer.toString();
- return script;
- }
-
-
- /**
- * Creates HtmlAjaxCommandLink sets its id, value and reRender and UIParameter
- */
- public boolean getRendersChildren() {
- return true;
- }
+ /**
+ * Creates HtmlAjaxCommandLink sets its id, value and reRender and UIParameter
+ */
+ public boolean getRendersChildren() {
+ return true;
+ }
}
Added: trunk/richfaces/datascroller/src/test/java/org/richfaces/event/DataScrollerEventTest.java
===================================================================
--- trunk/richfaces/datascroller/src/test/java/org/richfaces/event/DataScrollerEventTest.java (rev 0)
+++ trunk/richfaces/datascroller/src/test/java/org/richfaces/event/DataScrollerEventTest.java 2007-04-11 13:02:10 UTC (rev 357)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import javax.faces.component.UIData;
+import javax.faces.component.html.HtmlDataTable;
+import javax.faces.event.PhaseId;
+import javax.faces.event.FacesListener;
+
+/**
+ * Unit test for DataScrollerEvent.
+ */
+public class DataScrollerEventTest extends AbstractAjax4JsfTestCase {
+
+ private DataScrollerEvent event;
+ private UIData data;
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public DataScrollerEventTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ data = (UIData) application.createComponent(HtmlDataTable.COMPONENT_TYPE);
+ event = new DataScrollerEvent(data, "old", "new");
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ event = null;
+ data = null;
+ }
+
+ public void testEvent() throws Exception {
+ assertEquals(PhaseId.INVOKE_APPLICATION, event.getPhaseId());
+ assertEquals("old", event.getOldScrolVal());
+ assertEquals("new", event.getNewScrolVal());
+ assertFalse(event.isAppropriateListener(new TestFacesListener()));
+ assertTrue(event.isAppropriateListener(new TestDataScrollerListener()));
+ }
+
+ class TestFacesListener implements FacesListener {
+
+ }
+
+ class TestDataScrollerListener implements DataScrollerListener {
+ public void processScroller(DataScrollerEvent event) {
+ }
+ }
+}
19 years
JBoss Rich Faces SVN: r356 - trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: F.antonov
Date: 2007-04-11 09:00:35 -0400 (Wed, 11 Apr 2007)
New Revision: 356
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
Log:
Menu item test case development.
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2007-04-11 12:58:24 UTC (rev 355)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2007-04-11 13:00:35 UTC (rev 356)
@@ -148,7 +148,7 @@
return iconFacet;
}
- private String resolveSubmitMode(UIMenuItem menuItem) {
+ protected String resolveSubmitMode(UIMenuItem menuItem) {
String submitMode = menuItem.getMode();
if (null != submitMode) {
return submitMode;
@@ -164,7 +164,7 @@
return MenuComponent.MODE_SERVER;
}
- private String processInlineStyles(FacesContext context, UIMenuItem menuItem, boolean isOnmouseover) {
+ protected String processInlineStyles(FacesContext context, UIMenuItem menuItem, boolean isOnmouseover) {
StringBuffer buffer = new StringBuffer();
Object style = menuItem.getAttributes().get("style");
Object selectStyle = menuItem.getAttributes().get("selectStyle");
19 years
JBoss Rich Faces SVN: r355 - in trunk/richfaces/menu-components/src/test/java/org/richfaces: component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: F.antonov
Date: 2007-04-11 08:58:24 -0400 (Wed, 11 Apr 2007)
New Revision: 355
Added:
trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/
trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/
trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java
Modified:
trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
Log:
Menu components test cases development.
Modified: trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
===================================================================
--- trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2007-04-11 12:29:47 UTC (rev 354)
+++ trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2007-04-11 12:58:24 UTC (rev 355)
@@ -21,36 +21,18 @@
package org.richfaces.component;
-import java.io.IOException;
-import java.io.Serializable;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlOutputText;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.IntegerConverter;
-import javax.faces.el.ValueBinding;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
import javax.faces.event.PhaseId;
-import javax.faces.render.Renderer;
import org.richfaces.component.html.HtmlMenuItem;
-import org.richfaces.renderkit.html.MenuItemRenderer;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
@@ -59,21 +41,18 @@
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.ajax4jsf.tests.MockViewRoot;
-import org.ajax4jsf.ajax.UIActionParameter;
-import org.ajax4jsf.framework.renderer.ComponentVariables;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
import org.apache.commons.collections.Buffer;
import org.apache.commons.lang.StringUtils;
-import org.apache.shale.test.mock.MockActionListener;
+
/**
* Unit test for MenuItem Component.
*/
public class MenuItemComponentTest
extends AbstractAjax4JsfTestCase
{
- private static Set javaScripts = new HashSet();
+ private static Set javaScripts = new HashSet<String>();
static {
javaScripts.add("prototype.js");
@@ -119,6 +98,7 @@
*/
public void testMenuItemRender() throws Exception
{
+ menuItem.setMode(MenuComponent.MODE_NONE);
HtmlPage page = renderView();
assertNotNull(page);
//System.out.println(page.asXml());
@@ -128,7 +108,7 @@
}
/**
- * MenuItem facets test.
+ * MenuItem facet test.
*/
public void testMenuItemIconFacet() throws Exception
{
@@ -143,11 +123,12 @@
}
/**
- * Test for MenuItem component in disabled mode.
+ * Test for MenuItem disabled component.
*/
public void testDisabledMenuItem() throws Exception
{
- menuItem.setDisabled(true);
+ menuItem.setDisabled(true);
+ menuItem.getAttributes().put("iconDisabled", "menuItemIconDisabled");
HtmlPage page = renderView();
assertNotNull(page);
System.out.println(page.asXml());
@@ -176,15 +157,18 @@
}
/**
- * Test for MenuItem component in enabled mode.
+ * Test for enabled MenuItem component in "server" mode.
*/
- public void testEnabledMenuItem() throws Exception
+ public void testEnabledMenuItemServerMode() throws Exception
{
assertEquals(false, menuItem.isDisabled());
menuItem.getAttributes().put("iconClass", "iconClass");
+ menuItem.setMode(MenuComponent.MODE_SERVER);
+ menuItem.getAttributes().put("target", "target");
+ menuItem.getAttributes().put("selectStyle", "menuItemSelectStyle");
HtmlPage page = renderView();
assertNotNull(page);
- //System.out.println(page.asXml());
+ System.out.println(page.asXml());
HtmlElement anchor = page.getHtmlElementById(menuItem.getClientId(facesContext) + ":anchor");
assertNotNull(anchor);
@@ -204,9 +188,50 @@
assertEquals("div", div.getNodeName());
classAttr = div.getAttributeValue("class");
assertTrue(classAttr.contains("dr-menu-item dr-menu-item-enabled rich-menu-item rich-menu-item-enabled"));
+ classAttr = div.getAttributeValue("onclick");
+ assertNotNull(classAttr);
+ assertTrue(classAttr.length() > 0);
+ classAttr = div.getAttributeValue("onmouseover");
+ assertTrue(classAttr.contains("menuItemSelectStyle"));
}
/**
+ * Test for enabled MenuItem component in "ajax" mode.
+ */
+ public void testEnabledMenuItemAJAXMode() throws Exception
+ {
+ menuItem.setMode(MenuComponent.MODE_AJAX);
+ menuItem.getAttributes().put("style", "menuItemStyle");
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ //System.out.println(page.asXml());
+
+ HtmlElement div = page.getHtmlElementById(menuItem.getClientId(facesContext));
+ assertNotNull(div);
+ String classAttr = div.getAttributeValue("onclick");
+ assertTrue(classAttr.contains("AJAX"));
+ classAttr = div.getAttributeValue("style");
+ assertTrue(classAttr.contains("menuItemStyle"));
+ }
+
+ /**
+ * Test for enabled MenuItem component in "none" mode.
+ */
+ public void testEnabledMenuItemNoneMode() throws Exception
+ {
+ menuItem.setMode(MenuComponent.MODE_NONE);
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ //System.out.println(page.asXml());
+
+ HtmlElement div = page.getHtmlElementById(menuItem.getClientId(facesContext));
+ assertNotNull(div);
+ String classAttr = div.getAttributeValue("onclick");
+ assertNotNull(classAttr);
+ assertTrue(classAttr.length() > 0);
+ }
+
+ /**
* CSS link test.
*/
public void testRenderStyle() throws Exception {
@@ -249,9 +274,9 @@
}
/**
- * doDecode method trst.
+ * DoDecode method trst. Component in "AJAX" mode. Immediate is true.
*/
- public void testMenuItemDoDecode() throws Exception {
+ public void testMenuItemDoDecodeAJAXMode() throws Exception {
menuItem.setImmediate(true);
menuItem.setMode(MenuComponent.MODE_AJAX);
@@ -265,4 +290,21 @@
assertEquals(1, events.size());
}
+ /**
+ * DoDecode method trst. Component in "server" mode. Immediate is false.
+ */
+ public void testMenuItemDoDecodeServerMode() throws Exception {
+
+ menuItem.setImmediate(false);
+ menuItem.setMode(MenuComponent.MODE_SERVER);
+
+ externalContext.getRequestParameterMap().put(menuItem.getClientId(facesContext) + ":hidden", "Action");
+ menuItem.decode(facesContext);
+
+ MockViewRoot mockViewRoot = (MockViewRoot) facesContext.getViewRoot();
+ Buffer events = mockViewRoot.getEventsQueue(facesContext, PhaseId.INVOKE_APPLICATION);
+ assertNotNull(events);
+ assertEquals(1, events.size());
+ }
+
}
Added: trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java
===================================================================
--- trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java (rev 0)
+++ trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java 2007-04-11 12:58:24 UTC (rev 355)
@@ -0,0 +1,127 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.MenuComponent;
+import org.richfaces.component.UIMenuItem;
+import org.richfaces.component.html.HtmlMenuItem;
+
+/**
+ * Unit test for MenuItem renderer.
+ */
+public class MenuItemRendererBaseTest
+ extends AbstractAjax4JsfTestCase
+{
+
+ private UIMenuItem menuItem;
+ private MenuComponent menu;
+ private static MenuItemRendererBase renderer = new MenuItemRendererBase();
+
+ /**
+ * Simple implementation of MenuComponent interfase.
+ */
+ private class MenuComponentImpl extends UIComponentBase implements MenuComponent {
+
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getMode() {
+ return MenuComponent.MODE_AJAX;
+ }
+
+ }
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public MenuItemRendererBaseTest(String testName)
+ {
+ super(testName);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ menu = new MenuComponentImpl();
+
+ menuItem = (UIMenuItem) application.createComponent(HtmlMenuItem.COMPONENT_TYPE);
+ menuItem.setId("menuItem");
+ menuItem.setValue("Menu Item");
+
+ ((UIComponent) menu).getChildren().add(menuItem);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ menuItem = null;
+ menu = null;
+ }
+
+ /**
+ * Test for resolveSubmitMode method.
+ */
+ public void testResolveSubmitModeMethod() throws Exception
+ {
+ menuItem.setMode(null);
+ assertEquals(menuItem.getParent(), menu);
+ String resultMode = renderer.resolveSubmitMode(menuItem);
+ assertEquals(resultMode, MenuComponent.MODE_AJAX);
+
+ menuItem.setMode(MenuComponent.MODE_NONE);
+ resultMode = renderer.resolveSubmitMode(menuItem);
+ assertEquals(resultMode, MenuComponent.MODE_NONE);
+ }
+
+ /**
+ * Test for processInlineStyles method.
+ */
+ public void testProcessInlineStylesMethod() throws Exception
+ {
+ String style = "some style";
+ String selectStyle = "some select style";
+ String result = renderer.processInlineStyles(facesContext, menuItem, true);
+ assertEquals(result, "");
+
+ menuItem.getAttributes().put("selectStyle", selectStyle);
+ result = renderer.processInlineStyles(facesContext, menuItem, false);
+ assertTrue(! result.contains(selectStyle));
+ assertTrue(! result.contains(style));
+
+ result = renderer.processInlineStyles(facesContext, menuItem, true);
+ assertTrue(result.contains(selectStyle));
+ assertTrue(! result.contains(style));
+
+ menuItem.getAttributes().put("style", style);
+ result = renderer.processInlineStyles(facesContext, menuItem, true);
+ assertTrue(result.contains(selectStyle));
+ assertTrue(result.contains(style));
+ }
+
+}
19 years
JBoss Rich Faces SVN: r354 - in trunk/richfaces/tabPanel/src: test/java/org/richfaces and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-11 08:29:47 -0400 (Wed, 11 Apr 2007)
New Revision: 354
Added:
trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/
trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java
Modified:
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
Log:
test updated
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-04-11 12:14:57 UTC (rev 353)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-04-11 12:29:47 UTC (rev 354)
@@ -47,48 +47,48 @@
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 12.01.2007
- *
+ *
*/
public class TabPanelRendererBase extends org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase {
public final static String ACTIVE_CELL_CLASSES = "dr-tbpnl-tbcell-act rich-tabhdr-cell-active";
public final static String INACTIVE_CELL_CLASSES = "dr-tbpnl-tbcell-inact rich-tabhdr-cell-inactive";
public final static String DISABLED_CELL_CLASSES = "dr-tbpnl-tbcell-dsbld rich-tabhdr-cell-disabled";
-
+
protected Class getComponentClass() {
return UITabPanel.class;
}
protected void doDecode(FacesContext context, UIComponent component) {
super.doDecode(context, component);
-
+
UITabPanel panel = (UITabPanel) component;
-
+
String clientId = component.getClientId(context);
Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
UITab eventTab = null;
-
- for (Iterator tabsIterator = panel.getTabs();
+
+ for (Iterator tabsIterator = panel.getTabs();
tabsIterator.hasNext() && eventTab == null;) {
-
+
UITab tab = (UITab) tabsIterator.next();
if (!tab.isRendered() || tab.isDisabled()) {
continue;
}
String tabClientId = tab.getClientId(context);
- if (requestParameterMap.containsKey(tabClientId) ||
+ if (requestParameterMap.containsKey(tabClientId) ||
requestParameterMap.containsKey(tabClientId + "_server_submit")) {
-
+
eventTab = tab;
}
}
-
+
if (eventTab != null) {
new SwitchablePanelSwitchEvent(panel, null, eventTab).queue();
new ActionEvent(eventTab).queue();
-
+
if (UISwitchablePanel.AJAX_METHOD.equals(eventTab.getSwitchType())) {
new AjaxEvent(eventTab).queue();
}
@@ -104,11 +104,11 @@
private final JSReference JSR_ACTIVE_CLASS = new JSReference("activeClass");
private final JSReference JSR_ID = new JSReference("id");
private final JSReference JSR_INACTIVE_CLASS = new JSReference("inactiveClass");
-
+
private final JSReference JSR_CELL_ACTIVE_CLASS = new JSReference("cellActiveClass");
private final JSReference JSR_CELL_INACTIVE_CLASS = new JSReference("cellInactiveClass");
-
+
public Object collectTabInfo(FacesContext context, UITab tab) {
Map info = new HashMap();
info.put(JSR_ID, tab.getClientId(context));
@@ -117,11 +117,11 @@
info.put(JSR_CELL_ACTIVE_CLASS, ACTIVE_CELL_CLASSES);
info.put(JSR_CELL_INACTIVE_CLASS, INACTIVE_CELL_CLASSES);
-
+
return info;
}
};
-
+
/**
* @param context
* @param component
@@ -154,7 +154,7 @@
* @param name
* @return
*/
- private static boolean parameterPresent(String style, String name) {
+ protected static boolean parameterPresent(String style, String name) {
if (style != null && style.length() > 0) {
String[] styles = style.split(";");
for (int i = 0; i < styles.length; i++) {
@@ -177,11 +177,11 @@
public void encodeTabs(FacesContext context, UITabPanel tabPanel) throws IOException {
ComponentVariables componentVariables = ComponentsVariableResolver.getVariables(this, tabPanel);
-
+
Object value = tabPanel.getValue();
if (value instanceof String) {
if (((String) value).length() == 0) {
- value = null;
+ value = null;
}
}
if (value == null){
@@ -191,15 +191,15 @@
UITabPanel pane = tabPanel;
UITab firstRenderedTab = null;
UITab activeTab = null;
-
+
for (Iterator iter = pane.getTabs(); iter.hasNext() && activeTab == null;) {
UITab tab = (UITab) iter.next();
-
+
if (tab.isRendered()) {
if (firstRenderedTab == null) {
firstRenderedTab = tab;
}
-
+
if (useFirstRenderedTab) {
activeTab = firstRenderedTab;
} else if (value.equals(tab.getName())) {
@@ -218,7 +218,7 @@
}
}
}
-
+
if (activeTab == null) {
throw new IllegalStateException("No active tabs!");
} else {
@@ -234,12 +234,12 @@
UITab tab = (UITab) iter.next();
boolean active = activeTab == tab;
tab.setActive(active);
-
+
if (tab.isRendered()) {
if (!clientSide) {
clientSide = UISwitchablePanel.CLIENT_METHOD.equals(tab.getSwitchType());
}
-
+
tab.encodeTab(context, active);
if (!tab.isDisabled()) {
@@ -252,7 +252,7 @@
componentVariables.setVariable("clientSide", new Boolean(clientSide));
componentVariables.setVariable("tabs", tabs);
}
-
+
public static String getActiveTabCellClass(UITab tab) {
return TabClassBuilder.activeTabClassBuilder.buildTabClass(tab);
}
@@ -265,7 +265,7 @@
return TabClassBuilder.inactiveTabClassBuilder.buildTabClass(tab);
}
-
+
public static String getActiveTabClass(UITab tab) {
return TabClassBuilder.activeTabClassBuilder.buildTabClass(tab);
}
@@ -280,7 +280,7 @@
/**
* Encode JavaScript function for switch tabs.
- *
+ *
* @param templateContext
* @throws IOException
*/
@@ -304,6 +304,6 @@
protected TabInfoCollector getTabInfoCollector() {
return collector;
}
-
+
}
Modified: trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
===================================================================
--- trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-04-11 12:14:57 UTC (rev 353)
+++ trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-04-11 12:29:47 UTC (rev 354)
@@ -28,6 +28,7 @@
import org.apache.commons.lang.StringUtils;
import org.richfaces.component.html.HtmlTab;
import org.richfaces.component.html.HtmlTabPanel;
+import org.richfaces.renderkit.TabPanelRendererBase;
import javax.faces.component.UIForm;
import javax.faces.component.html.HtmlForm;
Added: trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java
===================================================================
--- trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java (rev 0)
+++ trunk/richfaces/tabPanel/src/test/java/org/richfaces/renderkit/TabPanelRendererBaseTest.java 2007-04-11 12:29:47 UTC (rev 354)
@@ -0,0 +1,64 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+public class TabPanelRendererBaseTest extends AbstractAjax4JsfTestCase {
+ private static String STYLE = "test1:1;test2:2; test3: 3; test4 :4;test5 : 5; test6:6; test7:;test8; test9";
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public TabPanelRendererBaseTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testParameterPresent() throws Exception {
+ assertFalse(TabPanelRendererBase.parameterPresent(null, "test0"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test1"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test2"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test3"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test4"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test5"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test6"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test7"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test8"));
+ assertTrue(TabPanelRendererBase.parameterPresent(STYLE, "test9"));
+ }
+}
19 years
JBoss Rich Faces SVN: r353 - trunk/richfaces/menu-components/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: F.antonov
Date: 2007-04-11 08:14:57 -0400 (Wed, 11 Apr 2007)
New Revision: 353
Modified:
trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml
Log:
MenuItem component development.
Modified: trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml
===================================================================
--- trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml 2007-04-11 12:09:18 UTC (rev 352)
+++ trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml 2007-04-11 12:14:57 UTC (rev 353)
@@ -180,7 +180,6 @@
<name>mode</name>
<classname>java.lang.String</classname>
<description>Set the submission mode (ajax, server(Default), none)</description>
- <defaultvalue>"server"</defaultvalue>
</property>
<!-- Command attributes -->
19 years
JBoss Rich Faces SVN: r352 - in trunk/richfaces/tabPanel/src: test/java/org/richfaces and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-11 08:09:18 -0400 (Wed, 11 Apr 2007)
New Revision: 352
Added:
trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/UITabTest.java
trunk/richfaces/tabPanel/src/test/java/org/richfaces/model/
trunk/richfaces/tabPanel/src/test/java/org/richfaces/model/TabTest.java
Modified:
trunk/richfaces/tabPanel/src/main/java/org/richfaces/model/Tab.java
trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
Log:
test updated
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/model/Tab.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/model/Tab.java 2007-04-11 11:08:17 UTC (rev 351)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/model/Tab.java 2007-04-11 12:09:18 UTC (rev 352)
@@ -23,136 +23,130 @@
/**
* Tab model bean represent a single tab in list of tabs for panel.
+ *
* @author shura (latest modification by $Author: ishabalov $)
* @version $Revision: 1.3 $ $Date: 2007/02/21 20:35:05 $
- *
*/
public class Tab implements TabModel {
- private Object _name;
- private String _label;
- private boolean _disabled;
- private String _labelWidth;
-// private String _description;
- private String _switchType;
- private String _title;
-
-
- /**
- * No-argument constructor for JavaBean contract.
- */
- public Tab() {
- super();
- }
-
- public Tab(Object value) {
- this(value,value.toString(),false,null,null);
- }
- /**
- * @param value
- * @param label
- * @param disabled
- * @param labelWidth
- * @param title
- */
- public Tab(Object value, String label, boolean disabled, String labelWidth, String title) {
- super();
- this._name = value;
- this._label = label;
- this._disabled = disabled;
- this._labelWidth = labelWidth;
- this._title = title;
-// this._description = description;
- }
- /**
- * @return Returns the description.
- */
-/* public String getDescription() {
- return this._description;
- }*/
- /**
- * @param description The description to set.
- */
-/* public void setDescription(String description) {
- this._description = description;
- }*/
- /**
- * @return Returns the disabled.
- */
- public boolean isDisabled() {
- return this._disabled;
- }
- /**
- * @param disabled The disabled to set.
- */
- public void setDisabled(boolean disabled) {
- this._disabled = disabled;
- }
- /**
- * @return Returns the label.
- */
- public String getLabel() {
- return this._label;
- }
- /**
- * @param label The label to set.
- */
- public void setLabel(String label) {
- this._label = label;
- }
- /**
- * @return Returns the labelWidth.
- */
- public String getLabelWidth() {
- return this._labelWidth;
- }
- /**
- * @param labelWidth The labelWidth to set.
- */
- public void setLabelWidth(String labelWidth) {
- this._labelWidth = labelWidth;
- }
- /**
- * @return Returns the value.
- */
- public Object getName() {
- return this._name;
- }
- /**
- * @param value The value to set.
- */
- public void setName(Object value) {
- if(value == null) {
- throw new NullPointerException("value for tab set to null");
- }
- this._name = value;
- }
+ private Object _name;
+ private String _label;
+ private boolean _disabled;
+ private String _labelWidth;
+ private String _switchType;
+ private String _title;
- /**
- * @return Returns the switchType.
- */
- public String getSwitchType() {
- return _switchType;
- }
+ /**
+ * No-argument constructor for JavaBean contract.
+ */
+ public Tab() {
+ super();
+ }
- /**
- * @param switchType The switchType to set.
- */
- public void setSwitchType(String switchType) {
- _switchType = switchType;
- }
- /**
- * @return Returns the title.
- */
- public String getTitle() {
- return _title;
- }
- /**
- * @param title The title to set.
- */
- public void setTitle(String newvalue) {
- this._title = newvalue;
-
- }
-
+ public Tab(Object value) {
+ this(value, value.toString(), false, null, null);
+ }
+
+ /**
+ * @param value
+ * @param label
+ * @param disabled
+ * @param labelWidth
+ * @param title
+ */
+ public Tab(Object value, String label, boolean disabled, String labelWidth, String title) {
+ super();
+ this._name = value;
+ this._label = label;
+ this._disabled = disabled;
+ this._labelWidth = labelWidth;
+ this._title = title;
+ }
+
+ /**
+ * @return Returns the disabled.
+ */
+ public boolean isDisabled() {
+ return this._disabled;
+ }
+
+ /**
+ * @param disabled The disabled to set.
+ */
+ public void setDisabled(boolean disabled) {
+ this._disabled = disabled;
+ }
+
+ /**
+ * @return Returns the label.
+ */
+ public String getLabel() {
+ return this._label;
+ }
+
+ /**
+ * @param label The label to set.
+ */
+ public void setLabel(String label) {
+ this._label = label;
+ }
+
+ /**
+ * @return Returns the labelWidth.
+ */
+ public String getLabelWidth() {
+ return this._labelWidth;
+ }
+
+ /**
+ * @param labelWidth The labelWidth to set.
+ */
+ public void setLabelWidth(String labelWidth) {
+ this._labelWidth = labelWidth;
+ }
+
+ /**
+ * @return Returns the value.
+ */
+ public Object getName() {
+ return this._name;
+ }
+
+ /**
+ * @param value The value to set.
+ */
+ public void setName(Object value) {
+ if (value == null) {
+ throw new NullPointerException("value for tab set to null");
+ }
+ this._name = value;
+ }
+
+ /**
+ * @return Returns the switchType.
+ */
+ public String getSwitchType() {
+ return _switchType;
+ }
+
+ /**
+ * @param switchType The switchType to set.
+ */
+ public void setSwitchType(String switchType) {
+ _switchType = switchType;
+ }
+
+ /**
+ * @return Returns the title.
+ */
+ public String getTitle() {
+ return _title;
+ }
+
+ /**
+ * @param newvalue The title to set.
+ */
+ public void setTitle(String newvalue) {
+ this._title = newvalue;
+ }
}
Modified: trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
===================================================================
--- trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-04-11 11:08:17 UTC (rev 351)
+++ trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-04-11 12:09:18 UTC (rev 352)
@@ -75,16 +75,17 @@
form.setId("form");
facesContext.getViewRoot().getChildren().add(form);
- tabPanel = (HtmlTabPanel)application.createComponent("org.richfaces.TabPanel");
+ tabPanel = (UITabPanel)application.createComponent("org.richfaces.TabPanel");
tabPanel.setId("tabPanel");
form.getChildren().add(tabPanel);
- tab1 = (HtmlTab)application.createComponent("org.richfaces.Tab");
+ tab1 = (UITab)application.createComponent("org.richfaces.Tab");
tab1.setId("tab1");
tabPanel.getChildren().add(tab1);
- tab2 = (HtmlTab)application.createComponent("org.richfaces.Tab");
+ tab2 = (UITab)application.createComponent("org.richfaces.Tab");
tab2.setId("tab2");
+ tab2.setActive(false);
tabPanel.getChildren().add(tab2);
}
Added: trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/UITabTest.java
===================================================================
--- trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/UITabTest.java (rev 0)
+++ trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/UITabTest.java 2007-04-11 12:09:18 UTC (rev 352)
@@ -0,0 +1,91 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.html.HtmlTabPanel;
+import org.richfaces.component.html.HtmlTab;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+
+/**
+ * Unit test for UITabTest.
+ */
+public class UITabTest extends AbstractAjax4JsfTestCase {
+
+ private UITab tab;
+ private UITabPanel tabPanel;
+ private UIForm form;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public UITabTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ tab = (UITab)application.createComponent("org.richfaces.Tab");
+ tab.setId("tab");
+
+ tabPanel = (UITabPanel)application.createComponent("org.richfaces.TabPanel");
+
+ form = new HtmlForm();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ tab = null;
+ tabPanel = null;
+ form = null;
+ }
+
+ public void testGetPane1() throws Exception {
+ assertNull(tab.getPane());
+
+ tabPanel.getChildren().add(tab);
+ assertTrue(tab.getPane() instanceof UITabPanel);
+ }
+
+ public void testGetPane2() throws Exception {
+ assertNull(tab.getPane());
+
+ form.getChildren().add(tab);
+
+ try {
+ tab.getPane();
+ assertTrue(false);
+ } catch(Exception ex) {
+ }
+ }
+}
Added: trunk/richfaces/tabPanel/src/test/java/org/richfaces/model/TabTest.java
===================================================================
--- trunk/richfaces/tabPanel/src/test/java/org/richfaces/model/TabTest.java (rev 0)
+++ trunk/richfaces/tabPanel/src/test/java/org/richfaces/model/TabTest.java 2007-04-11 12:09:18 UTC (rev 352)
@@ -0,0 +1,115 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+/**
+ * Unit test for Tab.
+ */
+public class TabTest extends AbstractAjax4JsfTestCase {
+
+ private Tab tab;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public TabTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ tab = null;
+ }
+
+ public void testTab1() throws Exception {
+ tab = new Tab();
+
+ assertNull(tab.getName());
+ try {
+ tab.setName(null);
+ assertTrue(false);
+ } catch(Exception ex) {
+ }
+ tab.setName("name");
+ assertEquals("name", tab.getName());
+
+ tab.setLabel("label");
+ assertEquals("label", tab.getLabel());
+
+ tab.setDisabled(true);
+ assertTrue(tab.isDisabled());
+
+ tab.setLabelWidth("labelWidth");
+ assertEquals("labelWidth", tab.getLabelWidth());
+
+ tab.setSwitchType("switchType");
+ assertEquals("switchType", tab.getSwitchType());
+
+ tab.setTitle("title");
+ assertEquals("title", tab.getTitle());
+ }
+
+ public void testTab2() throws Exception {
+ tab = new Tab("name");
+ assertEquals("name", tab.getName());
+ assertEquals("name", tab.getLabel());
+ assertFalse(tab.isDisabled());
+ assertNull(tab.getLabelWidth());
+ assertNull(tab.getSwitchType());
+ assertNull(tab.getTitle());
+
+ try {
+ tab = new Tab(null);
+ assertTrue(false);
+ } catch(NullPointerException ex) {
+ }
+ }
+
+ public void testTab3() throws Exception {
+ tab = new Tab("name", "label", true, "labelWidth", "title");
+ assertEquals("name", tab.getName());
+ assertEquals("label", tab.getLabel());
+ assertTrue(tab.isDisabled());
+ assertEquals("labelWidth", tab.getLabelWidth());
+ assertEquals("title", tab.getTitle());
+ assertNull(tab.getSwitchType());
+ }
+
+ public void testTab4() throws Exception {
+ tab = new Tab();
+ assertTrue(tab instanceof TabModel);
+ }
+}
19 years
JBoss Rich Faces SVN: r351 - trunk/richfaces/toolBar/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-11 07:08:17 -0400 (Wed, 11 Apr 2007)
New Revision: 351
Added:
trunk/richfaces/toolBar/src/test/java/org/richfaces/component/UIToolBarGroupTest.java
Log:
test updated
Added: trunk/richfaces/toolBar/src/test/java/org/richfaces/component/UIToolBarGroupTest.java
===================================================================
--- trunk/richfaces/toolBar/src/test/java/org/richfaces/component/UIToolBarGroupTest.java (rev 0)
+++ trunk/richfaces/toolBar/src/test/java/org/richfaces/component/UIToolBarGroupTest.java 2007-04-11 11:08:17 UTC (rev 351)
@@ -0,0 +1,89 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+
+/**
+ * Unit test for UIToolBarGroup.
+ */
+public class UIToolBarGroupTest extends AbstractAjax4JsfTestCase {
+
+ private UIToolBarGroup toolBarGroup;
+ private UIToolBar toolBar;
+ private UIForm form;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public UIToolBarGroupTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ toolBar = (UIToolBar)application.createComponent("org.richfaces.ToolBar");
+ toolBar.setId("toolBar");
+
+ toolBarGroup = (UIToolBarGroup)application.createComponent("org.richfaces.ToolBarGroup");
+
+ form = new HtmlForm();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ toolBarGroup = null;
+ toolBar = null;
+ form = null;
+ }
+
+ public void testGetToolBar1() throws Exception {
+ assertNull(toolBarGroup.getToolBar());
+
+ toolBar.getChildren().add(toolBarGroup);
+ assertTrue(toolBarGroup.getToolBar() instanceof UIToolBar);
+ }
+
+ public void testGetToolBar2() throws Exception {
+ assertNull(toolBarGroup.getToolBar());
+
+ form.getChildren().add(toolBarGroup);
+
+ try {
+ toolBarGroup.getToolBar();
+ assertTrue(false);
+ } catch(Exception ex) {
+ }
+ }
+}
19 years
JBoss Rich Faces SVN: r350 - in trunk/richfaces/suggestionbox/src/test/java/org/richfaces: component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-11 06:40:30 -0400 (Wed, 11 Apr 2007)
New Revision: 350
Added:
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/AjaxSuggestionEventTest.java
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionEventTest.java
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/renderkit/
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/renderkit/html/
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/renderkit/html/SuggestionBoxRendererTest.java
Log:
test updated
Added: trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/AjaxSuggestionEventTest.java
===================================================================
--- trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/AjaxSuggestionEventTest.java (rev 0)
+++ trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/AjaxSuggestionEventTest.java 2007-04-11 10:40:30 UTC (rev 350)
@@ -0,0 +1,72 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+/**
+ * Unit test for AjaxSuggestionEvent.
+ */
+public class AjaxSuggestionEventTest extends AbstractAjax4JsfTestCase {
+
+ private AjaxSuggestionEvent event1;
+ private AjaxSuggestionEvent event2;
+ private UISuggestionBox sb;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public AjaxSuggestionEventTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ sb = (UISuggestionBox)application.createComponent("org.richfaces.SuggestionBox");
+ event1 = new AjaxSuggestionEvent(sb);
+ event2 = new AjaxSuggestionEvent(sb, "VALUE2");
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ event1 = null;
+ event2 = null;
+ sb = null;
+ }
+
+ public void testEvent() throws Exception {
+ assertNull(event1.getSubmittedValue());
+ event1.setSubmittedValue("VALUE1");
+ assertEquals("VALUE1", event1.getSubmittedValue());
+
+ assertEquals("VALUE2", event2.getSubmittedValue());
+ }
+}
Added: trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionEventTest.java
===================================================================
--- trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionEventTest.java (rev 0)
+++ trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionEventTest.java 2007-04-11 10:40:30 UTC (rev 350)
@@ -0,0 +1,72 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+/**
+ * Unit test for SuggestionEvent.
+ */
+public class SuggestionEventTest extends AbstractAjax4JsfTestCase {
+
+ private SuggestionEvent event1;
+ private SuggestionEvent event2;
+ private UISuggestionBox sb;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public SuggestionEventTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ sb = (UISuggestionBox)application.createComponent("org.richfaces.SuggestionBox");
+ event1 = new SuggestionEvent(sb);
+ event2 = new SuggestionEvent(sb, "VALUE2");
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ event1 = null;
+ event2 = null;
+ sb = null;
+ }
+
+ public void testEvent() throws Exception {
+ assertNull(event1.getSubmittedValue());
+ event1.setSubmittedValue("VALUE1");
+ assertEquals("VALUE1", event1.getSubmittedValue());
+
+ assertEquals("VALUE2", event2.getSubmittedValue());
+ }
+}
Added: trunk/richfaces/suggestionbox/src/test/java/org/richfaces/renderkit/html/SuggestionBoxRendererTest.java
===================================================================
--- trunk/richfaces/suggestionbox/src/test/java/org/richfaces/renderkit/html/SuggestionBoxRendererTest.java (rev 0)
+++ trunk/richfaces/suggestionbox/src/test/java/org/richfaces/renderkit/html/SuggestionBoxRendererTest.java 2007-04-11 10:40:30 UTC (rev 350)
@@ -0,0 +1,117 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UISuggestionBox;
+
+/**
+ * Unit test for SuggestionBox renderer.
+ */
+public class SuggestionBoxRendererTest extends AbstractAjax4JsfTestCase {
+
+ private SuggestionBoxRenderer renderer;
+ private UISuggestionBox sb;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public SuggestionBoxRendererTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ renderer = new SuggestionBoxRenderer();
+ sb = (UISuggestionBox)application.createComponent("org.richfaces.SuggestionBox");
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ renderer = null;
+ }
+
+ public void testOpacityStyle() throws Exception {
+ String opacity = renderer.opacityStyle(facesContext, sb);
+ assertEquals("opacity:0.1; filter:alpha(opacity=10);", opacity);
+
+ sb.getAttributes().put("shadowOpacity", "3");
+ opacity = renderer.opacityStyle(facesContext, sb);
+ assertEquals("opacity:0.3; filter:alpha(opacity=30);", opacity);
+ }
+
+ public void testBorder() throws Exception {
+ String border = renderer.border(facesContext, sb);
+ assertEquals("; border-width: null null null null ;", border);
+
+ sb.getAttributes().put("border", "3");
+ border = renderer.border(facesContext, sb);
+ assertEquals("; border-width: 3px 3px 3px 3px ;", border);
+ }
+
+ public void testBgcolor() throws Exception {
+ String bgcolor = renderer.bgcolor(facesContext, sb);
+ assertEquals(";", bgcolor);
+
+ sb.getAttributes().put("bgcolor", "red");
+ bgcolor = renderer.bgcolor(facesContext, sb);
+ assertEquals("background-color: red;", bgcolor);
+ }
+
+ public void testCellPadding() throws Exception {
+ String cellPadding = renderer.cellPadding(facesContext, sb);
+ assertEquals(";", cellPadding);
+
+ sb.setCellpadding("10");
+ cellPadding = renderer.cellPadding(facesContext, sb);
+ assertEquals("padding: 10px;", cellPadding);
+ }
+
+ public void testContentId() throws Exception {
+ sb.setId("suggestionBox");
+ String contentId = renderer.getContentId(facesContext, sb);
+ assertEquals("suggestionBox:suggest", contentId);
+ }
+
+ public void testOverflowSize() throws Exception {
+ String overflowSize = renderer.overflowSize(facesContext, sb);
+ assertEquals("width:196px;height:196px;", overflowSize);
+ }
+
+ public void testShadowDepth() throws Exception {
+ String shadowDepth = renderer.shadowDepth(facesContext, sb);
+ assertEquals("top: 4; left: 4", shadowDepth);
+
+ sb.getAttributes().put("shadowDepth", "2");
+ shadowDepth = renderer.shadowDepth(facesContext, sb);
+ assertEquals("top: 2; left: 2", shadowDepth);
+ }
+}
19 years
JBoss Rich Faces SVN: r349 - in trunk/richfaces/separator/src: test/java/org/richfaces and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-11 05:43:26 -0400 (Wed, 11 Apr 2007)
New Revision: 349
Added:
trunk/richfaces/separator/src/test/java/org/richfaces/renderkit/
trunk/richfaces/separator/src/test/java/org/richfaces/renderkit/html/
trunk/richfaces/separator/src/test/java/org/richfaces/renderkit/html/SeparatorRendererTest.java
Modified:
trunk/richfaces/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java
trunk/richfaces/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java
Log:
test updated
Modified: trunk/richfaces/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java
===================================================================
--- trunk/richfaces/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java 2007-04-10 17:35:06 UTC (rev 348)
+++ trunk/richfaces/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java 2007-04-11 09:43:26 UTC (rev 349)
@@ -22,91 +22,90 @@
package org.richfaces.renderkit.html;
-import java.io.IOException;
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.richfaces.component.UISeparator;
+import org.richfaces.renderkit.html.images.BevelSeparatorImage;
+import org.richfaces.renderkit.html.images.SimpleSeparatorImage;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import java.io.IOException;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.util.HtmlDimensions;
+public class SeparatorRendererBase extends RendererBase {
-import org.richfaces.component.UISeparator;
-import org.richfaces.renderkit.html.images.BevelSeparatorImage;
-import org.richfaces.renderkit.html.images.SimpleSeparatorImage;
+ private static final String[] SUPPORTED_TYPES = {
+ UISeparator.LINE_TYPE_BEVEL,
+ UISeparator.LINE_TYPE_DASHED,
+ UISeparator.LINE_TYPE_DOTTED,
+ UISeparator.LINE_TYPE_DOUBLE,
+ UISeparator.LINE_TYPE_SOLID
+ };
-public class SeparatorRendererBase extends RendererBase {
-
- private static final String[] SUPPORTED_TYPES = {
- UISeparator.LINE_TYPE_BEVEL ,
- UISeparator.LINE_TYPE_DASHED,
- UISeparator.LINE_TYPE_DOTTED,
- UISeparator.LINE_TYPE_DOUBLE,
- UISeparator.LINE_TYPE_SOLID
- };
-
- private String getCSSDimension(UIComponent component, String attributeName, String defaultValue) {
- Object hO = component.getAttributes().get(attributeName);
- String height;
- if (hO == null) {
- height = defaultValue;
- } else if (hO instanceof String ) {
- height = (String) hO;
- if (height.trim().length() == 0) {
- height = defaultValue;
- }
- } else {
- height = hO.toString();
- }
- return getUtils().encodePctOrPx(height);
- }
-
- protected Class getComponentClass() {
- return UISeparator.class;
- }
+ private String getCSSDimension(UIComponent component, String attributeName, String defaultValue) {
+ Object hO = component.getAttributes().get(attributeName);
+ String height;
+ if (hO == null) {
+ height = defaultValue;
+ } else if (hO instanceof String) {
+ height = (String) hO;
+ if (height.trim().length() == 0) {
+ height = defaultValue;
+ }
+ } else {
+ height = hO.toString();
+ }
+ return getUtils().encodePctOrPx(height);
+ }
- public boolean getRendersChildren() {
- return true;
- }
-
- private boolean isSupportedLineType(String lineType) {
- for (int i = 0; i < SUPPORTED_TYPES.length; i++){
- if (lineType.equalsIgnoreCase(SUPPORTED_TYPES[i])) return true;
- }
- return false;
- }
+ protected Class getComponentClass() {
+ return UISeparator.class;
+ }
- public String backgroundImage(FacesContext context, UIComponent component) throws IOException {
- UISeparator separator = (UISeparator) component;
- String lineType = separator.getLineType();
- if (! isSupportedLineType(lineType)) {
- lineType = UISeparator.LINE_TYPE_BEVEL;
- }
- String height = getCSSDimension(component, "height", UISeparator.DEFAULT_HEIGHT);
- if (height.trim().endsWith("%")) throw new FacesException("It is not allowed to set height of separator in percent (component "+component.getId()+")!");
- int h = HtmlDimensions.decode(height).intValue();
-
- if(lineType == null || lineType.trim().length() == 0){
- lineType = UISeparator.LINE_TYPE_BEVEL;
- }
- //XXX by nick - fantonov - equalsIgnoreCase here?
- if(lineType.equalsIgnoreCase(UISeparator.LINE_TYPE_BEVEL) && h < 3 ){
- lineType = UISeparator.LINE_TYPE_SOLID;
- }
- String uri = null;
- if (lineType.equalsIgnoreCase(UISeparator.LINE_TYPE_BEVEL)) {
- uri = getResource(BevelSeparatorImage.class.getName()).getUri(context, component);
- } else {
- uri = getResource(SimpleSeparatorImage.class.getName()).getUri(context, component);
- }
- return uri;
- }
-
- public String getHeight(FacesContext context, UIComponent component) {
- return getCSSDimension(component, "height", UISeparator.DEFAULT_HEIGHT);
- }
+ public boolean getRendersChildren() {
+ return true;
+ }
- public String getWidth(FacesContext context, UIComponent component) {
- return getCSSDimension(component, "width", UISeparator.DEFAULT_WIDTH);
- }
+ protected boolean isSupportedLineType(String lineType) {
+ for (int i = 0; i < SUPPORTED_TYPES.length; i++) {
+ if (lineType.equalsIgnoreCase(SUPPORTED_TYPES[i])) return true;
+ }
+ return false;
+ }
+
+ public String backgroundImage(FacesContext context, UIComponent component) throws IOException {
+ UISeparator separator = (UISeparator) component;
+ String lineType = separator.getLineType();
+ if (! isSupportedLineType(lineType)) {
+ lineType = UISeparator.LINE_TYPE_BEVEL;
+ }
+ String height = getHeight(context, component);
+ if (height.trim().endsWith("%"))
+ throw new FacesException("It is not allowed to set height of separator in percent (component " + component.getId() + ")!");
+ int h = HtmlDimensions.decode(height).intValue();
+
+ if (lineType == null || lineType.trim().length() == 0) {
+ lineType = UISeparator.LINE_TYPE_BEVEL;
+ }
+ //XXX by nick - fantonov - equalsIgnoreCase here?
+ if (lineType.equalsIgnoreCase(UISeparator.LINE_TYPE_BEVEL) && h < 3) {
+ lineType = UISeparator.LINE_TYPE_SOLID;
+ }
+ String uri = null;
+ if (lineType.equalsIgnoreCase(UISeparator.LINE_TYPE_BEVEL)) {
+ uri = getResource(BevelSeparatorImage.class.getName()).getUri(context, component);
+ } else {
+ uri = getResource(SimpleSeparatorImage.class.getName()).getUri(context, component);
+ }
+ return uri;
+ }
+
+ public String getHeight(FacesContext context, UIComponent component) {
+ return getCSSDimension(component, "height", UISeparator.DEFAULT_HEIGHT);
+ }
+
+ public String getWidth(FacesContext context, UIComponent component) {
+ return getCSSDimension(component, "width", UISeparator.DEFAULT_WIDTH);
+ }
}
Modified: trunk/richfaces/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java
===================================================================
--- trunk/richfaces/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java 2007-04-10 17:35:06 UTC (rev 348)
+++ trunk/richfaces/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java 2007-04-11 09:43:26 UTC (rev 349)
@@ -24,6 +24,7 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.renderkit.html.SeparatorRendererBase;
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
@@ -60,15 +61,15 @@
facesContext.getViewRoot().getChildren().add(form);
- out1 = (UIOutput)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
+ out1 = (UIOutput) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
out1.setValue("output1");
form.getChildren().add(out1);
- ui = (UISeparator)application.createComponent("org.richfaces.separator");
+ ui = (UISeparator) application.createComponent("org.richfaces.separator");
ui.setId("separator");
form.getChildren().add(ui);
- out2 = (UIOutput)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
+ out2 = (UIOutput) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
out2.setValue("output2");
form.getChildren().add(out2);
}
@@ -98,7 +99,7 @@
assertNotNull(div1);
assertEquals("div", div1.getNodeName());
- HtmlElement div2 = (HtmlElement)div1.getHtmlElementsByTagName("div").get(0);
+ HtmlElement div2 = (HtmlElement) div1.getHtmlElementsByTagName("div").get(0);
String classAttr = div2.getAttributeValue("class");
assertTrue(classAttr.contains("rich-separator"));
String styleAttr = div2.getAttributeValue("style");
Added: trunk/richfaces/separator/src/test/java/org/richfaces/renderkit/html/SeparatorRendererTest.java
===================================================================
--- trunk/richfaces/separator/src/test/java/org/richfaces/renderkit/html/SeparatorRendererTest.java (rev 0)
+++ trunk/richfaces/separator/src/test/java/org/richfaces/renderkit/html/SeparatorRendererTest.java 2007-04-11 09:43:26 UTC (rev 349)
@@ -0,0 +1,107 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UISeparator;
+
+/**
+ * Unit test for SeparatorRenderer.
+ */
+public class SeparatorRendererTest extends AbstractAjax4JsfTestCase {
+
+ private static final String[] SUPPORTED_TYPES = {
+ UISeparator.LINE_TYPE_BEVEL,
+ UISeparator.LINE_TYPE_DASHED,
+ UISeparator.LINE_TYPE_DOTTED,
+ UISeparator.LINE_TYPE_DOUBLE,
+ UISeparator.LINE_TYPE_SOLID
+ };
+
+ private SeparatorRendererBase renderer;
+ private UISeparator ui;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public SeparatorRendererTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ renderer = new SeparatorRendererBase();
+ ui = (UISeparator) application.createComponent("org.richfaces.separator");
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ renderer = null;
+ ui = null;
+ }
+
+ public void testSupportedTypes() throws Exception {
+ for (int i = 0; i < SUPPORTED_TYPES.length; i++) {
+ assertEquals(true, renderer.isSupportedLineType(SUPPORTED_TYPES[i]));
+ }
+
+ boolean notSupported = renderer.isSupportedLineType("UNDEFINED");
+ assertFalse(notSupported);
+ }
+
+ public void testBackgroundImage() throws Exception {
+ assertEquals(UISeparator.LINE_TYPE_BEVEL, ui.getLineType());
+ ui.setLineType("UNDEFINED");
+ String uri = renderer.backgroundImage(facesContext, ui);
+ assertTrue(uri.contains("org.richfaces.renderkit.html.images.BevelSeparatorImage"));
+
+ ui.setLineType(UISeparator.LINE_TYPE_BEVEL);
+ uri = renderer.backgroundImage(facesContext, ui);
+ assertTrue(uri.contains("org.richfaces.renderkit.html.images.BevelSeparatorImage"));
+
+ ui.setLineType(UISeparator.LINE_TYPE_DOTTED);
+ uri = renderer.backgroundImage(facesContext, ui);
+ assertTrue(uri.contains("org.richfaces.renderkit.html.images.SimpleSeparatorImage"));
+
+ ui.setLineType(UISeparator.LINE_TYPE_BEVEL);
+ ui.setHeight("10%");
+ try {
+ uri = renderer.backgroundImage(facesContext, ui);
+ assertTrue(false);
+ } catch(Exception ex) {
+ }
+
+ ui.setLineType(UISeparator.LINE_TYPE_BEVEL);
+ ui.setHeight("2");
+ assertTrue(uri.contains("org.richfaces.renderkit.html.images.SimpleSeparatorImage"));
+ }
+}
19 years