You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2016/09/16 17:17:00 UTC

svn commit: r1761064 - in /myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src: main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java test/java/org/apache/myfaces/tobago/renderkit/html/CssClassCompareUnitTest.java

Author: lofwyr
Date: Fri Sep 16 17:17:00 2016
New Revision: 1761064

URL: http://svn.apache.org/viewvc?rev=1761064&view=rev
Log:
TOBAGO-1600: Update Bootstrap to 4.0.0 alpha 4 (from alpha 3)
* add CssClassCompareUnitTest() which compare tobago.css with
TobagoClass.java and bootstrap.css with BootstrapClass
[developed by hnoeth]

Added:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/CssClassCompareUnitTest.java
Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java?rev=1761064&r1=1761063&r2=1761064&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java Fri Sep 16 17:17:00 2016
@@ -53,7 +53,6 @@ public enum BootstrapClass implements Cs
   CARD_TITLE("card-title"),
   CLOSE("close"),
   COLLAPSE("collapse"),
-  COLLAPSED("collapsed"),
   COL_FORM_LABEL("col-form-label"),
   COL_LG_1("col-lg-1"),
   COL_LG_2("col-lg-2"),
@@ -105,7 +104,6 @@ public enum BootstrapClass implements Cs
   COL_XS_12("col-xs-12"),
   CONTAINER("container"),
   CONTAINER_FLUID("container-fluid"),
-  DANGER("danger"),
   DISABLED("disabled"),
   DROPDOWN("dropdown"),
   DROPDOWN_ITEM("dropdown-item"),
@@ -123,7 +121,6 @@ public enum BootstrapClass implements Cs
   HAS_SUCCESS("has-success"),
   HAS_WARNING("has-warning"),
   HIDDEN_SM_UP("hidden-sm-up"),
-  ICON_BAR("icon-bar"),
   INPUT_GROUP("input-group"),
   INPUT_GROUP_ADDON("input-group-addon"),
   INPUT_GROUP_BTN("input-group-btn"),
@@ -137,8 +134,6 @@ public enum BootstrapClass implements Cs
   NAV_TABS("nav-tabs"),
   NAVBAR("navbar"),
   NAVBAR_BRAND("navbar-brand"),
-  NAVBAR_BTN("navbar-btn"),
-  NAVBAR_COLLAPSE("navbar-collapse"),
   NAVBAR_DARK("navbar-dark"),
   NAVBAR_FIXED_BOTTOM("navbar-fixed-bottom"),
   NAVBAR_FIXED_TOP("navbar-fixed-top"),
@@ -150,7 +145,6 @@ public enum BootstrapClass implements Cs
   PAGE_LINK("page-link"),
   PAGINATION("pagination"),
   PROGRESS("progress"),
-  RADIO("radio"),
   ROW("row"),
   SR_ONLY("sr-only"),
   TAB_CONTENT("tab-content"),
@@ -161,8 +155,7 @@ public enum BootstrapClass implements Cs
   TABLE_INFO("table-info"),
   TABLE_INVERSE("table-inverse"),
   TABLE_SM("table-sm"),
-  TABLE_STRIPED("table-striped"),
-  WARNING("warning");
+  TABLE_STRIPED("table-striped");
 
   private static final int SEVERITY_ERROR = FacesMessage.SEVERITY_ERROR.getOrdinal();
   private static final int SEVERITY_WARN = FacesMessage.SEVERITY_WARN.getOrdinal();

Added: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/CssClassCompareUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/CssClassCompareUnitTest.java?rev=1761064&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/CssClassCompareUnitTest.java (added)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/CssClassCompareUnitTest.java Fri Sep 16 17:17:00 2016
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.renderkit.html;
+
+import org.apache.myfaces.tobago.internal.config.AbstractTobagoTestBase;
+import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
+import org.apache.myfaces.tobago.renderkit.css.CssItem;
+import org.apache.myfaces.tobago.renderkit.css.TobagoClass;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+public class CssClassCompareUnitTest extends AbstractTobagoTestBase {
+
+  @Test
+  public void testCompareBootstapCss() throws FileNotFoundException {
+    File bootstrapCss = new File(
+        "src/main/resources/org/apache/myfaces/"
+            + "tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.4/css/bootstrap.css");
+    compareCss(bootstrapCss, BootstrapClass.values());
+  }
+
+  @Test
+  public void testCompareTobagoCss() throws FileNotFoundException {
+    File tobagoCss = new File(
+        "src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css");
+
+    List<CssItem> classNames = new ArrayList<CssItem>();
+    for (TobagoClass value : TobagoClass.values()) {
+      if (!value.getName().startsWith("tobago-")) {
+        classNames.add(value);
+      }
+    }
+
+    compareCss(tobagoCss, classNames.toArray(new CssItem[classNames.size()]));
+  }
+
+  private void compareCss(File cssFile, CssItem[] cssItems) throws FileNotFoundException {
+    Assert.assertTrue(cssFile.exists());
+
+    String fileContent = new Scanner(cssFile).useDelimiter("\\Z").next();
+
+    for (CssItem cssItem : cssItems) {
+      final String className = cssItem.getName();
+
+      Assert.assertTrue("'" + className + "' exist in " + cssItem.getClass().getName() + " but not in "
+              + cssFile.getName(),
+          containsClassName(fileContent, className));
+    }
+  }
+
+  private boolean containsClassName(String content, String className) {
+    return content.contains("." + className + " ")
+        || content.contains("." + className + "{")
+        || content.contains("." + className + ",")
+        || content.contains("." + className + ":")
+        || content.contains("." + className + ".")
+        || content.contains("." + className + ">");
+  }
+}