dojo.provide("tests.webmap.widget._WindowControlBox");

dojo.require("doh.runner");
dojo.require("webmap.widget._WindowControlBox");
dojo.require("tests.Util");

var div;
function doWindowControlBoxSetup(){
	tests.Util.resetDom();
	div = document.createElement("div");
	document.body.appendChild(div);
}

doh.register("tests.webmap.widget._WindowControlBox", 
	[
		{
			name: "hookUpWindowControlBox_closeable_true",
			widget: null,
			buttons: [],
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
				var _this = this;
				this.widget._hookUpButton = function(b){_this.buttons.push(b);};
				this.widget.minimizeNode = "minimizeNode";
				this.widget.closeNode = "closeNode";
			},
			runTest: function(){			
				this.widget.hookUpWindowControlBox(true);
				tests.assertEqual(["minimizeNode","closeNode"], this.buttons);
				this.buttons = null;
				this.widget.minimizeNode = null;
				this.widget.closeNode = null;
				this.widget.hookUpWindowControlBox(true);
				tests.assertEqual(null, this.buttons);
			}
		},
		{
			name: "hookUpWindowControlBox_closeable_false",
			widget: null,
			buttons: [],
			div: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.div = document.createElement("div");
				document.body.appendChild(this.div);
				this.widget = new webmap.widget._WindowControlBox();
				var _this = this;
				this.widget._hookUpButton = function(b){_this.buttons.push(b);};
				this.widget.minimizeNode = "minimizeNode";
				this.widget.closeNode = this.div;
			},
			runTest: function(){			
				this.widget.hookUpWindowControlBox(false);
				tests.assertEqual(["minimizeNode"], this.buttons);
				tests.assertEqual("none", dojo.style(this.widget.closeNode, "display"));
			},
			tearDown: function(){
				document.body.removeChild(this.div);
			}
		},
		{
			name: "onAfterShow",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				var shown = false;
				wcb._shown = function(){shown = true;};
				wcb.onAfterShow();
				tests.assertTrue(shown);
			}
		},
		{
			name: "onBeforeHide",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				var boxSet = false;
				wcb._setNodeBox = function(){boxSet = true;};
				wcb.hiding = false;
				wcb.onBeforeHide();
				tests.assertTrue(boxSet);
				tests.assertTrue(wcb.hiding);
			}
		},
		{
			name: "onAfterHide",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.hiding = true;
				wcb.onAfterHide();
				tests.assertFalse(wcb.hiding);
			}
		},
		{
			name: "onBeforeMininmize",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				var boxSet = false;
				wcb._setNodeBox = function(){boxSet = true;};
				wcb.onBeforeMininmize();
				tests.assertTrue(boxSet);
			}
		},
		{
			name: "onAfterMininmize",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.minimized = false;
				wcb.onAfterMininmize();
				tests.assertTrue(wcb.minimized);
			}
		},
		{
			name: "onAfterRestore",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				var shown = false;
				wcb._shown = function(){shown = true;};
				wcb.onAfterRestore();
				tests.assertTrue(shown);
			}
		},
		{
			name: "show",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.hiding = false;
				wcb.minimized = false;
				wcb.showing = false;
				var restored = false;
				wcb._restore = function(){restored = true;};
				var beforeShow = false;
				wcb.onBeforeShow = function(){beforeShow = true;};
				var args = null;
				var anim = {played:false,play:function(){this.played = true;}};
				wcb._getShowAnimation = function(a){args = a;return anim;};
				wcb.show("args");
				tests.assertFalse(restored);
				tests.assertTrue(beforeShow);
				tests.assertTrue(wcb.showing);
				tests.assertEqual("args", args);
				tests.assertTrue(anim.played);
			}
		},
		{
			name: "show_hiding_true",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.hiding = true;
				wcb.minimized = false;
				wcb.showing = false;
				var restored = false;
				wcb._restore = function(){restored = true;};
				var beforeShow = false;
				wcb.onBeforeShow = function(){beforeShow = true;};
				var args = null;
				var anim = {played:false,play:function(){this.played = true;}};
				wcb._getShowAnimation = function(a){args = a;return anim;};
				wcb.show("args");
				tests.assertFalse(restored);
				tests.assertFalse(beforeShow);
				tests.assertFalse(wcb.showing);
				tests.assertEqual(null, args);
				tests.assertFalse(anim.played);
			}
		},
		{
			name: "show_minimized_true",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.hiding = false;
				wcb.minimized = true;
				wcb.showing = false;
				var restored = false;
				wcb._restore = function(){restored = true;};
				var beforeShow = false;
				wcb.onBeforeShow = function(){beforeShow = true;};
				var args = null;
				var anim = {played:false,play:function(){this.played = true;}};
				wcb._getShowAnimation = function(a){args = a;return anim;};
				wcb.show("args");
				tests.assertTrue(restored);
				tests.assertFalse(beforeShow);
				tests.assertFalse(wcb.showing);
				tests.assertEqual(null, args);
				tests.assertFalse(anim.played);
			}
		},
		{
			name: "show_showing_true",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.hiding = false;
				wcb.minimized = false;
				wcb.showing = true;
				var restored = false;
				wcb._restore = function(){restored = true;};
				var beforeShow = false;
				wcb.onBeforeShow = function(){beforeShow = true;};
				var args = null;
				var anim = {played:false,play:function(){this.played = true;}};
				wcb._getShowAnimation = function(a){args = a;return anim;};
				wcb.show("args");
				tests.assertFalse(restored);
				tests.assertTrue(beforeShow);
				tests.assertTrue(wcb.showing);
				tests.assertEqual(null, args);
				tests.assertFalse(anim.played);
			}
		},
		{
			name: "hide",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.minimized = false;
				wcb.showing = false;
				wcb.domNode = "div";
				wcb._nodeBox = "before";
				var beforeHide = false;
				wcb.onBeforeHide = function(){beforeHide = true;};
				var node = null;
				var reminAmims = [{played:false,play:function(){this.played = true;}},{played:false,play:function(){this.played = true;}}];
				wcb._removeFromArray = function(n){node = n;return reminAmims;};
				var args = null;
				var anim = {played:false,play:function(){this.played = true;}};
				wcb._getHideAnimation = function(a){wcb._nodeBox = "after";args = a;return anim;};
				wcb.hide("args");
				tests.assertTrue(beforeHide);
				tests.assertEqual(wcb.domNode, node);
				tests.assertEqual("after", wcb._nodeBox);
				tests.assertEqual("args", args);
				for (var i = 0; i < reminAmims.length; i++)
					tests.assertTrue(reminAmims[i].played);
				tests.assertTrue(anim.played);
			}
		},
		{
			name: "hide_minimized_true",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.minimized = true;
				wcb.showing = false;
				wcb.domNode = "div";
				wcb._nodeBox = "before";
				var beforeHide = false;
				wcb.onBeforeHide = function(){beforeHide = true;};
				var node = null;
				var reminAmims = [{played:false,play:function(){this.played = true;}},{played:false,play:function(){this.played = true;}}];
				wcb._removeFromArray = function(n){node = n;return reminAmims;};
				var args = null;
				var anim = {played:false,play:function(){this.played = true;}};
				wcb._getHideAnimation = function(a){wcb._nodeBox = "after";args = a;return anim;};
				wcb.hide("args");
				tests.assertFalse(wcb.minimized);
				tests.assertTrue(beforeHide);
				tests.assertEqual(wcb.domNode, node);
				tests.assertEqual("before", wcb._nodeBox);
				tests.assertEqual("args", args);
				for (var i = 0; i < reminAmims.length; i++)
					tests.assertTrue(reminAmims[i].played);
				tests.assertTrue(anim.played);
			}
		},
		{
			name: "hide_showing_true",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.minimized = false;
				wcb.showing = true;
				wcb.domNode = "div";
				wcb._nodeBox = "before";
				var beforeHide = false;
				wcb.onBeforeHide = function(){beforeHide = true;};
				var node = null;
				var reminAmims = [{played:false,play:function(){this.played = true;}},{played:false,play:function(){this.played = true;}}];
				wcb._removeFromArray = function(n){node = n;return reminAmims;};
				var args = null;
				var anim = {played:false,play:function(){this.played = true;}};
				wcb._getHideAnimation = function(a){wcb._nodeBox = "after";args = a;return anim;};
				wcb.hide("args");
				tests.assertFalse(wcb.minimized);
				tests.assertFalse(beforeHide);
				tests.assertEqual(null, node);
				tests.assertEqual("before", wcb._nodeBox);
				tests.assertEqual(null, args);
				for (var i = 0; i < reminAmims.length; i++)
					tests.assertFalse(reminAmims[i].played);
				tests.assertFalse(anim.played);
			}
		},
		{
			name: "toggleMinimized",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb._restore = function(){restored = true;};
				wcb._minimize = function(){minimized = true;};
				wcb.minimized = true;
				var restored = false;
				var minimized = false;
				wcb.toggleMinimized();
				tests.assertTrue(restored);
				tests.assertFalse(minimized);
				wcb.minimized = false;
				var restored = false;
				var minimized = false;
				tests.assertFalse(restored);
				tests.assertFalse(minimized);
			}
		},
		{
			name: "_getShowAnimation",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				dojo.style(div, "display", "none");
				wcb.domNode = div;
				wcb._nodeBox = {l:1, t:2, w:200, h:100};
				var animArgs = null;
				var passedArgs = null;
				var box = null;
				wcb._getBox = function(){box = {l:3,t:4};return box;};
				wcb._mixinAnimArgs = function(a0, a1){animArgs = a0;passedArgs = a1;};
				var anim = wcb._getShowAnimation("passedArgs");
				tests.assertEqual("passedArgs", passedArgs);
				var expectedArgs = {node:wcb.domNode, properties:{}};
				expectedArgs.properties.left = {start:box.l, end:wcb._nodeBox.l};
				expectedArgs.properties.top = {start:box.t, end:wcb._nodeBox.t};
				expectedArgs.properties.width = {start:1, end:wcb._nodeBox.w};
				expectedArgs.properties.height = {start:1, end:wcb._nodeBox.h};
				tests.assertEqual(expectedArgs, animArgs);
				tests.assertEqual("passedArgs", passedArgs);
				tests.assertEqual("block", dojo.style(wcb.domNode, "display"));
				tests.assertEqual(div, anim.node);
				expectedArgs.properties.opacity = {start:0, end:1};
				tests.assertEqual(expectedArgs.properties, anim.properties);
				//TODO: how to test connections
			}
		},
		{
			name: "_getShowAnimation_null_nodeBox",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				dojo.style(div, "display", "none");
				wcb.domNode = div;
				wcb._nodeBox = null;
				var animArgs = null;
				var passedArgs = null;
				var box = null;
				wcb._getBox = function(){box = {l:3,t:4};return box;};
				wcb._mixinAnimArgs = function(a0, a1){animArgs = a0;passedArgs = a1;};
				var anim = wcb._getShowAnimation("passedArgs");
				tests.assertEqual(null, box);
				tests.assertEqual("passedArgs", passedArgs);
				var expectedArgs = {node:wcb.domNode, properties:{}};
				tests.assertEqual(expectedArgs, animArgs);
				tests.assertEqual("passedArgs", passedArgs);
				tests.assertEqual("none", dojo.style(wcb.domNode, "display"));
				tests.assertEqual(div, anim.node);
				expectedArgs.properties.opacity = {start:0, end:1};
				tests.assertEqual(expectedArgs.properties, anim.properties);
				//TODO: how to test connections
			}
		},
		{
			name: "_getHideAnimation",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.domNode = div;
				wcb._nodeBox = {l:1, t:2, w:200, h:100};
				var animArgs = null;
				var passedArgs = null;
				var box = null;
				wcb._getBox = function(){box = {l:3,t:4};return box;};
				wcb._mixinAnimArgs = function(a0, a1){animArgs = a0;passedArgs = a1;};
				var anim = wcb._getHideAnimation("passedArgs");
				tests.assertEqual("passedArgs", passedArgs);
				var expectedArgs = {node:wcb.domNode, properties:{}};
				expectedArgs.properties.top = {start:wcb._nodeBox.t, end:Math.round(wcb._nodeBox.t + wcb._nodeBox.h/2)};
				expectedArgs.properties.left = {start:wcb._nodeBox.l, end:Math.round(wcb._nodeBox.l + wcb._nodeBox.w/2)};
				expectedArgs.properties.height = {start:wcb._nodeBox.h, end:1};
				expectedArgs.properties.width = {start:wcb._nodeBox.w, end:1};
				expectedArgs.properties.opacity = {start:1.0, end:0.0};
				tests.assertEqual(expectedArgs, animArgs);
				tests.assertEqual("passedArgs", passedArgs);
				tests.assertEqual(div, anim.node);
				tests.assertEqual(expectedArgs.properties, anim.properties);
				//TODO: how to test connections
			}
		},
		{
			name: "_restore",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.domNode = "domNode";
				var beforeRestore = false;
				wcb.onBeforeRestore = function(){beforeRestore = true;}
				var node = null;
				var reminAmims = [{played:false,play:function(){this.played = true;}},{played:false,play:function(){this.played = true;}}];
				wcb._removeFromArray = function(n){node = n;return reminAmims;};
				var args = null;
				var anim = {played:false,play:function(){this.played = true;}};
				wcb._getRestoreAnimation = function(a){args = a;return anim;};
				wcb._restore("args");
				tests.assertTrue(beforeRestore);
				tests.assertEqual(wcb.domNode, node);
				tests.assertEqual("args", args);
				for (var i = 0; i < reminAmims.length; i++)
					tests.assertTrue(reminAmims[i].played);
				tests.assertTrue(anim.played);
			}
		},
		{
			name: "_minimize",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.domNode = "domNode";
				wcb.minimizeNode = div;
				var beforeMininmize = false;
				wcb.onBeforeMininmize = function(){beforeMininmize = true;}
				var args = null;
				var anim = {played:false,play:function(){this.played = true;}};
				wcb._getMinimizeAnimation = function(a){args = a;return anim;};
				var nodes = [];
				wcb._getMinNodes = function(){return nodes;};
				wcb._minimize("args");
				tests.assertTrue(beforeMininmize);
				tests.assertEqual("args", args);
				tests.assertTrue(anim.played);
				tests.assertEqual("webmapRestoreBox", wcb.minimizeNode.className);
				tests.assertEqual("Restore", wcb.minimizeNode.title);
				tests.assertEqual("Restore", wcb.minimizeNode.alt);
				tests.assertEqual(["domNode"], nodes);
				wcb._minimize("args");
				tests.assertEqual(["domNode"], nodes);
			}
		},
		{
			name: "_getRestoreAnimation",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				dojo.style(div, "display", "none");
				wcb.domNode = div;
				wcb._nodeBox = {l:1, t:2, w:200, h:100};
				var animArgs = null;
				var passedArgs = null;
				var box = null;
				wcb._getBox = function(){box = {l:3,t:4,w:5,h:6};return box;};
				wcb._mixinAnimArgs = function(a0, a1){animArgs = a0;passedArgs = a1;};
				var anim = wcb._getRestoreAnimation("passedArgs");
				tests.assertEqual("passedArgs", passedArgs);
				var expectedArgs = {node:wcb.domNode, properties:{}};
				expectedArgs.properties.left = {start:box.l, end:wcb._nodeBox.l};
				expectedArgs.properties.top = {start:box.t, end:wcb._nodeBox.t};
				expectedArgs.properties.width = {start:box.w, end:wcb._nodeBox.w};
				expectedArgs.properties.height = {start:box.h, end:wcb._nodeBox.h};
				tests.assertEqual(expectedArgs, animArgs);
				tests.assertEqual("passedArgs", passedArgs);
				tests.assertEqual("block", dojo.style(wcb.domNode, "display"));
				tests.assertEqual(div, anim.node);
				tests.assertEqual(expectedArgs.properties, anim.properties);
				//TODO: how to test connections
			}
		},
		{
			name: "_getRestoreAnimation_null_nodeBox",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				dojo.style(div, "display", "none");
				wcb.domNode = div;
				wcb._nodeBox = null;
				var animArgs = null;
				var passedArgs = null;
				var box = null;
				wcb._getBox = function(){box = {l:3,t:4,w:5,h:6};return box;};
				wcb._mixinAnimArgs = function(a0, a1){animArgs = a0;passedArgs = a1;};
				var anim = wcb._getRestoreAnimation("passedArgs");
				tests.assertEqual(null, box);
				tests.assertEqual("passedArgs", passedArgs);
				var expectedArgs = {node:wcb.domNode, properties:{}};
				tests.assertEqual(expectedArgs, animArgs);
				tests.assertEqual("passedArgs", passedArgs);
				tests.assertEqual("none", dojo.style(wcb.domNode, "display"));
				tests.assertEqual(div, anim.node);
				tests.assertEqual(expectedArgs.properties, anim.properties);
				//TODO: how to test connections
			}
		},
		{
			name: "_getMinimizeAnimation",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.domNode = div;
				var animArgs = null;
				var passedArgs = null;
				var minArgs = null;
				wcb._getMinimizeArgs = function(a){minArgs = a};
				wcb._mixinAnimArgs = function(a0, a1){animArgs = a0;passedArgs = a1;};
				var anim = wcb._getMinimizeAnimation("passedArgs");
				tests.assertEqual("passedArgs", passedArgs);
				var expectedArgs = {node:wcb.domNode, properties:{}};
				tests.assertEqual(expectedArgs, minArgs);
				tests.assertEqual(expectedArgs, animArgs);
				tests.assertEqual("passedArgs", passedArgs);
				tests.assertEqual(div, anim.node);
				tests.assertEqual(expectedArgs.properties, anim.properties);
				//TODO: how to test connections
			}
		},
		{
			name: "_hookUpButton",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb._connections = new Array();
				wcb._hookUpButton(div);
				tests.assertEqual(2, wcb._connections.length);
			}
		},
		{
			name: "_mouseOverButton",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				div.className = "button";
				wcb._mouseOverButton({target:div});
				tests.assertEqual("button buttonHover", div.className);
			}
		},
		{
			name: "_mouseOutButton",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				div.className = "button buttonHover";
				wcb._mouseOutButton({target:div});
				tests.assertEqual("button", div.className);
			}
		},
		{
			name: "_setNodeBox",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb._nodeBox = null;
				wcb._getBox = function(){return "box";};
				wcb._setNodeBox();
				tests.assertEqual("box", wcb._nodeBox);
			}
		},
		{
			name: "_getMinimizeArgs_lowerLeft_minArray_length_0",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb._nodeBox = {l:10,t:20,w:200,h:100};
				var win = {l:0,t:0,w:800,h:600};
				wcb._getWindowBox = function(){return win;};
				var minArray = [];
				wcb._getMinNodes = function(){return minArray;};
				var args = {properties:{}};
				wcb._getMinimizeArgs(args);
				var expected = {properties:{}};
				expected.properties.width = {start:wcb._nodeBox.w, end:wcb.minWidth};
				expected.properties.height = {start:wcb._nodeBox.h, end:wcb.minHeight};
				expected.properties.top = {start:wcb._nodeBox.t, end:(win.h - wcb.minHeight - 5)};
				expected.properties.left = {start:wcb._nodeBox.l, end:5};
				tests.assertEqual(expected, args);
			}
		},
		{
			name: "_getMinimizeArgs_lowerLeft_minArray_length_2",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb._nodeBox = {l:10,t:20,w:200,h:100};
				var win = {l:0,t:0,w:800,h:600};
				wcb._getWindowBox = function(){return win;};
				var minArray = [{offsetWidth:200},{}];
				wcb._getMinNodes = function(){return minArray;};
				var args = {properties:{}};
				wcb._getMinimizeArgs(args);
				var expected = {properties:{}};
				expected.properties.width = {start:wcb._nodeBox.w, end:wcb.minWidth};
				expected.properties.height = {start:wcb._nodeBox.h, end:wcb.minHeight};
				expected.properties.top = {start:wcb._nodeBox.t, end:(win.h - wcb.minHeight - 5)};
				expected.properties.left = {start:wcb._nodeBox.l, end:5};
				expected.properties.left.end += minArray.length * (minArray[0].offsetWidth + 5);
				tests.assertEqual(expected, args);
			}
		},
		{
			name: "_getMinimizeArgs_lowerRight_minArray_length_0",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.minimizeLocation = webmap.widget.minimizeLocation.lowerRight;
				wcb._nodeBox = {l:10,t:20,w:200,h:100};
				var win = {l:0,t:0,w:800,h:600};
				wcb._getWindowBox = function(){return win;};
				var minArray = [];
				wcb._getMinNodes = function(){return minArray;};
				var args = {properties:{}};
				wcb._getMinimizeArgs(args);
				var expected = {properties:{}};
				expected.properties.width = {start:wcb._nodeBox.w, end:wcb.minWidth};
				expected.properties.height = {start:wcb._nodeBox.h, end:wcb.minHeight};
				expected.properties.top = {start:wcb._nodeBox.t, end:(win.h - wcb.minHeight - 5)};
				expected.properties.left = {start:wcb._nodeBox.l, end:5};
				expected.properties.left = {start:wcb._nodeBox.l, end:win.w - wcb.minWidth - 5};
				tests.assertEqual(expected, args);
			}
		},
		{
			name: "_getMinimizeArgs_lowerRight_minArray_length_2",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.minimizeLocation = webmap.widget.minimizeLocation.lowerRight;
				wcb._nodeBox = {l:10,t:20,w:200,h:100};
				var win = {l:0,t:0,w:800,h:600};
				wcb._getWindowBox = function(){return win;};
				var minArray = [{offsetWidth:200},{}];
				wcb._getMinNodes = function(){return minArray;};
				var args = {properties:{}};
				wcb._getMinimizeArgs(args);
				var expected = {properties:{}};
				expected.properties.width = {start:wcb._nodeBox.w, end:wcb.minWidth};
				expected.properties.height = {start:wcb._nodeBox.h, end:wcb.minHeight};
				expected.properties.top = {start:wcb._nodeBox.t, end:(win.h - wcb.minHeight - 5)};
				expected.properties.left = {start:wcb._nodeBox.l, end:5};
				expected.properties.left = {start:wcb._nodeBox.l, end:win.w - wcb.minWidth - 5};
				expected.properties.left.end -= minArray.length * (minArray[0].offsetWidth + 5);
				tests.assertEqual(expected, args);
			}
		},
		{
			name: "_getWindowBox",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				tests.assertEqual(dijit.getViewport(), wcb._getWindowBox());
				dojo.style(div, "left", "10px");
				dojo.style(div, "top", "20px");
				dojo.style(div, "width", "800px");
				dojo.style(div, "height", "600px");
				wcb.windowNode = div;
				tests.assertEqual({l:10,t:20,w:800,h:600}, wcb._getWindowBox());
			}
		},
		{
			name: "_removeFromArray_minimizeLocation_lowerLeft",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
			},
			runTest: function(){
				console.warn("Write me!"); try{notWritten++;}catch(ignore){}
			}
		},
		{
			name: "_removeFromArray_minimizeLocation_lowerRight",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
			},
			runTest: function(){
				console.warn("Write me!"); try{notWritten++;}catch(ignore){}
			}
		},
		{
			name: "_getReMinimizeArgs_lowerLeft",
			widget: null,
			minNodesCount: 0,
			winBoxCount: 0,
			div: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
				this.div = document.createElement("div");
				document.body.appendChild(this.div);
				dojo.style(this.div, "position", "absolute");
				dojo.style(this.div, "left", "100px");
				var minNodes = [{offsetWidth:100},{offsetWidth:50}];
				var _this = this;
				this._getWindowBox = function(){_this.winBoxCount++;return {w:600};};
				this.widget._getMinNodes = function(){_this.minNodesCount++;return minNodes;};
				
			},
			runTest: function(){
				var args = {node:this.div,properties: {}};
				this.widget._getReMinimizeArgs(args, 2);
				tests.assertEqual(1, this.minNodesCount);
				tests.assertEqual(0, this.winBoxCount);
				tests.assertEqual({start:100, end:215}, args.properties.left);
				this.widget._getReMinimizeArgs(args, 3);
				tests.assertEqual(2, this.minNodesCount);
				tests.assertEqual(0, this.winBoxCount);
				tests.assertEqual({start:100, end:320}, args.properties.left);
			},
			tearDown: function(){
				document.body.removeChild(this.div);
			}
		},
		{
			name: "_getReMinimizeArgs_lowerRight",
			widget: null,
			minNodesCount: 0,
			winBoxCount: 0,
			div: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
				this.widget.minimizeLocation = webmap.widget.minimizeLocation.lowerRight;
				this.div = document.createElement("div");
				document.body.appendChild(this.div);
				dojo.style(this.div, "position", "absolute");
				dojo.style(this.div, "left", "100px");
				var minNodes = [{offsetWidth:100},{offsetWidth:50}];
				var _this = this;
				this.widget._getWindowBox = function(){_this.winBoxCount++;return {w:600};};
				this.widget._getMinNodes = function(){_this.minNodesCount++;return minNodes;};
				
			},
			runTest: function(){
				var args = {node:this.div,properties: {}};
				this.widget._getReMinimizeArgs(args, 2);
				tests.assertEqual(1, this.minNodesCount);
				tests.assertEqual(1, this.winBoxCount);
				tests.assertEqual({start:100, end:285}, args.properties.left);
				this.widget._getReMinimizeArgs(args, 3);
				tests.assertEqual(2, this.minNodesCount);
				tests.assertEqual(2, this.winBoxCount);
				tests.assertEqual({start:100, end:180}, args.properties.left);
			},
			tearDown: function(){
				document.body.removeChild(this.div);
			}
		},
		{
			name: "_getMinNodes_minimizeLocation_lowerLeft_browser_is_window_nothing_minimized",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
			},
			runTest: function(){
				tests.assertEqual({} ,webmap.widget.minLeftNodes);
				tests.assertEqual([], this.widget._getMinNodes());
				tests.assertEqual({_window:[]} ,webmap.widget.minLeftNodes);
			},
			tearDown: function(){
				webmap.widget.minLeftNodes = {};
			}
		},
		{
			name: "_getMinNodes_minimizeLocation_lowerLeft_browser_is_window_nothing_minimized",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
			},
			runTest: function(){
				tests.assertEqual({} ,webmap.widget.minLeftNodes);
				tests.assertEqual([], this.widget._getMinNodes());
				tests.assertEqual({_window:[]} ,webmap.widget.minLeftNodes);
			},
			tearDown: function(){
				webmap.widget.minLeftNodes = {};
			}
		},
		{
			name: "_getMinNodes_minimizeLocation_lowerLeft_browser_is_window_has_minimized",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
				webmap.widget.minLeftNodes = {_window:[1,2,3]};
			},
			runTest: function(){
				tests.assertEqual([1,2,3], this.widget._getMinNodes());
			},
			tearDown: function(){
				webmap.widget.minLeftNodes = {};
			}
		},
		{
			name: "_getMinNodes_minimizeLocation_lowerLeft_node_is_window_nothing_minimized",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
				this.widget.windowNode = "psuedo";
			},
			runTest: function(){
				tests.assertEqual({} ,webmap.widget.minLeftNodes);
				tests.assertEqual([], this.widget._getMinNodes());
				tests.assertEqual({psuedo:[]} ,webmap.widget.minLeftNodes);
			},
			tearDown: function(){
				webmap.widget.minLeftNodes = {};
			}
		},
		{
			name: "_getMinNodes_minimizeLocation_lowerLeft_node_is_window_nothing_minimized",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
				this.widget.windowNode = "psuedo";
				webmap.widget.minLeftNodes = {psuedo:[1,2,3]};
			},
			runTest: function(){
				tests.assertEqual([1,2,3], this.widget._getMinNodes());
			},
			tearDown: function(){
				webmap.widget.minLeftNodes = {};
			}
		},
		{
			name: "_getMinNodes_minimizeLocation_lowerRight_browser_is_window_nothing_minimized",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
				this.widget.minimizeLocation = webmap.widget.minimizeLocation.lowerRight;
			},
			runTest: function(){
				tests.assertEqual({} ,webmap.widget.minRightNodes);
				tests.assertEqual([], this.widget._getMinNodes());
				tests.assertEqual({_window:[]} ,webmap.widget.minRightNodes);
			},
			tearDown: function(){
				webmap.widget.minRightNodes = {};
			}
		},
		{
			name: "_getMinNodes_minimizeLocation_lowerRight_browser_is_window_has_minimized",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
				this.widget.minimizeLocation = webmap.widget.minimizeLocation.lowerRight;
				webmap.widget.minRightNodes = {_window:[1,2,3]};
			},
			runTest: function(){
				tests.assertEqual([1,2,3], this.widget._getMinNodes());
			},
			tearDown: function(){
				webmap.widget.minRightNodes = {};
			}
		},
		{
			name: "_getMinNodes_minimizeLocation_lowerRight_node_is_window_nothing_minimized",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
				this.widget.minimizeLocation = webmap.widget.minimizeLocation.lowerRight;
				this.widget.windowNode = "psuedo";
			},
			runTest: function(){
				tests.assertEqual({} ,webmap.widget.minRightNodes);
				tests.assertEqual([], this.widget._getMinNodes());
				tests.assertEqual({psuedo:[]} ,webmap.widget.minRightNodes);
			},
			tearDown: function(){
				webmap.widget.minRightNodes = {};
			}
		},
		{
			name: "_getMinNodes_minimizeLocation_lowerRight_node_is_window_nothing_minimized",
			widget: null,
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
				this.widget.minimizeLocation = webmap.widget.minimizeLocation.lowerRight;
				this.widget.windowNode = "psuedo";
				webmap.widget.minRightNodes = {psuedo:[1,2,3]};
			},
			runTest: function(){
				tests.assertEqual([1,2,3], this.widget._getMinNodes());
			},
			tearDown: function(){
				webmap.widget.minRightNodes = {};
			}
		},
		{
			name: "_mixinAnimArgs",
			widget: null,
			animArgs: {properties:{left:{start:"start", end:"end"},top:{start:"start", end:"end"},opacity:{start:"start", end:"end"}}},
			setUp: function(){
				doWindowControlBoxSetup();
				this.widget = new webmap.widget._WindowControlBox();
			},
			runTest: function(){
				var args = {properties:{left:{start:1, end:10},opacity:{start:0, end:100}}};
				this.widget._mixinAnimArgs(this.animArgs, args);
				tests.assertEqual({"properties": {"left": {"start": 1, "end": 10}, "top": {"start": "start", "end": "end"}, "opacity": {"start": "start", "end": 100}}}, this.animArgs);
				args.properties.left.end = "adios";
				this.widget._mixinAnimArgs(this.animArgs, args);
				tests.assertEqual({"properties": {"left": {"start": 1, "end": "adios"}, "top": {"start": "start", "end": "end"}, "opacity": {"start": "start", "end": 100}}}, this.animArgs);
			}
		},
		{
			name: "_shown",
			setUp: function(){
				doWindowControlBoxSetup();
			},
			runTest: function(){
				var wcb = new webmap.widget._WindowControlBox();
				wcb.minimized = true;
				wcb.showing = true;
				wcb._shown();
				tests.assertFalse(wcb.minimized);
				tests.assertFalse(wcb.showing);
				wcb.minimized = true;
				wcb.showing = true;
				wcb.minimizeNode = document.createElement("img");
				wcb._shown();
				tests.assertEqual("webmapMinimizeBox", wcb.minimizeNode.className);
				tests.assertEqual("Minimize", wcb.minimizeNode.title);
				tests.assertEqual("Minimize", wcb.minimizeNode.alt);
			}
		}
	]
);