myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject svn commit: r1804505 - in /myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main: java/org/apache/myfaces/tobago/example/demo/ webapp/ webapp/content/20-component/010-input/50-input-group/ webapp/content/30-concept/06-validat...
Date Wed, 09 Aug 2017 11:37:23 GMT
Author: hnoeth
Date: Wed Aug  9 11:37:22 2017
New Revision: 1804505

URL: http://svn.apache.org/viewvc?rev=1804505&view=rev
Log:
fix tests
* fix group.test.js; merge from trunk [1793993]
* improve test.xhtml; adjust 'start test' button; merge from trunk [1785939]
* fix link for form.xhtml
* fix validation-jsr303.test.js
* add testAll; merge from trunk [1799942]

Added:
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-testAll.js
      - copied unchanged from r1804438, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-testAll.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml
      - copied, changed from r1804438, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml
Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/group.test.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/06-validation/01/validation-jsr303.test.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/08-form/form.xhtml
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-test.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java?rev=1804505&r1=1804504&r2=1804505&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java
Wed Aug  9 11:37:22 2017
@@ -26,8 +26,11 @@ import javax.enterprise.context.RequestS
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.inject.Named;
+import java.io.File;
 import java.io.Serializable;
 import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
 
 @RequestScoped
 @Named
@@ -35,19 +38,88 @@ public class TestController implements S
 
   private static final Logger LOG = LoggerFactory.getLogger(TestController.class);
 
-  public String getTestBase() {
+  public boolean hasTest() {
+    final ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+    final String testJsUrl = "/" + getBase() + ".test.js";
+    try {
+      return externalContext.getResource(testJsUrl) != null;
+    } catch (MalformedURLException e) {
+      LOG.error("URL was: " + testJsUrl, e);
+    }
+    return false;
+  }
+
+  public String getBase() {
     final FacesContext facesContext = FacesContext.getCurrentInstance();
-    final ExternalContext externalContext = facesContext.getExternalContext();
     final String viewId = facesContext.getViewRoot().getViewId();
-    final String base = viewId.substring(0, viewId.length() - 6);
-    try {
-      if (externalContext.getResource(base + ".test.js") != null) {
-        return base;
+    return viewId.substring(1, viewId.length() - 6); //remove leading '/' and trailing '.xhtml'
+  }
+
+  public List<String> getAllPages() {
+    List<String> pages = new ArrayList<String>();
+
+    final File rootDir = new File("src/main/webapp/content");
+    if (rootDir.exists()) {
+      for (String page : getXHTMLs(rootDir)) {
+        pages.add(page.substring(16));
+      }
+    }
+    return pages;
+  }
+
+  private List<String> getXHTMLs(File dir) {
+    List<String> xhtmls = new ArrayList<String>();
+    for (File file : dir.listFiles()) {
+      if (file.isDirectory()) {
+        xhtmls.addAll(getXHTMLs(file));
+      } else if (!file.getName().startsWith("x-") && file.getName().endsWith(".xhtml"))
{
+        xhtmls.add(file.getPath());
+      }
+    }
+    return xhtmls;
+  }
+
+  public List<TestPage> getTestPages() {
+    List<TestPage> testPages = new ArrayList<TestPage>();
+
+    int idCount = 1;
+    final File rootDir = new File("src/main/webapp/content");
+    if (rootDir.exists()) {
+      for (String testJs : getTestJs(rootDir)) {
+        final String base = testJs.substring(16, testJs.length() - 8);
+        testPages.add(new TestPage("tp" + idCount++, base));
       }
-    } catch (MalformedURLException e) {
-      LOG.error("viewId='" + viewId + "'", e);
     }
+    return testPages;
+  }
 
-    return null;
+  private List<String> getTestJs(File dir) {
+    List<String> testJsFiles = new ArrayList<String>();
+    for (File file : dir.listFiles()) {
+      if (file.isDirectory()) {
+        testJsFiles.addAll(getTestJs(file));
+      } else if (!file.getName().startsWith("x-") && file.getName().endsWith(".test.js"))
{
+        testJsFiles.add(file.getPath());
+      }
+    }
+    return testJsFiles;
+  }
+
+  public class TestPage {
+    private final String id;
+    private final String base;
+
+    TestPage(String id, String base) {
+      this.id = id;
+      this.base = base;
+    }
+
+    public String getId() {
+      return id;
+    }
+
+    public String getBase() {
+      return base;
+    }
   }
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/group.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/group.test.js?rev=1804505&r1=1804504&r2=1804505&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/group.test.js
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/group.test.js
Wed Aug  9 11:37:22 2017
@@ -23,7 +23,7 @@ QUnit.test("span(https://example.com/) -
   var combinedWidth = $span.outerWidth(true) + $input.outerWidth(true);
 
   assert.equal($inputfield.outerWidth(true), $mainForm.width());
-  assert.ok(combinedWidth <= $mainForm.width(),
+  assert.ok(combinedWidth <= $mainForm.width() + 1,
       "Width of inputfield (" + $span.outerWidth(true) + "px) + span (" + $input.outerWidth(true)
+ "px) (="
       + combinedWidth + "px) must be smaller/equal than the width of the content box (" +
$mainForm.width() + "px).");
   assert.equal($span.outerHeight(), $input.outerHeight());
@@ -38,7 +38,7 @@ QUnit.test("label(Price) - inputfield -
   var combinedWidth = $label.outerWidth(true) + $span.outerWidth(true) + $input.outerWidth(true);
 
   assert.equal($inputfield.outerWidth(true), $mainForm.width());
-  assert.ok(combinedWidth <= $mainForm.width(),
+  assert.ok(combinedWidth <= $mainForm.width() + 1,
       "Width of label (" + $label.outerWidth(true) + "px) + input (" + $input.outerWidth(true)
+ "px) + span ("
       + $span.outerWidth(true) + "px) (=" + combinedWidth
       + "px) must be smaller/equal than the width of the content box (" + $mainForm.width()
+ "px).");
@@ -54,7 +54,7 @@ QUnit.test("span(User Two) - inputfield
   var combinedWidth = $span.outerWidth(true) + $input.outerWidth(true) + $button.outerWidth(true);
 
   assert.equal($inputfield.outerWidth(true), $mainForm.width());
-  assert.ok(combinedWidth <= $mainForm.width(),
+  assert.ok(combinedWidth <= $mainForm.width() + 1,
       "Width of span (" + $span.outerWidth(true) + "px) + input (" + $input.outerWidth(true)
+ "px) + button ("
       + $button.outerWidth(true) + "px) (=" + combinedWidth
       + "px) must be smaller/equal than the width of the content box (" + $mainForm.width()
+ "px).");
@@ -70,7 +70,7 @@ QUnit.test("dropdown-button - inputfield
   var combinedWidth = $button.outerWidth(true) + $input.outerWidth(true);
 
   assert.equal($inputfield.outerWidth(true), $mainForm.width());
-  assert.ok(combinedWidth <= $mainForm.width(),
+  assert.ok(combinedWidth <= $mainForm.width() + 1,
       "Width of button (" + $button.outerWidth(true) + "px) + input (" + $input.outerWidth(true)
+ "px) (="
       + combinedWidth + "px) must be smaller/equal than the width of the content box (" +
$mainForm.width() + "px).");
   assert.equal($button.outerHeight(), $input.outerHeight());
@@ -85,7 +85,7 @@ QUnit.test("inputfield - span(Send To:)
   var combinedWidth = $input.outerWidth(true) + $span.outerWidth(true) + $button.outerWidth(true);
 
   assert.equal($inputfield.outerWidth(true), $mainForm.width());
-  assert.ok(combinedWidth <= $mainForm.width(),
+  assert.ok(combinedWidth <= $mainForm.width() + 1,
       "Width of input (" + $input.outerWidth(true) + "px) + span (" + $span.outerWidth(true)
+ "px) + button ("
       + $button.outerWidth(true) + "px) (=" + combinedWidth
       + "px) must be smaller/equal than the width of the content box (" + $mainForm.width()
+ "px).");
@@ -101,7 +101,7 @@ QUnit.test("inputfield - dropdownbox", f
   var combinedWidth = $input.outerWidth(true) + $dropdown.outerWidth(true);
 
   assert.equal($inputfield.outerWidth(true), $mainForm.width());
-  assert.ok(combinedWidth <= $mainForm.width(),
+  assert.ok(combinedWidth <= $mainForm.width() + 1,
       "Width of input (" + $input.outerWidth(true) + "px) + dropdown (" + $dropdown.outerWidth(true)
+ "px) (="
       + combinedWidth + "px) must be smaller/equal than the width of the content box (" +
$mainForm.width() + "px).");
   assert.equal($input.outerHeight(), $dropdown.outerHeight());

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/06-validation/01/validation-jsr303.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/06-validation/01/validation-jsr303.test.js?rev=1804505&r1=1804504&r2=1804505&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/06-validation/01/validation-jsr303.test.js
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/06-validation/01/validation-jsr303.test.js
Wed Aug  9 11:37:22 2017
@@ -54,53 +54,68 @@ QUnit.test("Required: Submit with conten
 QUnit.test("Length: Submit single character.", function (assert) {
   assert.expect(1);
   var done = assert.async();
+  var step = 1;
 
   var $messages = jQueryFrame("#page\\:messages .tobago-messages");
-  var $in = jQueryFrame("#page\\:mainForm\\:length\\:in\\:\\:field");
-  var $submit = jQueryFrame("#page\\:mainForm\\:length\\:submit");
+  var $in = jQueryFrame("#page\\:mainForm\\:length\\:in2\\:\\:field");
+  var $submit = jQueryFrame("#page\\:mainForm\\:length\\:submit2");
 
   $in.val("a");
   $submit.click();
 
   jQuery("#page\\:testframe").load(function () {
-    $messages = jQueryFrame($messages.selector);
-    assert.equal($messages.length, 1);
-    done();
+    if (step === 1) {
+      $messages = jQueryFrame($messages.selector);
+      assert.equal($messages.length, 1);
+
+      step++;
+      done();
+    }
   });
 });
 
 QUnit.test("Length: Submit three characters.", function (assert) {
   assert.expect(1);
   var done = assert.async();
+  var step = 1;
 
   var $messages = jQueryFrame("#page\\:messages .tobago-messages");
-  var $in = jQueryFrame("#page\\:mainForm\\:length\\:in\\:\\:field");
-  var $submit = jQueryFrame("#page\\:mainForm\\:length\\:submit");
+  var $in = jQueryFrame("#page\\:mainForm\\:length\\:in2\\:\\:field");
+  var $submit = jQueryFrame("#page\\:mainForm\\:length\\:submit2");
 
   $in.val("abc");
   $submit.click();
 
   jQuery("#page\\:testframe").load(function () {
-    $messages = jQueryFrame($messages.selector);
-    assert.equal($messages.length, 0);
-    done();
+    if (step === 1) {
+      $messages = jQueryFrame($messages.selector);
+      assert.equal($messages.length, 0);
+
+      step++;
+      done();
+    }
   });
 });
 
 QUnit.test("Length: Submit five characters.", function (assert) {
   assert.expect(1);
   var done = assert.async();
+  var step = 1;
 
   var $messages = jQueryFrame("#page\\:messages .tobago-messages");
-  var $in = jQueryFrame("#page\\:mainForm\\:length\\:in\\:\\:field");
-  var $submit = jQueryFrame("#page\\:mainForm\\:length\\:submit");
+  var $in = jQueryFrame("#page\\:mainForm\\:length\\:in2\\:\\:field");
+  var $submit = jQueryFrame("#page\\:mainForm\\:length\\:submit2");
 
   $in.val("abcde");
   $submit.click();
 
   jQuery("#page\\:testframe").load(function () {
-    $messages = jQueryFrame($messages.selector);
-    assert.equal($messages.length, 1);
-    done();
+    if (step === 1) {
+      $messages = jQueryFrame($messages.selector);
+      assert.equal($messages.length, 1);
+
+      step++;
+      done();
+    }
   });
 });

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/08-form/form.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/08-form/form.xhtml?rev=1804505&r1=1804504&r2=1804505&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/08-form/form.xhtml
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/08-form/form.xhtml
Wed Aug  9 11:37:22 2017
@@ -27,7 +27,7 @@
     Forms are added by the <code class="language-markup">&lt;tc:form/></code>
tag.</p>
   <p>Forms are also relevant for
     <tc:link label="#{demoBundle.default_command}"
-             link="/faces/content/20-component/040-command/00-default/default-command.xhtml"/>.</p>
+             link="#{request.contextPath}/content/20-component/040-command/10-default/default-command.xhtml"/>.</p>
   <tc:link label="Tag Library Documentation" image="#{request.contextPath}/image/feather-leaf.png"
            link="#{demoBundle.tagDocUrl}/#{info.stableVersion}/tld/tc/form.html"/>
 

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml?rev=1804505&r1=1804504&r2=1804505&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
Wed Aug  9 11:37:22 2017
@@ -122,9 +122,8 @@
                      link="/faces/test.xhtml"
                      label="Run Test"
                      immediate="true" tip="Run Test"
-                     rendered="#{testController.testBase != null}">
-            <f:param name="page" value="#{request.contextPath}/faces#{testController.testBase}.xhtml"/>
-            <f:param name="testjs" value="#{request.contextPath}#{testController.testBase}.test.js"/>
+                     rendered="#{testController.hasTest()}">
+            <f:param name="base" value="#{testController.base}"/>
           </tc:button>
           <tc:button id="closetest" label="Close Test"
                      immediate="true" tip="Close test window"/>

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-test.js?rev=1804505&r1=1804504&r2=1804505&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-test.js
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-test.js
Wed Aug  9 11:37:22 2017
@@ -27,9 +27,9 @@ function jQueryFrame(expression) {
  */
 function waitForAjax(waitingDone, executeWhenDone, maxWait) {
   var startTime = new Date().getTime();
-  maxWait = maxWait != null ? maxWait : 20000;
+  maxWait = maxWait ? maxWait : 20000;
   var stillWaiting = true;
-  var interval = setInterval(function() {
+  var interval = setInterval(function () {
     if (new Date().getTime() - startTime < maxWait && stillWaiting) {
       stillWaiting = !waitingDone();
     } else {
@@ -38,3 +38,20 @@ function waitForAjax(waitingDone, execut
     }
   }, 50);
 }
+
+QUnit.test("wait for test", function (assert) {
+  var done = assert.async();
+
+  var startTime = new Date().getTime();
+  var contentWindowName = "";
+  var waitingDone = false;
+  var interval = setInterval(function () {
+    contentWindowName = document.getElementById("page:testframe").contentWindow.name;
+    waitingDone = contentWindowName !== "page:testframe" && contentWindowName !==
"ds-tempWindowId";
+    if (new Date().getTime() - startTime >= 20000 || waitingDone) {
+      clearInterval(interval);
+      assert.ok(waitingDone);
+      done();
+    }
+  }, 50);
+});

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml?rev=1804505&r1=1804504&r2=1804505&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml
Wed Aug  9 11:37:22 2017
@@ -25,12 +25,12 @@
   <tc:script file="#{request.contextPath}/script/qunit-1.23.1.js"/>
   <tc:script file="#{request.contextPath}/script/tobago-test.js"/>
   <tc:style file="#{request.contextPath}/style/qunit-1.23.1.css"/>
-  <tc:script file="#{param['testjs']}"/>
+  <tc:script file="#{request.contextPath}/#{param['accessTest'] ? 'error/error' : param['base']}.test.js"/>
 
   <div id="qunit"></div>
   <div id="qunit-fixture"></div>
 
-  <tc:object id="testframe" src="#{param['page']}">
+  <tc:object id="testframe" src="#{request.contextPath}/faces/#{param['base']}.xhtml">
     <tc:style width="100%"/>
   </tc:object>
 </ui:composition>

Copied: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml
(from r1804438, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml?p2=myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml&p1=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml&r1=1804438&r2=1804505&rev=1804505&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml
Wed Aug  9 11:37:22 2017
@@ -28,7 +28,7 @@
   <c:forEach items="#{testController.testPages}" var="testPage">
     <div class="testframe-wrapper">
       <div>
-        <tc:link label="open in new tab" outcome="/#{testPage.base}.xhtml" target="_blank"/>
+        <tc:link label="open in new tab" link="/#{testPage.base}.xhtml" target="_blank"/>
       </div>
       <tc:object id="#{testPage.id}" name="test.xhtml?base=#{testPage.base}">
         <tc:style height="300px"/>



Mime
View raw message