View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.custom.toggle;
20  
21  import javax.faces.component.UIComponent;
22  import javax.faces.component.html.HtmlForm;
23  
24  import org.apache.myfaces.component.behavior.AbstractClientBehaviorTestCase;
25  import org.apache.myfaces.component.behavior.HtmlClientEventAttributesUtil;
26  import org.apache.myfaces.component.behavior.HtmlRenderedClientEventAttr;
27  import org.apache.myfaces.component.html.ext.HtmlInputText;
28  import org.apache.myfaces.shared_tomahawk.renderkit.ClientBehaviorEvents;
29  import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
30  import org.apache.myfaces.shared_tomahawk.util.ArrayUtils;
31  
32  /**
33   * @author Leonardo Uribe (latest modification by $Author: jankeesvanandel $)
34   * @version $Revision: 799929 $ $Date: 2009-08-01 16:29:33 -0500 (sáb, 01 ago 2009) $
35   */
36  public class ToggleLinkClientBehaviorRendererTest extends AbstractClientBehaviorTestCase
37  {
38      private HtmlRenderedClientEventAttr[] attrs = null;
39      
40      @Override
41      public void setUp() throws Exception
42      {
43          super.setUp();
44          attrs =  (HtmlRenderedClientEventAttr[]) 
45                  ArrayUtils.concat(HtmlClientEventAttributesUtil.generateClientBehaviorEventAttrs(),
46                  new HtmlRenderedClientEventAttr[]{
47                      new HtmlRenderedClientEventAttr(HTML.ONFOCUS_ATTR, ClientBehaviorEvents.FOCUS),
48                      new HtmlRenderedClientEventAttr(HTML.ONBLUR_ATTR, ClientBehaviorEvents.BLUR)
49                  });
50      }
51      
52      @Override
53      public void tearDown() throws Exception
54      {
55          super.tearDown();
56          attrs = null;
57      }
58  
59      @Override
60      protected UIComponent createComponentToTest()
61      {
62          ToggleLink component = new ToggleLink();
63          TogglePanel panel = new TogglePanel();
64          UIComponent form = new HtmlForm();
65          HtmlInputText inputText = new HtmlInputText();
66          inputText.setId("comp1");
67          component.setFor("comp1");
68          form.getChildren().add(panel);
69          panel.getChildren().add(component);
70          panel.getChildren().add(inputText);
71          facesContext.getViewRoot().getChildren().add(form);
72          return component;
73      }
74  
75      @Override
76      protected HtmlRenderedClientEventAttr[] getClientBehaviorHtmlRenderedAttributes()
77      {
78          return attrs;
79      }
80  }