dojo.provide("tests.webmap.widget.ScrollTableCalloutBox");

dojo.require("doh.runner");
dojo.require("webmap.widget.ScrollTableCalloutBox");
dojo.require("tests.Util");

var div;
function doScrollTableCalloutBoxSetup(){
	tests.Util.resetDom();
	div = document.createElement("div");
	document.body.appendChild(div);
}

doh.register("tests.webmap.widget.ScrollTableCalloutBox", 
	[
		{
			name: "setData",
			widget: null,
			datas: [],
			setUp: function(){
				var _this = this;
				this.widget = new webmap.widget.ScrollTableCalloutBox({viewType:"list", x:1, y:2}, div);
				this.widget.scrollTable = {
						setData: function(d){_this.datas.push(d);}
					};
			},
			runTest: function(){
				this.widget.setData("data");
				tests.assertEqual(["data"], this.datas);
			},
			tearDown: function(){
				this.widget.destroy();
			}
		},
		{
			name: "showQuick",
			widget: null,
			befores: 0,
			afters: 0,
			setUp: function(){
				var _this = this;
				this.widget = new webmap.widget.ScrollTableCalloutBox({
					viewType:"list", x:1, y:2,
					onBeforeShow: function(){_this.befores++;},
					onAfterShow: function(){_this.afters++;} 
				}, div);
				dojo.style(this.widget.domNode, "display", "none");
			},
			runTest: function(){
				this.widget.showQuick();
				tests.assertEqual(1, this.befores);
				tests.assertEqual(1, this.afters);
				tests.assertEqual("block", dojo.style(this.widget.domNode, "display"));
			},
			tearDown: function(){
				this.widget.destroy();
			}
		},
		{
			name: "hideQuick",
			widget: null,
			befores: 0,
			afters: 0,
			setUp: function(){
				var _this = this;
				this.widget = new webmap.widget.ScrollTableCalloutBox({
					viewType:"list", x:1, y:2,
					onBeforeHide: function(){_this.befores++;},
					onAfterHide: function(){_this.afters++;} 
				}, div);
				dojo.style(this.widget.domNode, "display", "block");
			},
			runTest: function(){
				this.widget.hideQuick();
				tests.assertEqual(1, this.befores);
				tests.assertEqual(1, this.afters);
				tests.assertEqual("none", dojo.style(this.widget.domNode, "display"));
			},
			tearDown: function(){
				this.widget.destroy();
			}
		}
	]
);