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  
20  package org.apache.myfaces.tobago.renderkit.html;
21  
22  import org.junit.Assert;
23  import org.junit.Test;
24  
25  @SuppressWarnings("deprecation")
26  public class StyleClassesUnitTest {
27  
28    @Test
29    public void testRemoveOneMatch() {
30      StyleClasses c = new StyleClasses();
31      c.addFullQualifiedClass("bla");
32      c.addFullQualifiedClass("tobago-test-inline");
33      c.addFullQualifiedClass("blupp");
34      c.removeTobagoClasses("test");
35      Assert.assertEquals("bla blupp", c.toString());
36    }
37  
38    @Test
39    public void testRemoveNoMatch() {
40      StyleClasses c = new StyleClasses();
41      c.addFullQualifiedClass("bla");
42      c.addFullQualifiedClass("tobago-test-inline");
43      c.addFullQualifiedClass("blupp");
44      c.removeTobagoClasses("no");
45      Assert.assertEquals("bla tobago-test-inline blupp", c.toString());
46    }
47  
48    @Test
49    public void testRemoveEmpty() {
50      StyleClasses c = new StyleClasses();
51      c.removeTobagoClasses("no");
52      Assert.assertEquals(null, c.toString());
53    }
54  
55    @Test
56    public void testAddMarkupClass() {
57      StyleClasses c = new StyleClasses();
58      c.addMarkupClass("myComponent", "big");
59      Assert.assertEquals("tobago-myComponent-markup-big", c.toString());
60      c.removeMarkupClass("myComponent", "big");
61      Assert.assertEquals(null, c.toString());
62    }
63  
64    @Test
65    public void testAddMarkupClassSub() {
66      StyleClasses c = new StyleClasses();
67      c.addMarkupClass("myComponent", "mySub", "big");
68      Assert.assertEquals("tobago-myComponent-mySub-markup-big", c.toString());
69      c.removeMarkupClass("myComponent", "mySub", "big");
70      Assert.assertEquals(null, c.toString());
71    }
72  
73    @Test
74    public void testAddAspectClass() {
75      StyleClasses c = new StyleClasses();
76      c.addAspectClass("myComponent", StyleClasses.Aspect.DISABLED);
77      Assert.assertEquals("tobago-myComponent-disabled", c.toString());
78      c.removeAspectClass("myComponent", StyleClasses.Aspect.DISABLED);
79      Assert.assertEquals(null, c.toString());
80    }
81  
82    @Test
83    public void testAddAspectClassSub() {
84      StyleClasses c = new StyleClasses();
85      c.addAspectClass("myComponent", "mySub", StyleClasses.Aspect.DISABLED);
86      Assert.assertEquals("tobago-myComponent-mySub-disabled", c.toString());
87      c.removeAspectClass("myComponent", "mySub", StyleClasses.Aspect.DISABLED);
88      Assert.assertEquals(null, c.toString());
89    }
90  
91  }