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/06/15 12:35:03 UTC

svn commit: r1748575 - in /myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp: ./ content/20-component/010-input/10-in/ content/20-component/010-input/20-suggest/ content/20-component/010-input/40-date/ script/

Author: lofwyr
Date: Wed Jun 15 12:35:03 2016
New Revision: 1748575

URL: http://svn.apache.org/viewvc?rev=1748575&view=rev
Log:
TOBAGO 1473
[developed by hnoeth]

Added:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.test.js
Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/10-in/in.test.js
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/20-suggest/suggest.test.js
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/script/demo.js
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/10-in/in.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/10-in/in.test.js?rev=1748575&r1=1748574&r2=1748575&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/10-in/in.test.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/10-in/in.test.js Wed Jun 15 12:35:03 2016
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-function jQueryFrame(expression){
+function jQueryFrame(expression) {
   return document.getElementById("page:testframe").contentWindow.jQuery(expression);
 }
 
@@ -27,12 +27,7 @@ QUnit.test("inputfield with label", func
   assert.equal($inputField.val(), "Some Text");
 
   $inputField.val("abc");
-
-  var done = assert.async();
-  setTimeout(function () {
-    assert.equal($inputField.val(), "abc");
-    done();
-  }, 50);
+  assert.equal($inputField.val(), "abc");
 });
 
 QUnit.test("ajax change event", function (assert) {

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/20-suggest/suggest.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/20-suggest/suggest.test.js?rev=1748575&r1=1748574&r2=1748575&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/20-suggest/suggest.test.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/20-suggest/suggest.test.js Wed Jun 15 12:35:03 2016
@@ -15,24 +15,10 @@
  * limitations under the License.
  */
 
+function jQueryFrame(expression) {
+  return document.getElementById("page:testframe").contentWindow.jQuery(expression);
+}
+
 QUnit.test("suggest test", function (assert) {
   assert.equal("not implemented", "not implemented yet");
-  // var $inputField = jQuery(document).find("#page\\:in\\:\\:field");
-  // var $outputField = jQuery(document).find("#page\\:out > span:first");
-  // var $button = jQuery(document).find("#page\\:button");
-
-  // assert.equal($inputField.val(), "");
-  // assert.equal($outputField.text(), "");
-  //
-  // $inputField.val("abc");
-  // assert.equal($inputField.val(), "abc");
-  // // assert.equal("123", "qwe");
-  // assert.equal($outputField.text(), "");
-  //
-  // $button.click();
-  // var done = assert.async();
-  // setTimeout(function () {
-  //   assert.equal(content().find("#page\\:out > span:first").text(), "abc");
-  //   done();
-  // }, 500);
 });

Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.test.js?rev=1748575&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.test.js (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.test.js Wed Jun 15 12:35:03 2016
@@ -0,0 +1,82 @@
+/**
+ * Created by henning on 15.06.16.
+ */
+
+function jQueryFrame(expression) {
+  return document.getElementById("page:testframe").contentWindow.jQuery(expression);
+}
+
+function getToday() {
+  var now = new Date();
+  var dd = now.getDate();
+  var mm = now.getMonth() + 1;
+  var yyyy = now.getFullYear();
+  if (dd < 10) {
+    dd = '0' + dd
+  }
+  if (mm < 10) {
+    mm = '0' + mm
+  }
+  return dd + "." + mm + "." + yyyy;
+}
+
+QUnit.test("date with label", function (assert) {
+  var $label = jQueryFrame("#page\\:dnormal > label");
+  var $dateField = jQueryFrame("#page\\:dnormal\\:\\:field");
+  var $dateButton = jQueryFrame("#page\\:dnormal button");
+  var today = getToday();
+
+  assert.equal($label.text(), "Date");
+  assert.equal($dateField.val(), today);
+
+  $dateField.val("32.05.2016");
+  $dateButton.click();
+
+  assert.equal($dateField.val(), today);
+});
+
+QUnit.test("submit", function (assert) {
+  var $dateField = jQueryFrame("#page\\:fsbmt\\:sbmtinput\\:\\:field");
+  var $dateButton = jQueryFrame("#page\\:fsbmt\\:sbmtinput button");
+  var $outField = jQueryFrame("#page\\:fsbmt\\:sbmtoutput span");
+  var $submitButton = jQueryFrame("#page\\:fsbmt\\:sbmtbutton");
+
+  assert.equal($dateField.val(), "22.05.2016");
+  assert.equal($outField.text(), "22.05.2016");
+
+  $dateButton.click();
+  assert.ok(jQueryFrame(".bootstrap-datetimepicker-widget").get(0));
+  jQueryFrame(".bootstrap-datetimepicker-widget .day").get(37).click(); // Choose '01.06.2016'.
+
+  assert.equal($dateField.val(), "01.06.2016");
+  $submitButton.click();
+
+  var done = assert.async();
+  setTimeout(function () {
+    $outField = jQueryFrame("#page\\:fsbmt\\:sbmtoutput span");
+    assert.equal($outField.text(), "01.06.2016");
+    done();
+  }, 500);
+});
+
+QUnit.test("ajax", function (assert) {
+  var $dateField = jQueryFrame("#page\\:ajaxinput\\:\\:field");
+  var $dateButton = jQueryFrame("#page\\:ajaxinput button");
+  var $outField = jQueryFrame("#page\\:outputfield span");
+  var today = getToday();
+
+  assert.equal($dateField.val(), "");
+  assert.equal($outField.text(), "");
+
+  $dateButton.click();
+
+  assert.ok(jQueryFrame(".bootstrap-datetimepicker-widget").get(0));
+  assert.equal($dateField.val(), today);
+
+  var done = assert.async();
+  setTimeout(function () {
+    $outField = jQueryFrame("#page\\:outputfield span");
+    assert.equal($outField.text(), today);
+    done();
+  }, 500);
+});

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml?rev=1748575&r1=1748574&r2=1748575&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml Wed Jun 15 12:35:03 2016
@@ -131,10 +131,13 @@
           <tc:button id="runtest"
                      link="/faces/test.xhtml"
                      label="Run Test"
-                     immediate="true" tip="Run Test">
+                     immediate="true" tip="Run Test"
+                     rendered="#{testController.testJs != null}">
             <f:param name="page" value="#{testController.page}"/>
             <f:param name="testjs" value="#{testController.testJs}"/>
           </tc:button>
+          <tc:button id="closetest" label="Close Test"
+                     immediate="true" tip="Close test window"/>
         </tc:form>
       </tc:flowLayout>
 

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/script/demo.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/script/demo.js?rev=1748575&r1=1748574&r2=1748575&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/script/demo.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/script/demo.js Wed Jun 15 12:35:03 2016
@@ -70,6 +70,28 @@ var initInspect = function (elements) {
 Tobago.registerListener(initInspect, Tobago.Phase.DOCUMENT_READY);
 Tobago.registerListener(initInspect, Tobago.Phase.AFTER_UPDATE);
 
+var initTestButtons = function () {
+  var $runButton = jQuery("#page\\:navbtns\\:runtest");
+  var $closeButton = jQuery("#page\\:navbtns\\:closetest");
+
+  if (jQuery(parent.document.getElementById("qunit")).length) {
+    $runButton.hide();
+    $closeButton.attr("onclick", "window.top.location.href = location.href");
+  } else {
+    $closeButton.hide();
+  }
+};
+
+Tobago.registerListener(initTestButtons, Tobago.Phase.DOCUMENT_READY);
+Tobago.registerListener(initTestButtons, Tobago.Phase.AFTER_UPDATE);
+
+var initTestframe = function () {
+  jQuery("#page\\:testframe").attr("onload", "this.height = this.contentWindow.jQuery('body').prop('scrollHeight');");
+};
+
+Tobago.registerListener(initTestframe, Tobago.Phase.DOCUMENT_READY);
+Tobago.registerListener(initTestframe, Tobago.Phase.AFTER_UPDATE);
+
 Demo = {};
 
 /**

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml?rev=1748575&r1=1748574&r2=1748575&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml Wed Jun 15 12:35:03 2016
@@ -21,6 +21,7 @@
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns="http://www.w3.org/1999/xhtml">
+  <tc:script file="script/demo.js"/>
   <tc:script file="script/qunit-1.23.1.js"/>
   <tc:style file="style/qunit-1.23.1.css"/>
   <tc:script file="#{param['testjs']}"/>
@@ -29,6 +30,6 @@
   <div id="qunit-fixture"></div>
 
   <tc:object id="testframe" src="#{param['page']}">
-    <tc:style width="100%" height="800px"/>
+    <tc:style width="100%"/>
   </tc:object>
 </ui:composition>