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.component.html.ext.behavior;
20  
21  import javax.faces.component.UIComponent;
22  
23  import org.apache.myfaces.application.NavigationHandlerImpl;
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.HtmlCommandButton;
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 HtmlCommandButtonClientBehaviorRendererTest 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                      new HtmlRenderedClientEventAttr(HTML.ONSELECT_ATTR, ClientBehaviorEvents.SELECT),
50                      new HtmlRenderedClientEventAttr(HTML.ONCHANGE_ATTR, ClientBehaviorEvents.CHANGE),
51                      new HtmlRenderedClientEventAttr(HTML.ONCLICK_ATTR, ClientBehaviorEvents.ACTION)
52                  });
53      }
54      
55      
56  
57      @Override
58      protected void setUpApplication() throws Exception
59      {
60          super.setUpApplication();
61          application.setNavigationHandler(new NavigationHandlerImpl());
62      }
63  
64      @Override
65      public void tearDown() throws Exception
66      {
67          super.tearDown();
68          attrs = null;
69      }
70  
71      @Override
72      protected UIComponent createComponentToTest()
73      {
74          return new HtmlCommandButton();
75      }
76  
77      @Override
78      protected HtmlRenderedClientEventAttr[] getClientBehaviorHtmlRenderedAttributes()
79      {
80          return attrs;
81      }
82  }