Author: psharples
Date: Thu Mar 24 11:59:06 2011
New Revision: 1084920
URL: http://svn.apache.org/viewvc?rev=1084920&view=rev
Log:
This widget can be used to bulk/batch test the setting of preferences and
shared data - useful for seeing what happens when the queueing mechanism is
enabled in wookie
Added:
incubator/wookie/trunk/scratchpad/widgets/blitz/
incubator/wookie/trunk/scratchpad/widgets/blitz/build.xml (with props)
incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml (with props)
incubator/wookie/trunk/scratchpad/widgets/blitz/include.js (with props)
incubator/wookie/trunk/scratchpad/widgets/blitz/index.html (with props)
incubator/wookie/trunk/scratchpad/widgets/blitz/style.css (with props)
Added: incubator/wookie/trunk/scratchpad/widgets/blitz/build.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/blitz/build.xml?rev=1084920&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/blitz/build.xml (added)
+++ incubator/wookie/trunk/scratchpad/widgets/blitz/build.xml Thu Mar 24
11:59:06 2011
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project default="build-widget" basedir="." name="widget build file">
+ <property name="wookie.widgets.dir" location="../"/>
+ <property name="widget.shortname" value="blitz"/>
+
+ <import file="../build.xml"/>
+</project>
\ No newline at end of file
Propchange: incubator/wookie/trunk/scratchpad/widgets/blitz/build.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml?rev=1084920&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml (added)
+++ incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml Thu Mar 24
11:59:06 2011
@@ -0,0 +1,10 @@
+<widget xmlns="http://www.w3.org/ns/widgets"
+ id="http://wookie.apache.org/widgets/blitz"
+ version="0.1"
+ width="420"
+ height="320">
+ <name>Blitz</name>
+ <description>Preference and shared data test widget</description>
+ <content src="index.html"/>
+ <feature name="http://wave.google.com" required="true"/>
+</widget>
\ No newline at end of file
Propchange: incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/wookie/trunk/scratchpad/widgets/blitz/include.js
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/blitz/include.js?rev=1084920&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/blitz/include.js (added)
+++ incubator/wookie/trunk/scratchpad/widgets/blitz/include.js Thu Mar 24
11:59:06 2011
@@ -0,0 +1,140 @@
+var DEFAULT_VALUE = "wookie-test-value-";
+var TEST_SEPARATOR_START = "<chat>";
+var TEST_SEPARATOR_END = "</chat><br/>";
+
+function bulkTestPreferences(prefName, numberToTest){
+ var outputStr = "";
+ for(i=0;i<numberToTest;i++){
+ Widget.preferences.setItem(prefName, DEFAULT_VALUE + i);
+ outputStr+=widget.preferences.getItem(prefName) + "<br>";
+ }
+ appendToLog(outputStr);
+}
+
+function bulkTestSharedData(prefName, numberToTest){
+ var TEST_START = TEST_SEPARATOR_START + "<b>" + username + ":</b>";
+ if (document.forms['frm1'].useappend.checked == true){
+ for(i=0;i<numberToTest;i++){
+ appendSharedDataName(prefName, TEST_START +
DEFAULT_VALUE + i + TEST_SEPARATOR_END);
+ }
+ }
+ else{
+ for(i=0;i<numberToTest;i++){
+ setSharedDataName(prefName, TEST_START + DEFAULT_VALUE
+ i + TEST_SEPARATOR_END);
+ }
+ }
+}
+
+function pauseBeforeGettingPreferences(prefName){
+ var t=setTimeout("getPreferenceName('"+prefName+"')",5000);
+}
+
+function getPreferenceName(prefName){
+ appendToLog("<i>(Widget.getPreference):"+
widget.preferences.getItem(prefName) + "</i><br/>");
+ return false;
+}
+
+function setPreferenceName(prefName, prefValue){
+ Widget.preferences.setItem(prefName, prefValue);
+}
+
+function getsharedData(dName){
+ Widget.sharedDataForKey(dName, sharedDataCallback);
+}
+
+function sharedDataCallback(p){
+ appendToLog("<i>(Widget.getSharedData):" + p + "</i><br/>");
+}
+
+function appendSharedDataName(dName, dValue){
+ Widget.appendSharedDataForKey(dName, dValue);
+}
+
+function setSharedDataName(dName, dValue){
+ Widget.setSharedDataForKey(dName, dValue);
+}
+
+function handleSharedDataUpdate(p){
+ if (document.forms['frm1'].logsharedupdate.checked == true){
+ appendToLog("<i>(Widget.onSharedUpdate) shareddatakey:" + p +
"</i><br/>");
+ }
+}
+
+function resetLog(){
+ var fcanvas = document.getElementById('fcontent');
+ fcanvas.innerHTML = "";
+}
+
+function resetWookieValue(dName){
+ if(isTestingProperties()){
+ setPreferenceName(dName, null)
+ }
+ else{
+ Widget.setSharedDataForKey(dName, null);
+ }
+}
+
+function getWookieValue(prefName){
+ if(isTestingProperties()){
+ getPreferenceName(prefName);
+ }
+ else{
+ getsharedData(prefName);
+ }
+}
+
+function setWookieValue(prefName, prefValue){
+ if(isTestingProperties()){
+ setPreferenceName(prefName, prefValue);
+ }
+ else{
+ if (document.forms['frm1'].useappend.checked == true){
+ appendSharedDataName(prefName, prefValue);
+ }
+ else{
+ setSharedDataName(prefName, prefValue);
+ }
+ }
+}
+
+function startTest(prefName, numTimes){
+ if(isTestingProperties()){
+ alert("This test will now attempt to set the preferences " +
numTimes + " times in succession");
+ bulkTestPreferences(prefName, numTimes);
+ }
+ else{
+ alert("This test will now attempt to set the shared data " +
numTimes + " times in succession");
+ bulkTestSharedData(prefName, numTimes);
+ }
+}
+
+function isTestingProperties(){
+ if (document.forms['frm1'].ptype[0].checked == true){
+ return true;
+ }
+ else{
+ return false;
+ }
+}
+
+function appendToLog(str){
+ var fcanvas = document.getElementById('fcontent');
+ var existing = fcanvas.innerHTML;
+ fcanvas.innerHTML = existing +str;
+ fcanvas.scrollTop = fcanvas.scrollHeight;
+}
+
+function rnd_no(max){
+ return Math.floor(Math.random()*max);
+};
+
+function init(){
+ if (wave.getViewer() != null){
+ username = wave.getViewer().getDisplayName();
+ }
+ if (username == null || username == ""){
+ username = "blitz_" + rnd_no(9999);
+ }
+}
+
+Widget.onSharedUpdate = handleSharedDataUpdate;
\ No newline at end of file
Propchange: incubator/wookie/trunk/scratchpad/widgets/blitz/include.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/wookie/trunk/scratchpad/widgets/blitz/index.html
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/blitz/index.html?rev=1084920&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/blitz/index.html (added)
+++ incubator/wookie/trunk/scratchpad/widgets/blitz/index.html Thu Mar 24
11:59:06 2011
@@ -0,0 +1,32 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+<title>Preferences and shared data test widget</title>
+<link rel="stylesheet" href="style.css" type="text/css"/>
+<script src="include.js"></script>
+</head>
+<body onload="init();">
+<div id="fcontent"></div>
+<div id="fform">
+<form name="frm1">
+ Name of property/shareddata field <input type="text" name="prefname"
value="wookie-test-key" /><br />
+ Value of property/shareddata field <input type="text" name="prefvalue"
value="default-value" /><br />
+ Test Preference <input type="radio" name="ptype" checked="checked"
value="preference" />
+ Test Shared data <input type="radio" name="ptype" value="shareddata" /><br />
+ <input type="checkbox" name="useappend" checked value="useappend" />append
shareddata
+ <input type="checkbox" name="logsharedupdate" value="logsharedupdate" />log
sharedupdate messages<br />
+ <input type="button" value="Get"
onclick="getWookieValue(document.forms['frm1']['prefname'].value)" />
+ <input type="button" value="Set"
onclick="setWookieValue(document.forms['frm1']['prefname'].value,
document.forms['frm1']['prefvalue'].value)" />
+ <input type="button" value="Reset"
onclick="resetWookieValue(document.forms['frm1']['prefname'].value)" />
+ <input type="button" value="Clear log" onclick="resetLog()" /><br />
+<div><b>Batch testing</b></div>
+ Number of times to test <select id="ntimes" name="ntimes"><script>
+ for(i=0;i<=1000;i++){
+ document.write("<option value="+i+">"+i+"</option>");
+ }
+ </script></select><br />
+ <input type="button" value="Start batch test"
onclick="startTest(document.forms['frm1']['prefname'].value,
document.forms['frm1'].ntimes.options[ntimes.selectedIndex].value)" /><br />
+</form>
+</div>
+<div id="fresponse"></div>
+</body></html>
\ No newline at end of file
Propchange: incubator/wookie/trunk/scratchpad/widgets/blitz/index.html
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/wookie/trunk/scratchpad/widgets/blitz/style.css
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/blitz/style.css?rev=1084920&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/blitz/style.css (added)
+++ incubator/wookie/trunk/scratchpad/widgets/blitz/style.css Thu Mar 24
11:59:06 2011
@@ -0,0 +1,29 @@
+html {
+ height:100%;
+ max-height:100%;
+ padding:0;
+ margin:0;
+ border:0;
+ font-size:80%;
+ font-family: "trebuchet ms", tahoma, verdana, arial, sans-serif;
+ /* hide overflow:hidden from IE5/Mac */
+ /* \*/
+ overflow: hidden;
+ /* */
+}
+
+body{
+ margin-top:0px;
+ margin-left:0px;
+ color: #000000;
+}
+
+div#fcontent {
+ border : solid 1px #ffffff;
+ background : #000000;
+ color : #ffffff;
+ padding : 4px;
+ width : 100%;
+ height : 120px;
+ overflow : auto;
+}
\ No newline at end of file
Propchange: incubator/wookie/trunk/scratchpad/widgets/blitz/style.css
------------------------------------------------------------------------------
svn:mime-type = text/plain