aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dijit/tests/layout/ContentPane.html
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-14 15:39:19 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-14 15:39:19 +0000
commit1c5685d68f1b73270fb814fe04cbb490eb90ba5f (patch)
tree3d3ada08a934b96fc31531f1327690d7edc6f766 /includes/js/dijit/tests/layout/ContentPane.html
parent104d59099e048688c4dbac37d72137006e396558 (diff)
downloadsemanticscuttle-1c5685d68f1b73270fb814fe04cbb490eb90ba5f.tar.gz
semanticscuttle-1c5685d68f1b73270fb814fe04cbb490eb90ba5f.tar.bz2
Minor fix: Remove DOJO library (60Mo) replaced by link to Google CDN (online DOJO library)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@159 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dijit/tests/layout/ContentPane.html')
-rw-r--r--includes/js/dijit/tests/layout/ContentPane.html577
1 files changed, 0 insertions, 577 deletions
diff --git a/includes/js/dijit/tests/layout/ContentPane.html b/includes/js/dijit/tests/layout/ContentPane.html
deleted file mode 100644
index 8853a3e..0000000
--- a/includes/js/dijit/tests/layout/ContentPane.html
+++ /dev/null
@@ -1,577 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-<head>
- <title>Test ContentPane</title>
- <style type="text/css">
- @import "../../../dojo/resources/dojo.css";
- @import "../../themes/tundra/tundra.css";
- @import "../css/dijitTests.css";
-
- .box {
- border: 1px solid black;
- padding: 8px;
- }
-
- .dijitTestWidget {
- border: 1px dashed red;
- background-color: #C0E209 ;
- }
- </style>
-
- <script type="text/javascript" src="../../../dojo/dojo.js"
- djConfig="isDebug: true"></script>
- <script type="text/javascript">
- dojo.require("doh.runner");
- dojo.require("dijit.layout.ContentPane");
- dojo.require("dijit._Container");
- dojo.require("dijit._Templated");
- dojo.require("dijit.layout.StackContainer");
-
- // create a do nothing, only for test widget
- dojo.declare("dijit.TestWidget",
- [dijit._Widget, dijit._Templated], {
- templateString: "<span class='dijitTestWidget'></span>"
- });
-
-
- dojo.addOnLoad(function(){
- doh.register("pane1",
- [
- {
- name: "no_autoparse",
- runTest: function(t){
- if(dijit.byId("pane1")){
- throw doh._AssertFailure("Page got autoparsed when it shouldn't");
- }
- }
- }
- ]
- );
-
- var pane2;
-
- doh.registerGroup("pane2",
- [
- {
- name: "clear_content",
- setUp: function(t){
- pane2 = new dijit.layout.ContentPane({
- preventCache: true
- }, dojo.byId("pane2"));
- pane2.setContent();// pass undefined on purpose
- },
- runTest: function(t){
- t.assertEqual(0, dijit._Container.prototype.getChildren.call(pane2).length);
- t.assertEqual("", pane2.domNode.innerHTML)
- }
- },
- {
- name: "setContent_String",
- setUp: function(){
- pane2.setContent();
- },
- runTest: function(t){
- var msg = "<h3>a simple html string</h3>";
- pane2.setContent(msg);
- t.assertEqual(msg, pane2.domNode.innerHTML.toLowerCase());
- }
- },
- {
- name: "setContent_DOMNode",
- setUp: function(t){
- var div = dojo.doc.createElement('div');
- div.innerHTML = "setContent( [DOMNode] )";
- div.setAttribute('dojoType', 'dijit.TestWidget');
- pane2.setContent(div);
- },
- runTest: function(t){
- t.assertEqual(1, dijit._Container.prototype.getChildren.call(pane2).length);
- },
- tearDown: function(t){
- pane2.setContent(); // clear content for next test
- }
- },
- {
- name: "setContent_NodeList",
- setUp: function(t){
- var div = dojo.doc.createElement('div');
- div.innerHTML = "<div dojotype='dijit.TestWidget'>above</div>"
- +"Testing!<div><p><span><b>Deep nested</b></span></p></div>"
- +"<div dojotype='dijit.TestWidget'>below</div>";
-
- var list = div.childNodes;
- pane2.setContent(div.childNodes);
- },
- runTest: function(t){
- t.assertEqual(2, dijit._Container.prototype.getChildren.call(pane2).length);
-
- //regular DOM check
- var children = pane2.domNode.childNodes;
- t.assertEqual(4, children.length);
- t.assertEqual("Testing!", children[1].nodeValue);
- t.assertEqual("div", children[2].nodeName.toLowerCase());
- t.assertEqual("<p><span><b>deep nested</b></span></p>", children[2].innerHTML.toLowerCase());
- }
- },
- {
- name: "setContent_dojo_NodeList",
- setUp: function(t){
- pane2.setContent();
- },
- runTest: function(t){
- var div = dojo.doc.createElement('div');
- div.innerHTML = "<div dojotype='dijit.TestWidget'>above</div>"
- +"Testing!<div><p><span><b>Deep nested</b></span></p></div>"
- +"<div dojotype='dijit.TestWidget'>below</div>";
-
- var list = new dojo.NodeList();
- dojo.forEach(div.childNodes, function(n){
- list.push(n.cloneNode(true));
- });
-
- pane2.setContent(list);
- t.assertEqual(4, pane2.domNode.childNodes.length);
- }
- },
- {
- name: "extractContent",
- runTest: function(t){
- var def = pane2.extractContent;
- t.assertFalse(def);
-
- // test that it's actually working
- pane2.extractContent = true;
- pane2.setContent('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" '
- +'"http://www.w3.org/TR/html4/strict.dtd">'
- +'<html><head><style>body{font-weight:bold;}</style></head>'
- +'<body>extractContent test</body></html>');
-
- t.assertEqual("extractContent test", pane2.domNode.innerHTML);
-
- // reset back to default
- pane2.extractContent = def;
- }
- },
-
- /////////////////////////////////////////////////////////////////////////
- // We assume that our network connection has a maximum of 1.5 sec latency
- /////////////////////////////////////////////////////////////////////////
- {
- name: "setHref_loading",
- timeout: 1800,
- setUp: function(t){
- pane2.setHref('getResponse.php?messId=1');
- },
- runTest: function(t){
- var d = new tests.Deferred();
- setTimeout(d.getTestCallback(
- function(){
- t.assertEqual(1, dijit._Container.prototype.getChildren.call(pane2).length);
- })
- , 1500);
- return d;
- }
- },
- {
- name: "setHref_then_cancel",
- timeout: 2800,
- setUp: function(t){
- pane2.setContent();// clear previous
- },
- runTest: function(t){
- var msg = "This should NEVER be seen!";
- pane2.setHref('getResponse.php?delay=1000&message='+encodeURI(msg));
- var d = new t.Deferred();
- setTimeout(d.getTestCallback(
- function(){
- t.assertFalse(pane2.domNode.innerHTML == msg);
- }
- ), 2500);
-
- pane2.cancel();
-
- return d;
- }
- },
- {
- // test that setHref cancels a inflight setHref
- name: "setHref_cancels_previous_setHref",
- timeout: 2800,
- setUp: function(t){
- pane2.setContent();
- },
- runTest: function(t){
- var msgCanceled = "This should be canceled";
- pane2.setHref("getResponse.php?delay=1000&message="+encodeURI(msgCanceled));
-
- var msg = "This message should win over the previous";
- setTimeout(function(){
- pane2.setHref("getResponse.php?message="+encodeURI(msg));
- }, 900);
-
- var d = new t.Deferred();
- setTimeout(d.getTestCallback(
- function(){
- t.assertEqual(msg, pane2.domNode.innerHTML);
- }
- ), 2500);
- return d;
- }
- },
- {
- name: "setContent_cancels_setHref",
- timeout: 2800,
- setUp: function(t){
- pane2.setContent();
- },
- runTest: function(t){
- var msgCanceled = "This message be canceled";
- pane2.setHref("getResponse.php?delay=1000&message="+encodeURI(msgCanceled));
-
- var msg = "This message should win over the inflight one";
- setTimeout(function(){
- pane2.setContent(msg);
- }, 900);
-
- var d = new t.Deferred();
- setTimeout(d.getTestCallback(
- function(){
- t.assertEqual(msg, pane2.domNode.innerHTML);
- }
- ), 2500);
- return d;
- }
- },
- {
- name: "refresh",
- timeout: 1900,
- setUp: function(t){
- pane2.setHref("getResponse.php?message="+encodeURI('initial load'));
- },
- runTest: function(t){
- var msg = 'refreshed load'
- setTimeout(function(){
- pane2.href = "getResponse.php?message="+encodeURI(msg);
- pane2.refresh();
- }, 100);
-
- var d = new t.Deferred();
- setTimeout(d.getTestCallback(
- function(){
- t.assertEqual(msg, pane2.domNode.innerHTML);
- }
- ), 1600);
- return d;
-
- }
- },
- {
- name: "isLoaded",
- timeout: 1800,
- setUp: function(t){
- pane2.setContent();
- },
- runTest: function(t){
- t.assertTrue(pane2.isLoaded);
-
- pane2.setHref("getResponse.php?delay=300&message=test");
-
- t.assertFalse(pane2.isLoaded);
-
- var ilObj = {}; // a object to get a reference instead of copy
-
- // probe after 200ms
- setTimeout(function(){
- ilObj.probed = pane2.isLoaded;
- }, 200);
-
- var d = new t.Deferred();
- setTimeout(d.getTestCallback(
- function(){
- t.assertTrue(pane2.isLoaded);
- t.assertFalse(ilObj.probed);
- }
- ), 1500);
- return d;
- }
- },
- {
- // test that we does'nt load a response if we are hidden
- name: "wait_with_load_when_domNode_hidden",
- timeout: 1800,
- setUp: function(t){
- pane2.domNode.style.display = 'none';
- pane2.setContent();
- },
- runTest: function(t){
- pane2._msg = "This text should not be loaded until after widget is shown";
- pane2.setHref("getResponse.php?message="+encodeURI(pane2._msg));
- var d = new t.Deferred();
- setTimeout(d.getTestCallback(
- function(){
- t.assertFalse(pane2.domNode.innerHTML == pane2._msg);
- }
- ), 1500);
- return d;
- },
- tearDown: function(t){
- pane2.domNode.style.display = "";
- }
- },
- {
- name: "onDownloadError",
- timeout: 1800,
- setUp: function(t){
- pane2.setContent();
- },
- runTest: function(t){
- var res = {};
- var msg = "Error downloading modified message";
- var orig = pane2.onDownloadError;
-
-
- pane2.onDownloadError = function(){
- return msg;
- }
-
- this.onError = function(e){
- res.onError = true;
- res.onError_Arg = !!e;
- return "This message should be ignored as it gets invoked by dojo.connect";
- }
-
- var evtHandle = dojo.connect(pane2, 'onDownloadError', this, 'onError');
-
- // test onDownloadError
- pane2.setHref('nonexistant');
-
- // do the test
- var d = new t.Deferred();
- setTimeout(function(){
- try{
- if(!res.onError){
- d.errback(new doh._AssertFailure("onDownloadError was never invoked"));
- }
- if(!res.onError_Arg){
- d.errback(new doh._AssertFailure("onDownloadError did'nt get any argument on invokation"));
- }
- if(pane2.domNode.innerHTML != msg){
- d.errback(new doh._AssertFailure("custom errortext not set"));
- }
- d.callback(true);
- }catch(e){
- d.errback(e);
- }finally{
- // reset to default
- dojo.disconnect(evtHandle);
- pane2.onDownloadError = orig;
- }
- }, 1500);
-
- return d;
- }
- },
- {
- name: "onLoad|Unload_onDownloadStart|End",
- timeout: 2400,
- setUp:function(t){
- pane2.setContent();
- },
- runTest:function(t){
- var obj = {
- start:function(){
- this.start_called = 1;
- // check that custom message gets set
- setTimeout(function(){
- obj.start_msg = (pane2.domNode.innerHTML == msg);
- }, 20);
- },
- end: function(){ this.end_called = 1; },
- load: function(){ this.load_called = 1; },
- unload: function(){ this.unload_called = 1; }
- };
-
- //set custom message
- var origStart = pane2.onDownloadStart;
- var msg = "custom downloadstart message";
- pane2.onDownloadStart = function(){ return msg; };
-
- var startHandler = dojo.connect(pane2, 'onDownloadStart', obj, 'start');
- var endHandler = dojo.connect(pane2, 'onDownloadEnd', obj, 'end');
- var loadHandler = dojo.connect(pane2, 'onLoad', obj, 'load');
- var unloadHandler = dojo.connect(pane2, 'onUnload', obj, 'unload');
-
- pane2.setHref('getResponse.php?delay=400');
-
- var d = new t.Deferred();
- setTimeout(function(){
- try{
- if(!obj.start_called){
- d.errback(new doh._AssertFailure('onDownloadStart not called'));
- }
- if(!obj.start_msg){
- d.errback(new doh._AssertFailure('custom download message not set'));
- }
- if(!obj.end_called){
- d.errback(new doh._AssertFailure('onDownloadEnd not called'));
- }
- if(!obj.unload_called){
- d.errback(new doh._AssertFailure('onUnload not called'));
- }
- if(!obj.load_called){
- d.errback(new doh._AssertFailure('onLoad not called'));
- }
- d.callback(true);
- }catch(e){
- d.errback(e);
- }finally{
- dojo.disconnect(endHandler);
- dojo.disconnect(startHandler);
- dojo.disconnect(unloadHandler);
- dojo.disconnect(loadHandler);
-
- pane2.onDownloadStart = origStart;
- }
- }, 1900);
-
- return d;
- }
- }
-
- ]
- );
-
- var pane3, st, tmp;
-
- doh.registerGroup("child_to_StackContainer",
- [
- {
- // TODO: this test should be moved to registerGroup setUp when #3504 is fixed
- // We actually dont need to test anything here, just setUp
- name: "setUp_StackContainer",
- setUp:function(t){
- st = dojo.byId('stackcontainer');
- dojo.addClass(st, 'box');
- st = new dijit.layout.StackContainer({}, st);
-
- st.addChild(new dijit.TestWidget());
- pane3 = new dijit.layout.ContentPane({
- href:'getResponse.php?delay=300&message=Loaded!',
- preventCache: true
- }, dojo.doc.createElement('div'));
- st.addChild(pane3);
-
- pane3.startup(); // starts the ContentPane
- },
- runTest:function(t){
- t.assertTrue(st);
- t.assertEqual(2, st.getChildren().length);
- }
- },
- {
- name: "preload_false_by_default",
- runTest: function(t){
- t.assertFalse(pane3.isLoaded);
- t.assertEqual('', pane3.domNode.innerHTML);
- }
- },
- {
- name: "startLoad when selected",
- timeout: 2100,
- runTest: function(t){
- st.selectChild(pane3);
-
- var d = new t.Deferred();
- setTimeout(d.getTestCallback(
- function(){
- t.assertTrue(pane3.isLoaded);
- t.assertEqual('Loaded!', pane3.domNode.innerHTML);
- }
- ), 1800);
-
- return d;
- }
- },
- {
- name: "refreshOnShow",
- timeout: 2100,
- setUp: function(t){
- tmp = {
- onUnload: function(){ this._unload_fired = 1; },
- onLoad: function(){ this._load_fired = 1; }
- };
- tmp.unload = dojo.connect(pane3, 'onUnload', tmp, 'onUnload');
- tmp.load = dojo.connect(pane3, 'onLoad', tmp, 'onLoad');
-
- pane3.refreshOnShow = true;
- },
- runTest: function(t){
- var d = new t.Deferred();
- st.back();
- st.forward();
-
- setTimeout(d.getTestCallback(function(){
- t.assertTrue(tmp._unload_fired);
- t.assertTrue(tmp._load_fired);
- t.assertEqual('Loaded!', pane3.domNode.innerHTML);
- }), 1800);
-
- return d;
- },
- tearDown: function(){
- dojo.disconnect(tmp.unload);
- dojo.disconnect(tmp.load);
- pane3.refreshOnShow = pane3.constructor.prototype.refreshOnShow;
- }
- },
- {
- name: "downloadTriggeredOnStartup",
- timeout: 1800,
- runTest: function(t){
- var href = 'getResponse.php?message=Loaded!'
- var pane4 = new dijit.layout.ContentPane({
- href:href,
- preventCache: true
- }, dojo.doc.createElement('div'));
-
- dojo.place(pane4.domNode, pane3.domNode, 'after');
-
- pane4.startup(); // parser should call startup when djConfig.parseOnLoad=true
-
- var d = new t.Deferred();
- setTimeout(d.getTestCallback(function(){
- t.assertEqual('Loaded!', pane4.domNode.innerHTML);
- pane4.destroy();
- }), 1500);
- return d;
- }
- }
- ]
- );
-
- doh.run();
- });
- </script>
-</head>
-<body class="tundra">
- <h2>dijit.layout.ContentPane test</h2>
- <h3>Test designed to run on localhost (minimize impact from network latency)</h3>
-
- <h4>This should NOT be parsed automatically</h4>
- <div dojoType="dijit.layout.ContentPane" class="box" hasShadow="true" id="pane1">
- <div dojoType='dijit.TestWidget'>If this has a different background and a red border, the page parsed when it shouldn't</div>
- </div>
- <br/><h3>Testing ContentPane</h3>
- <div id='pane2' class='box'>
- Even tough the entire page isn't scanned for widgets,
- any sub widgets of a ContentPane will be created when a ContentPane is created<br/>
- <span id="zero" dojoType='dijit.TestWidget'>This should have a backgroundcolor and a border</span>
- <div id="one" dojoType="dijit._Widget"></div>
- <div id="two" dojoType="dijit._Widget"></div>
- <div id="three" dojoType="dijit._Widget"></div>
- </div>
- <br/><br/>
- <div id='stackcontainer'></div>
-</body>
-</html>