You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2012/08/09 16:25:23 UTC

svn commit: r1371226 - in /pivot/trunk/tests/src/org/apache/pivot/tests: JavascriptConsoleTest.java javascript_console_test.bxml javascript_console_test.js

Author: smartini
Date: Thu Aug  9 14:25:22 2012
New Revision: 1371226

URL: http://svn.apache.org/viewvc?rev=1371226&view=rev
Log:
merge fixes from 2.0.x

Modified:
    pivot/trunk/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.java
    pivot/trunk/tests/src/org/apache/pivot/tests/javascript_console_test.bxml
    pivot/trunk/tests/src/org/apache/pivot/tests/javascript_console_test.js

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.java?rev=1371226&r1=1371225&r2=1371226&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.java (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/JavascriptConsoleTest.java Thu Aug  9 14:25:22 2012
@@ -69,6 +69,22 @@ public class JavascriptConsoleTest exten
     }
 
     /**
+     * Load (and returns) a Window, given its file name
+     * <p>
+     * Note that if public this method could be called even from JS in a bxml file
+     * (but a reference to the current application has to be put in serializer namespace).
+     *
+     * @param fileName the file name for the bxml file to load
+     * @return the Window instance
+     * @throws SerializationException in case of error
+     * @throws IOException in case of error
+     */
+    public Window load(String fileName) throws SerializationException, IOException {
+        logObject("load from \"" + fileName + "\"");
+        return loadWindow(fileName, null);
+    }
+
+    /**
      * Load (and returns) a Window, given its file name and serializer to use
      *
      * @param fileName the file name for the bxml file to load

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/javascript_console_test.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/javascript_console_test.bxml?rev=1371226&r1=1371225&r2=1371226&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/javascript_console_test.bxml (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/javascript_console_test.bxml Thu Aug  9 14:25:22 2012
@@ -30,8 +30,13 @@ limitations under the License.
 
     // JS variables for (remote) resources
     // needed for test 2 and 4
-    var baseURL  = "http://pivot.apache.org/assets-for-tests";
-    var frameURL = baseURL + "/frame.bxml";
+    var resourcesBaseURL   =
+        // "";
+        // "file:///D:/work/pivot/site/trunk/deploy/assets-for-tests" + "/";  // local test
+        // "http://pivot.apache.org/assets-for-tests" + "/";  // production url
+        "http://pivot.apache.org/assets-for-tests" + "/";
+    var frameName = "frame.bxml";
+    var frameURL  = resourcesBaseURL + frameName;
     // note that bxml files must have the MIME Type "application/bxml" (as requested by BXMLSerializer),
     // or (BXMLSerializer) will try to get it from its file extension ...
 
@@ -76,11 +81,17 @@ limitations under the License.
     log("application is " + application);  // reference to the application itself, set in main class, in Java Code
 
     // JS variables for (remote) resources
-    var bxmlSerializer = new BXMLSerializer();  // trick, I hope a good one ...
+    var bxmlSerializer = new BXMLSerializer();  // trick, create a new instance of BXMLSerializer ...
     log("bxmlSerializer is " + bxmlSerializer);
+    bxmlSerializer.getNamespace().put("application", application);  // add a reference to application even in this instance of BXMLSerializer ...
+    log("put a reference to application in serializer namespace");
+    bxmlSerializer.getNamespace().put("resourcesBaseURL", resourcesBaseURL);  // add a reference to resourcesBaseURL, so included bxml files could use it ...
+    log("put a reference to resourcesBaseURL in serializer namespace");
+
     // load the window/frame, but using an utility method defined in the application ...
     log("load the window/frame now, by JS code (calling Java code from the application) ...");
     var loadedWindow = application.loadWindowFromURL(frameURL, bxmlSerializer);
+//    var loadedWindow = application.loadWindowFromBaseURLAndFilename(resourcesBaseURL, frameName, bxmlSerializer);
     log("loadedWindow is " + loadedWindow + ", and its JavaScript typeof here is " + typeof loadedWindow);  // note that typeof loadedWindow is object
 
     var testRemoteFrame = loadedWindow;
@@ -90,6 +101,10 @@ limitations under the License.
 
 
     // test 5, TODO
+    // comment test 4, and copy its source inside the switch statements below (if possible), to make it really dynamic ...
+
+
+    // test 6, TODO
     // isolate a JS snippet (but self-contained) derive from test 4, and
     // find a way to execute it as the text written in the textArea in a JS interpreter,
     // then put it in a fixed template, and generalize it inside this test/sample application ...
@@ -113,7 +128,7 @@ limitations under the License.
 
                 <Label text="Templates:"/>
                 <ListButton bxml:id="templateButton"
-                    listData="['Choose a template', 'Open Frame Local', 'Open Frame Remote (from Pivot Web Site)']"
+                    listData="[' - Choose a template - ', 'Open Frame Local', 'Open Frame Remote (from Pivot Web Site)']"
                     selectedIndex="-1"
                 >
                     <listButtonSelectionListeners>
@@ -135,6 +150,7 @@ limitations under the License.
                                     templateText = "testRemoteFrame.open(window);";
                                     // note that testRemoteFrame is already loaded, so here it's only to display it ...
                                     testRemoteFrame.open(window);  // temp, then keep this commented
+// TODO: test 5 goes here ...
                                     break;
                                 default:
                                     clearConsole();

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/javascript_console_test.js
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/javascript_console_test.js?rev=1371226&r1=1371225&r2=1371226&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/javascript_console_test.js (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/javascript_console_test.js Thu Aug  9 14:25:22 2012
@@ -39,6 +39,7 @@ function clearStatus() {
 }
 
 function clearConsole() {
+	templateButton.selectedIndex = 0;
 	textArea.text = "";
 	// runButton.enabled = false;  // ok
 	runButton.setEnabled(false);   // explicit usage of the setter