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 2020/10/23 18:39:34 UTC

[myfaces-tobago] 08/13: tests

This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit 2801de2238ae9eccdcb3d9c2a8bbeffe280f9419
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Fri Oct 23 12:59:55 2020 +0200

    tests
---
 .../internal/config/AbstractTobagoTestBase.java    |   6 ++
 .../renderkit/renderer/InRendererUnitTest.java     | 116 +++++++++++++++++++++
 .../renderer/in/input-group-button-after.html      |  29 ++++++
 .../renderer/in/input-group-button-before.html     |  29 ++++++
 .../renderer/in/input-group-dropdown-after.html    |  37 +++++++
 .../renderer/in/input-group-dropdown-before.html   |  37 +++++++
 .../renderer/in/input-group-out-after.html         |  27 +++++
 .../renderer/in/input-group-out-before.html        |  27 +++++
 8 files changed, 308 insertions(+)

diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java
index 3e34049..f1fb08b 100644
--- a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java
@@ -40,6 +40,8 @@ import org.apache.myfaces.tobago.component.UISeparator;
 import org.apache.myfaces.tobago.component.UIStyle;
 import org.apache.myfaces.tobago.context.TobagoContext;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.BadgeRenderer;
+import org.apache.myfaces.tobago.internal.renderkit.renderer.ButtonInsideInAfterRenderer;
+import org.apache.myfaces.tobago.internal.renderkit.renderer.ButtonInsideInRenderer;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.ButtonRenderer;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.ButtonsRenderer;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.GridLayoutRenderer;
@@ -47,6 +49,7 @@ import org.apache.myfaces.tobago.internal.renderkit.renderer.InRenderer;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.LinkInsideCommandRenderer;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.LinkRenderer;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.LinksRenderer;
+import org.apache.myfaces.tobago.internal.renderkit.renderer.OutInsideInRenderer;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.OutRenderer;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.PanelRenderer;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.PopupRenderer;
@@ -122,11 +125,14 @@ public abstract class AbstractTobagoTestBase extends AbstractJsfTestCase {
     final RenderKit renderKit = facesContext.getRenderKit();
     renderKit.addRenderer(UIIn.COMPONENT_FAMILY, RendererTypes.IN, new InRenderer());
     renderKit.addRenderer(UIOut.COMPONENT_FAMILY, RendererTypes.OUT, new OutRenderer());
+    renderKit.addRenderer(UIOut.COMPONENT_FAMILY, RendererTypes.OUT_INSIDE_IN, new OutInsideInRenderer());
     renderKit.addRenderer(UIPanel.COMPONENT_FAMILY, RendererTypes.PANEL, new PanelRenderer());
     renderKit.addRenderer(UILink.COMPONENT_FAMILY, RendererTypes.LINK, new LinkRenderer());
     renderKit.addRenderer(UILink.COMPONENT_FAMILY, RendererTypes.LINK_INSIDE_COMMAND, new LinkInsideCommandRenderer());
     renderKit.addRenderer(UILinks.COMPONENT_FAMILY, RendererTypes.LINKS, new LinksRenderer());
     renderKit.addRenderer(UIButton.COMPONENT_FAMILY, RendererTypes.BUTTON, new ButtonRenderer());
+    renderKit.addRenderer(UIButton.COMPONENT_FAMILY, RendererTypes.BUTTON_INSIDE_IN, new ButtonInsideInRenderer());
+    renderKit.addRenderer(UIButton.COMPONENT_FAMILY, RendererTypes.BUTTON_INSIDE_IN_AFTER, new ButtonInsideInAfterRenderer());
     renderKit.addRenderer(UIButtons.COMPONENT_FAMILY, RendererTypes.BUTTONS, new ButtonsRenderer());
     renderKit.addRenderer(UIPopup.COMPONENT_FAMILY, RendererTypes.POPUP, new PopupRenderer());
     renderKit.addRenderer(UISeparator.COMPONENT_FAMILY, RendererTypes.SEPARATOR, new SeparatorRenderer());
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRendererUnitTest.java b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRendererUnitTest.java
index f78cf7f..a2fabdf 100644
--- a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRendererUnitTest.java
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRendererUnitTest.java
@@ -22,7 +22,10 @@ package org.apache.myfaces.tobago.internal.renderkit.renderer;
 import org.apache.myfaces.tobago.component.LabelLayout;
 import org.apache.myfaces.tobago.component.RendererTypes;
 import org.apache.myfaces.tobago.component.Tags;
+import org.apache.myfaces.tobago.component.UIButton;
 import org.apache.myfaces.tobago.component.UIIn;
+import org.apache.myfaces.tobago.component.UILink;
+import org.apache.myfaces.tobago.component.UIOut;
 import org.apache.myfaces.tobago.component.UISegmentLayout;
 import org.apache.myfaces.tobago.layout.SegmentMeasureList;
 import org.apache.myfaces.tobago.util.ComponentUtils;
@@ -34,6 +37,118 @@ import java.io.IOException;
 public class InRendererUnitTest extends RendererTestBase {
 
   @Test
+  public void inputGroupButtonAfter() throws IOException {
+    final UIIn c = (UIIn) ComponentUtils.createComponent(
+        facesContext, Tags.in.componentType(), RendererTypes.In, "id");
+
+    final UIButton b = (UIButton) ComponentUtils.createComponent(
+        facesContext, Tags.button.componentType(), RendererTypes.Button, "button");
+    b.setLabel("button");
+    c.getFacets().put("after", b);
+
+    c.encodeAll(facesContext);
+
+    Assert.assertEquals(loadHtml("renderer/in/input-group-button-after.html"), formattedResult());
+  }
+
+  @Test
+  public void inputGroupButtonBefore() throws IOException {
+    final UIIn c = (UIIn) ComponentUtils.createComponent(
+        facesContext, Tags.in.componentType(), RendererTypes.In, "id");
+
+    final UIButton b = (UIButton) ComponentUtils.createComponent(
+        facesContext, Tags.button.componentType(), RendererTypes.Button, "button");
+    b.setLabel("button");
+    c.getFacets().put("before", b);
+
+    c.encodeAll(facesContext);
+
+    Assert.assertEquals(loadHtml("renderer/in/input-group-button-before.html"), formattedResult());
+  }
+
+  @Test
+  public void inputGroupDropdownAfter() throws IOException {
+    final UIIn c = (UIIn) ComponentUtils.createComponent(
+        facesContext, Tags.in.componentType(), RendererTypes.In, "id");
+
+    final UIButton d = (UIButton) ComponentUtils.createComponent(
+        facesContext, Tags.button.componentType(), RendererTypes.Button, "button");
+    d.setLabel("dropdown");
+    d.setOmit(true);
+    c.getFacets().put("after", d);
+
+    final UILink l1 = (UILink) ComponentUtils.createComponent(
+        facesContext, Tags.link.componentType(), RendererTypes.Link, "l1");
+    l1.setLabel("Link 1");
+    d.getChildren().add(l1);
+
+    final UILink l2 = (UILink) ComponentUtils.createComponent(
+        facesContext, Tags.link.componentType(), RendererTypes.Link, "l2");
+    l2.setLabel("Link 2");
+    d.getChildren().add(l2);
+
+    c.encodeAll(facesContext);
+
+    Assert.assertEquals(loadHtml("renderer/in/input-group-dropdown-after.html"), formattedResult());
+  }
+
+  @Test
+  public void inputGroupDropdownBefore() throws IOException {
+    final UIIn c = (UIIn) ComponentUtils.createComponent(
+        facesContext, Tags.in.componentType(), RendererTypes.In, "id");
+
+    final UIButton d = (UIButton) ComponentUtils.createComponent(
+        facesContext, Tags.button.componentType(), RendererTypes.Button, "button");
+    d.setLabel("dropdown");
+    d.setOmit(true);
+    c.getFacets().put("before", d);
+
+    final UILink l1 = (UILink) ComponentUtils.createComponent(
+        facesContext, Tags.link.componentType(), RendererTypes.Link, "l1");
+    l1.setLabel("Link 1");
+    d.getChildren().add(l1);
+
+    final UILink l2 = (UILink) ComponentUtils.createComponent(
+        facesContext, Tags.link.componentType(), RendererTypes.Link, "l2");
+    l2.setLabel("Link 2");
+    d.getChildren().add(l2);
+
+    c.encodeAll(facesContext);
+
+    Assert.assertEquals(loadHtml("renderer/in/input-group-dropdown-before.html"), formattedResult());
+  }
+
+  @Test
+  public void inputGroupOutAfter() throws IOException {
+    final UIIn c = (UIIn) ComponentUtils.createComponent(
+        facesContext, Tags.in.componentType(), RendererTypes.In, "id");
+
+    final UIOut o = (UIOut) ComponentUtils.createComponent(
+        facesContext, Tags.out.componentType(), RendererTypes.Out, "out");
+    o.setValue("out");
+    c.getFacets().put("after", o);
+
+    c.encodeAll(facesContext);
+
+    Assert.assertEquals(loadHtml("renderer/in/input-group-out-after.html"), formattedResult());
+  }
+
+  @Test
+  public void inputGroupOutBefore() throws IOException {
+    final UIIn c = (UIIn) ComponentUtils.createComponent(
+        facesContext, Tags.in.componentType(), RendererTypes.In, "id");
+
+    final UIOut o = (UIOut) ComponentUtils.createComponent(
+        facesContext, Tags.out.componentType(), RendererTypes.Out, "out");
+    o.setValue("out");
+    c.getFacets().put("before", o);
+
+    c.encodeAll(facesContext);
+
+    Assert.assertEquals(loadHtml("renderer/in/input-group-out-before.html"), formattedResult());
+  }
+
+  @Test
   public void simple() throws IOException {
     final UIIn c = (UIIn) ComponentUtils.createComponent(
         facesContext, Tags.in.componentType(), RendererTypes.In, "id");
@@ -198,4 +313,5 @@ public class InRendererUnitTest extends RendererTestBase {
 
     Assert.assertEquals(loadHtml("renderer/in/label-none.html"), formattedResult());
   }
+
 }
diff --git a/tobago-core/src/test/resources/renderer/in/input-group-button-after.html b/tobago-core/src/test/resources/renderer/in/input-group-button-after.html
new file mode 100644
index 0000000..532436e
--- /dev/null
+++ b/tobago-core/src/test/resources/renderer/in/input-group-button-after.html
@@ -0,0 +1,29 @@
+<!--
+ * 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.
+-->
+
+<tobago-in id='id' class='mb-3'>
+  <div class='tobago-input-group-outer'>
+    <div class='input-group'>
+      <input type='text' name='id' id='id::field' class='tobago-in form-control'>
+      <div class='input-group-append'>
+        <button type='button' id='button' name='button' class='tobago-button btn btn-secondary'>
+          <tobago-behavior event='click' decoupled='decoupled'>
+          </tobago-behavior><span>button</span></button>
+      </div>
+    </div>
+  </div>
+</tobago-in>
\ No newline at end of file
diff --git a/tobago-core/src/test/resources/renderer/in/input-group-button-before.html b/tobago-core/src/test/resources/renderer/in/input-group-button-before.html
new file mode 100644
index 0000000..41e228a
--- /dev/null
+++ b/tobago-core/src/test/resources/renderer/in/input-group-button-before.html
@@ -0,0 +1,29 @@
+<!--
+ * 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.
+-->
+
+<tobago-in id='id' class='mb-3'>
+  <div class='tobago-input-group-outer'>
+    <div class='input-group'>
+      <div class='input-group-prepend'>
+        <button type='button' id='button' name='button' class='tobago-button btn btn-secondary'>
+          <tobago-behavior event='click' decoupled='decoupled'>
+          </tobago-behavior><span>button</span></button>
+      </div>
+      <input type='text' name='id' id='id::field' class='tobago-in form-control'>
+    </div>
+  </div>
+</tobago-in>
\ No newline at end of file
diff --git a/tobago-core/src/test/resources/renderer/in/input-group-dropdown-after.html b/tobago-core/src/test/resources/renderer/in/input-group-dropdown-after.html
new file mode 100644
index 0000000..b4506a3
--- /dev/null
+++ b/tobago-core/src/test/resources/renderer/in/input-group-dropdown-after.html
@@ -0,0 +1,37 @@
+<!--
+ * 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.
+-->
+
+<tobago-in id='id' class='mb-3'>
+  <div class='tobago-input-group-outer'>
+    <div class='input-group'>
+      <input type='text' name='id' id='id::field' class='tobago-in form-control'>
+      <tobago-dropdown id='button' class='dropdown input-group-append'>
+        <button type='button' id='button::command' name='button' data-toggle='dropdown' class='tobago-button btn btn-secondary dropdown-toggle'>
+          <tobago-behavior event='click' omit='omit' decoupled='decoupled'>
+          </tobago-behavior><span>dropdown</span></button>
+        <div class='dropdown-menu dropdown-menu-right' aria-labelledby='button::command' name='button'>
+          <button type='button' id='l1' name='l1' class='tobago-link dropdown-item'>
+            <tobago-behavior event='click' decoupled='decoupled'>
+            </tobago-behavior><span>Link 1</span></button>
+          <button type='button' id='l2' name='l2' class='tobago-link dropdown-item'>
+            <tobago-behavior event='click' decoupled='decoupled'>
+            </tobago-behavior><span>Link 2</span></button>
+        </div>
+      </tobago-dropdown>
+    </div>
+  </div>
+</tobago-in>
\ No newline at end of file
diff --git a/tobago-core/src/test/resources/renderer/in/input-group-dropdown-before.html b/tobago-core/src/test/resources/renderer/in/input-group-dropdown-before.html
new file mode 100644
index 0000000..2d2c3c0
--- /dev/null
+++ b/tobago-core/src/test/resources/renderer/in/input-group-dropdown-before.html
@@ -0,0 +1,37 @@
+<!--
+ * 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.
+-->
+
+<tobago-in id='id' class='mb-3'>
+  <div class='tobago-input-group-outer'>
+    <div class='input-group'>
+      <tobago-dropdown id='button' class='dropdown input-group-prepend'>
+        <button type='button' id='button::command' name='button' data-toggle='dropdown' class='tobago-button btn btn-secondary dropdown-toggle'>
+          <tobago-behavior event='click' omit='omit' decoupled='decoupled'>
+          </tobago-behavior><span>dropdown</span></button>
+        <div class='dropdown-menu' aria-labelledby='button::command' name='button'>
+          <button type='button' id='l1' name='l1' class='tobago-link dropdown-item'>
+            <tobago-behavior event='click' decoupled='decoupled'>
+            </tobago-behavior><span>Link 1</span></button>
+          <button type='button' id='l2' name='l2' class='tobago-link dropdown-item'>
+            <tobago-behavior event='click' decoupled='decoupled'>
+            </tobago-behavior><span>Link 2</span></button>
+        </div>
+      </tobago-dropdown>
+      <input type='text' name='id' id='id::field' class='tobago-in form-control'>
+    </div>
+  </div>
+</tobago-in>
\ No newline at end of file
diff --git a/tobago-core/src/test/resources/renderer/in/input-group-out-after.html b/tobago-core/src/test/resources/renderer/in/input-group-out-after.html
new file mode 100644
index 0000000..2babb76
--- /dev/null
+++ b/tobago-core/src/test/resources/renderer/in/input-group-out-after.html
@@ -0,0 +1,27 @@
+<!--
+ * 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.
+-->
+
+<tobago-in id='id' class='mb-3'>
+  <div class='tobago-input-group-outer'>
+    <div class='input-group'>
+      <input type='text' name='id' id='id::field' class='tobago-in form-control'>
+      <div class='input-group-append'>
+        <span class='tobago-out input-group-text'>out</span>
+      </div>
+    </div>
+  </div>
+</tobago-in>
\ No newline at end of file
diff --git a/tobago-core/src/test/resources/renderer/in/input-group-out-before.html b/tobago-core/src/test/resources/renderer/in/input-group-out-before.html
new file mode 100644
index 0000000..dff49fe
--- /dev/null
+++ b/tobago-core/src/test/resources/renderer/in/input-group-out-before.html
@@ -0,0 +1,27 @@
+<!--
+ * 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.
+-->
+
+<tobago-in id='id' class='mb-3'>
+  <div class='tobago-input-group-outer'>
+    <div class='input-group'>
+      <div class='input-group-prepend'>
+        <span class='tobago-out input-group-text'>out</span>
+      </div>
+      <input type='text' name='id' id='id::field' class='tobago-in form-control'>
+    </div>
+  </div>
+</tobago-in>
\ No newline at end of file