Commit 8bc8ccc3 authored by Pere Cortes's avatar Pere Cortes Committed by Sebastien Robin

erp5_safeimage: unit test fixed and func test added

parent 33cae3c2
...@@ -76,16 +76,28 @@ ...@@ -76,16 +76,28 @@
</section>\n </section>\n
</div>\n </div>\n
</div>\n </div>\n
<script type="text/javascript" src="js/template.js"></script>\n <tal:block tal:define="portal_url python:here.getPortalObject().absolute_url()">\n
<script type="text/javascript" src="jquery/core/jquery.js"></script>\n <script type="text/javascript" \n
<script type="text/javascript" src="urlHandler.js"></script>\n tal:attributes="src python: \'%s/%s\' % (portal_url,\'js/template.js\')"></script>\n
<script type="text/javascript" src="ICanHaz.min.js"></script>\n <script type="text/javascript" \n
<script type="text/javascript" src="openlayers/OpenLayers.js"></script>\n tal:attributes="src python: \'%s/%s\' % (portal_url,\'jquery/core/jquery.js\')"></script>\n
<script type="text/javascript" src="js/CanvasImage.js"></script>\n <script type="text/javascript" \n
<script type="text/javascript" src="js/ERP5_OpenLayers.js"></script>\n tal:attributes="src python: \'%s/%s\' % (portal_url,\'urlHandler.js\')"></script>\n
<script type="text/javascript" src="js/form.js"></script>\n <script type="text/javascript" \n
<script type="text/javascript" src="js/safeimage.js"></script>\n tal:attributes="src python: \'%s/%s\' % (portal_url,\'ICanHaz.min.js\')"></script>\n
<script type="text/javascript" src="js/pixastic.js"></script>\n <script type="text/javascript" \n
tal:attributes="src python: \'%s/%s\' % (portal_url,\'openlayers/OpenLayers.js\')"></script>\n
<script type="text/javascript" \n
tal:attributes="src python: \'%s/%s\' % (portal_url,\'js/CanvasImage.js\')"></script>\n
<script type="text/javascript" \n
tal:attributes="src python: \'%s/%s\' % (portal_url,\'js/ERP5_OpenLayers.js\')"></script>\n
<script type="text/javascript" \n
tal:attributes="src python: \'%s/%s\' % (portal_url,\'js/form.js\')"></script>\n
<script type="text/javascript" \n
tal:attributes="src python: \'%s/%s\' % (portal_url,\'js/safeimage.js\')"></script>\n
<script type="text/javascript" \n
tal:attributes="src python: \'%s/%s\' % (portal_url,\'js/pixastic.js\')"></script>\n
</tal:block>\n
</body>\n </body>\n
</html> </html>
...@@ -101,7 +113,7 @@ ...@@ -101,7 +113,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Safeview_SafeImage</string> </value> <value> <string>ERP5SafeImage_view</string> </value>
</item> </item>
<item> <item>
<key> <string>output_encoding</string> </key> <key> <string>output_encoding</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>#from Products.ERP5.Document.TileImageTransformed import TileImageTransformed\n
#from cStringIO import StringIO\n
\n
\n
portal = context.getPortalObject()\n
\n
\n
data = portal.restrictedTraverse("portal_skins/erp5_safeimage/img/image_test.jpg")\n
\n
print data.data\n
\n
return printed\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SeleniumSafeImage_uploadFile</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>cleanUp</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5SafeImage_Selenium</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Selenium_cleanUp</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Selenium_cleanUp</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>uploadImage</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5SafeImage_Selenium</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Selenium_uploadImage</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Selenium_uploadImage</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts54117138.4</string> </value> <value> <string>ts55132689.11</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -101,6 +101,9 @@ ...@@ -101,6 +101,9 @@
\t\t\t\t$(function() {\n \t\t\t\t$(function() {\n
\t\n \t\n
\t\t\t SafeImage.loadOpenLayerZoomedImage(zoomify_width,zoomify_height, zoomify_url,data);\n \t\t\t SafeImage.loadOpenLayerZoomedImage(zoomify_width,zoomify_height, zoomify_url,data);\n
if (document.location.search != ""){\n
SafeImage.map.zoomTo(Number(document.location.search.split("")[6]));\n
} \n
\t\t\t\t });\n \t\t\t\t });\n
\t};\n \t};\n
\n \n
...@@ -134,7 +137,7 @@ $("#main").form();\n ...@@ -134,7 +137,7 @@ $("#main").form();\n
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>2900</int> </value> <value> <int>3057</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts54116947.11</string> </value> <value> <string>ts55133579.12</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
\n \n
that.map = new OpenLayers.Map("map", options);\n that.map = new OpenLayers.Map("map", options);\n
that.map.addLayer(that.zoomify);\n that.map.addLayer(that.zoomify);\n
\n
that.map.setBaseLayer(that.zoomify);\n that.map.setBaseLayer(that.zoomify);\n
that.map.zoomToMaxExtent();\n that.map.zoomToMaxExtent();\n
};\n };\n
...@@ -58,7 +57,7 @@ ...@@ -58,7 +57,7 @@
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>1009</int> </value> <value> <int>1006</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts54117152.04</string> </value> <value> <string>ts54293364.05</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
document.write("<div id=\'map\' class=\'smallmap\'></div>");\n document.write("<div id=\'map\' class=\'smallmap\'></div>");\n
document.write("</article>");\n document.write("</article>");\n
document.write("</script>");\n document.write("</script>");\n
document.domain = "localhost";\n
})();\n })();\n
\n \n
...@@ -43,7 +42,7 @@ ...@@ -43,7 +42,7 @@
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>350</int> </value> <value> <int>317</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts54892065.66</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>user-extensions.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/**\n
* Selenium extensions for the ERP5 project\n
*/\n
\n
/* pere */\n
\n
/**\n
* Checks the element referenced by `locator` is a float equals to `text`.\n
* Values are converted to float, to be format-independant (ie. 1 000 = 1000.0)\n
*/\n
Selenium.prototype.assertFloat = function(locator, text) {\n
var actualValueText = getText(this.page().findElement(locator));\n
var actualValue = parseFloat(actualValueText\n
.replace(/ /g, "").replace(/&nbsp;/g, ""));\n
var expectedValue = parseFloat(text.replace(/ /g, "").replace(/&nbsp;/g, ""));\n
\n
if (isNaN(actualValue)) {\n
Assert.fail("Actual value "+ actualValueText +\n
" cannot be parsed as float");\n
}\n
Assert.matches(expectedValue.toString(), actualValue.toString());\n
};\n
\n
\n
/**\n
* like assertFloat, but for the value of <input elements.\n
*/\n
Selenium.prototype.assertFloatValue = function(locator, text) {\n
var actualValueText = getInputValue(this.page().findElement(locator));\n
var actualValue = parseFloat(actualValueText\n
.replace(/ /g, "").replace(/&nbsp;/g, ""));\n
var expectedValue = parseFloat(text.replace(/ /g, "").replace(/&nbsp;/g, ""));\n
\n
if (isNaN(actualValue)) {\n
Assert.fail("Actual value "+ actualValueText +\n
" cannot be parsed as float");\n
}\n
Assert.matches(expectedValue.toString(), actualValue.toString());\n
};\n
\n
\n
/**\n
* Checks the portal status message.\n
*/\n
Selenium.prototype.assertPortalStatusMessage = function(text) {\n
var psm_locator = "//div[@id=\'transition_message\']";\n
var actualValue = getText(this.page().findElement(psm_locator));\n
Assert.matches(text, actualValue);\n
};\n
\n
Selenium.prototype.doType = function(locator, newText) {\n
if (typeof(netscape) != "undefined" && typeof(netscape.security.PrivilegeManager) != "undefined" ) {\n
// On old firefox versions, we enable privilege to upload file in javascript.\n
// The user needs to have signed.applets.codebase_principal_support set to true in about:config\n
// This is done in prefs.js generated by product/ERP5Type/tests/runFunctionalTest.py\n
// This approach no longer work in newer firefox versions https://developer.mozilla.org/en-US/docs/Bypassing_Security_Restrictions_and_Signing_Code\n
// Without this, tests dealing with file upload will fail\n
netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");\n
}\n
var element = this.page().findElement(locator);\n
this.page().replaceText(element, newText);\n
};\n
\n
/*\n
* Get the location of the current page. This function is missing in\n
* Selenium 0.8 or later.\n
*/\n
Selenium.prototype.getAbsoluteLocation = function() {\n
return this.page().location || this.browserbot.getCurrentWindow().location;\n
};\n
\n
Selenium.prototype.doPhantomRender = function(filename) {\n
if (window.page && window.page.render) {\n
page.render(filename);\n
}\n
};\n
\n
Selenium.prototype.doZoomIn = function() {\n
this.page().SafeImage.map.zoomTo(1);\n
};\n
\n
Selenium.prototype.doZoomOut = function() {\n
this.page().SafeImage.map.zoomTo(0);\n
};\n
\n
\n
Selenium.prototype.assertElementPositionRangeTop = function(locator, range){\n
var positionTop = parseFloat(this.getElementPositionTop(locator));\n
/* example of range 450..455 */\n
var rangeList = range.split("..");\n
var minimumPositionTop = parseFloat(rangeList[0]);\n
var maximumPositionTop = parseFloat(rangeList[1]);\n
if (positionTop < minimumPositionTop || positionTop > maximumPositionTop ){\n
Assert.fail(positionTop + " is not between " + minimumPositionTop + " and " + maximumPositionTop);\n
};\n
};
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>3622</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -33,7 +33,7 @@ class TestSafeImage(ERP5TypeTestCase): ...@@ -33,7 +33,7 @@ class TestSafeImage(ERP5TypeTestCase):
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
return ('erp5_base', return ('erp5_base',
'erp5_dms', 'erp5_dms',
'erp5_safeimage', 'erp5_safeimage'
) )
def afterSetUp(self): def afterSetUp(self):
......
5 6
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment