[bcl] Remove NET_4_0 defines from class libs
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / ImageMapTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.ImageMap.cs
3 //
4 // Author:
5 //  Hagit Yidov (hagity@mainsoft.com
6 //
7 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 using NUnit.Framework;
30 using System;
31 using System.IO;
32 using System.Globalization;
33 using System.Web;
34 using System.Web.UI;
35 using System.Web.UI.WebControls;
36 using MonoTests.stand_alone.WebHarness;
37 using MonoTests.SystemWeb.Framework;
38 using System.Threading;
39
40 namespace MonoTests.System.Web.UI.WebControls
41 {
42         class PokerImageMap : ImageMap
43         {
44                 // View state Stuff
45                 public PokerImageMap ()
46                 {
47                         TrackViewState ();
48                 }
49
50                 public object SaveState ()
51                 {
52                         return SaveViewState ();
53                 }
54
55                 public void LoadState (object o)
56                 {
57                         LoadViewState (o);
58                 }
59
60                 public StateBag StateBag
61                 {
62                         get { return base.ViewState; }
63                 }
64
65                 public void DoOnClick (ImageMapEventArgs e)
66                 {
67                         base.OnClick (e);
68                 }
69
70                 public void DoOnBubbleEven (Object source, ImageMapEventArgs e)
71                 {
72                         base.OnBubbleEvent (source, e);
73                 }
74
75                 // Render Method
76                 public string Render ()
77                 {
78                         StringWriter sw = new StringWriter ();
79                         HtmlTextWriter tw = new HtmlTextWriter (sw);
80
81                         Render (tw);
82                         return sw.ToString ();
83                 }
84         }
85
86         [TestFixture]
87         public class ImageMapTest
88         {
89                 [TestFixtureSetUp]
90                 public void SetUp ()
91                 {
92                         WebTest.CopyResource (GetType (), "NoEventValidation.aspx", "NoEventValidation.aspx");
93                 }
94
95
96
97                 [Test]
98                 public void ImageMap_DefaultProperties ()
99                 {
100                         PokerImageMap imageMap = new PokerImageMap ();
101                         Assert.AreEqual (0, imageMap.StateBag.Count, "ViewState.Count");
102                         Assert.AreEqual (true, imageMap.Enabled, "Enabled");
103                         Assert.AreEqual (HotSpotMode.NotSet, imageMap.HotSpotMode, "HotSpotMode");
104                         Assert.AreEqual (0, imageMap.HotSpots.Count, "HotSpots.Count");
105                         Assert.AreEqual (string.Empty, imageMap.Target, "Target");
106                 }
107
108                 [Test]
109                 public void ImageMap_AssignToDefaultProperties ()
110                 {
111                         PokerImageMap imageMap = new PokerImageMap ();
112
113                         Assert.AreEqual (0, imageMap.StateBag.Count, "ViewState.Count");
114
115                         imageMap.Enabled = true;
116                         Assert.AreEqual (true, imageMap.Enabled, "Enabled");
117                         Assert.AreEqual (0, imageMap.StateBag.Count, "ViewState.Count-1");
118
119                         imageMap.HotSpotMode = HotSpotMode.Navigate;
120                         Assert.AreEqual (HotSpotMode.Navigate, imageMap.HotSpotMode, "HotSpotMode");
121                         Assert.AreEqual (1, imageMap.StateBag.Count, "ViewState.Count-2");
122
123                         imageMap.HotSpots.Add (new CircleHotSpot ());
124                         Assert.AreEqual (1, imageMap.HotSpots.Count, "HotSpots.Count");
125                         Assert.AreEqual (1, imageMap.StateBag.Count, "ViewState.Count-3");
126
127                         imageMap.Target = "Target";
128                         Assert.AreEqual ("Target", imageMap.Target, "Target");
129                         Assert.AreEqual (2, imageMap.StateBag.Count, "ViewState.Count-4");
130                 }
131
132                 [Test]
133                 public void ImageMap_Defaults_Render ()
134                 {
135                         PokerImageMap imageMap = new PokerImageMap ();
136                         string originalHtml = "<img src=\"\" />";
137                         string renderedHtml = imageMap.Render ();
138                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderDefault");
139                 }
140
141                 [Test]
142                 public void ImageMap_AssignedValues_RenderNavigate ()
143                 {
144                         // HotSpotMode = Navigate using NavigateURL
145                         //-----------------------------------------
146                         PokerImageMap imageMap = new PokerImageMap ();
147                         imageMap.Enabled = true;
148                         imageMap.HotSpotMode = HotSpotMode.Navigate;
149                         imageMap.Target = "Target";
150                         CircleHotSpot circle = new CircleHotSpot ();
151                         circle.NavigateUrl = "NavigateURL";
152                         imageMap.HotSpots.Add (circle);
153                         string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"0,0,0\" href=\"NavigateURL\" target=\"Target\" title=\"\" alt=\"\" />\r\n</map>";
154                         string renderedHtml = imageMap.Render ();
155                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderNavigateTextAssigned");
156                 }
157
158                 [Test]
159                 public void ImageMap_AssignedValues_RenderNavigateCircle ()
160                 {
161                         // Circle.HotSpotMode = Navigate
162                         //------------------------------
163                         PokerImageMap imageMap = new PokerImageMap ();
164                         imageMap.Enabled = true;
165                         CircleHotSpot circle = new CircleHotSpot ();
166                         circle.AccessKey = "A";
167                         circle.AlternateText = "Circle";
168                         circle.HotSpotMode = HotSpotMode.Navigate;
169                         circle.NavigateUrl = "NavigateURL";
170                         circle.TabIndex = 1;
171                         circle.Radius = 10;
172                         circle.X = 30;
173                         circle.Y = 40;
174                         imageMap.HotSpots.Add (circle);
175                         string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"30,40,10\" href=\"NavigateURL\" title=\"Circle\" alt=\"Circle\" accesskey=\"A\" tabindex=\"1\" />\r\n</map>";
176                         string renderedHtml = imageMap.Render ();
177                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderNavigateCircleTextAssigned");
178                 }
179
180                 [Test]
181                 public void ImageMap_AssignedValues_RenderNavigateShapes ()
182                 {
183                         // Rectangle/Polygon.HotSpotMode = Navigate 
184                         //-----------------------------------------
185                         PokerImageMap imageMap = new PokerImageMap ();
186                         imageMap.Enabled = true;
187                         imageMap.HotSpotMode = HotSpotMode.NotSet;
188                         RectangleHotSpot rect = new RectangleHotSpot ();
189                         rect.AccessKey = "R";
190                         rect.AlternateText = "Rectangle";
191                         rect.HotSpotMode = HotSpotMode.Navigate;
192                         rect.NavigateUrl = "NavigateUrlRect";
193                         rect.TabIndex = 1;
194                         rect.Bottom = 10;
195                         rect.Top = 20;
196                         rect.Left = 30;
197                         rect.Right = 40;
198                         imageMap.HotSpots.Add (rect);
199                         imageMap.HotSpotMode = HotSpotMode.Navigate;
200                         PolygonHotSpot poly = new PolygonHotSpot ();
201                         poly.AccessKey = "P";
202                         poly.AlternateText = "Polygon";
203                         poly.NavigateUrl = "NavigateUrlPoly";
204                         poly.TabIndex = 2;
205                         poly.Coordinates = "10,20,30,40,50,60,100,200";
206                         imageMap.HotSpots.Add (poly);
207                         string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"rect\" coords=\"30,20,40,10\" href=\"NavigateUrlRect\" title=\"Rectangle\" alt=\"Rectangle\" accesskey=\"R\" tabindex=\"1\" /><area shape=\"poly\" coords=\"10,20,30,40,50,60,100,200\" href=\"NavigateUrlPoly\" title=\"Polygon\" alt=\"Polygon\" accesskey=\"P\" tabindex=\"2\" />\r\n</map>";
208                         string renderedHtml = imageMap.Render ();
209                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderNavigateShapesTextAssigned");
210                 }
211
212                 [Test]
213                 public void ImageMap_AssignedValues_RenderInactive ()
214                 {
215                         // HotSpotMode = Inactive
216                         //-----------------------
217                         PokerImageMap imageMap = new PokerImageMap ();
218                         imageMap.Enabled = true;
219                         imageMap.HotSpotMode = HotSpotMode.Inactive;
220                         imageMap.Target = "Target";
221                         imageMap.HotSpots.Add (new CircleHotSpot ());
222                         string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"0,0,0\" nohref=\"true\" title=\"\" alt=\"\" />\r\n</map>";
223                         string renderedHtml = imageMap.Render ();
224                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderInaciveTextAssigned");
225                 }
226
227                 [Test]
228                 public void ImageMap_AssignedValues_RenderDisabled ()
229                 {
230                         // Enabled = false
231                         //----------------
232                         PokerImageMap imageMap = new PokerImageMap ();
233                         imageMap.Enabled = false;
234                         imageMap.HotSpotMode = HotSpotMode.Navigate;
235                         imageMap.Target = "Target";
236                         CircleHotSpot circle = new CircleHotSpot ();
237                         circle.NavigateUrl = "NavigateURL";
238                         imageMap.HotSpots.Add (circle);
239                         string originalHtml = "<img class=\"aspNetDisabled\" src=\"\" usemap=\"#ImageMap\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"0,0,0\" target=\"Target\" title=\"\" alt=\"\" />\r\n</map>";
240                         string renderedHtml = imageMap.Render ();
241                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderDisabledTextAssigne");
242                 }
243
244                 [Test]
245                 public void ImageMap_ViewState ()
246                 {
247                         PokerImageMap imageMap = new PokerImageMap ();
248                         imageMap.Enabled = true;
249                         Assert.AreEqual (true, imageMap.Enabled, "Enabled-beforecopy");
250                         imageMap.HotSpotMode = HotSpotMode.Navigate;
251                         Assert.AreEqual (HotSpotMode.Navigate, imageMap.HotSpotMode, "HotSpotMode-beforecopy");
252                         imageMap.HotSpots.Add (new CircleHotSpot ());
253                         Assert.AreEqual (1, imageMap.HotSpots.Count, "HotSpots.Count-beforecopy");
254                         imageMap.Target = "Target";
255                         Assert.AreEqual ("Target", imageMap.Target, "Target-beforecopy");
256                         object state = imageMap.SaveState ();
257                         PokerImageMap copy = new PokerImageMap ();
258                         copy.LoadState (state);
259                         Assert.AreEqual (true, copy.Enabled, "Enabled-aftercopy");
260                         Assert.AreEqual (HotSpotMode.Navigate, copy.HotSpotMode, "HotSpotMode-aftercopy");
261                         //Assert.AreEqual(1, copy.HotSpots.Count, "HotSpots.Count-aftercopy");
262                         Assert.AreEqual ("Target", copy.Target, "Target-aftercopy");
263                 }
264
265                 // Events Stuff
266                 private bool clicked = false;
267                 private string pbValue;
268
269                 private void ImageMapClickHandler (object sender, ImageMapEventArgs e)
270                 {
271                         clicked = true;
272                         pbValue = e.PostBackValue;
273                 }
274
275                 private void ResetEvents ()
276                 {
277                         clicked = false;
278                         pbValue = "Init";
279                 }
280
281                 [Test]
282                 public void ImageMap_Event ()
283                 {
284                         PokerImageMap imageMap = new PokerImageMap ();
285                         ResetEvents ();
286                         imageMap.HotSpotMode = HotSpotMode.PostBack;
287                         imageMap.Click += new ImageMapEventHandler (ImageMapClickHandler);
288                         Assert.AreEqual (false, clicked, "BeforeClick");
289                         imageMap.DoOnClick (new ImageMapEventArgs ("HotSpotName"));
290                         Assert.AreEqual (true, clicked, "AfterClick");
291                 }
292
293                 [Test]
294                 public void ImageMap_EventCircle ()
295                 {
296                         PokerImageMap imageMap = new PokerImageMap ();
297                         ResetEvents ();
298                         imageMap.HotSpotMode = HotSpotMode.NotSet;
299                         CircleHotSpot circle = new CircleHotSpot ();
300                         circle.HotSpotMode = HotSpotMode.PostBack;
301                         circle.PostBackValue = "myCircle";
302                         imageMap.HotSpots.Add (circle);
303                         imageMap.Click += new ImageMapEventHandler (ImageMapClickHandler);
304                         Assert.AreEqual ("Init", pbValue, "BeforeClick");
305                         imageMap.DoOnClick (new ImageMapEventArgs (circle.PostBackValue));
306                         Assert.AreEqual ("myCircle", pbValue, "AfterClick");
307                 }
308
309                 [Test]
310                 public void ImageMap_EventRectangle ()
311                 {
312                         PokerImageMap imageMap = new PokerImageMap ();
313                         ResetEvents ();
314                         imageMap.HotSpotMode = HotSpotMode.PostBack;
315                         RectangleHotSpot rect = new RectangleHotSpot ();
316                         rect.PostBackValue = "myRect";
317                         imageMap.HotSpots.Add (rect);
318                         imageMap.Click += new ImageMapEventHandler (ImageMapClickHandler);
319                         Assert.AreEqual ("Init", pbValue, "BeforeClick");
320                         imageMap.DoOnClick (new ImageMapEventArgs (rect.PostBackValue));
321                         Assert.AreEqual ("myRect", pbValue, "AfterClick");
322                 }
323
324                 [Test]
325                 public void ImageMap_EventPolygon ()
326                 {
327                         PokerImageMap imageMap = new PokerImageMap ();
328                         ResetEvents ();
329                         imageMap.HotSpotMode = HotSpotMode.NotSet;
330                         PolygonHotSpot poly = new PolygonHotSpot ();
331                         poly.HotSpotMode = HotSpotMode.PostBack;
332                         poly.PostBackValue = "myPoly";
333                         imageMap.HotSpots.Add (poly);
334                         imageMap.Click += new ImageMapEventHandler (ImageMapClickHandler);
335                         Assert.AreEqual ("Init", pbValue, "BeforeClick");
336                         imageMap.DoOnClick (new ImageMapEventArgs (poly.PostBackValue));
337                         Assert.AreEqual ("myPoly", pbValue, "AfterClick");
338                 }
339
340                 public void ImageMap_BubbleEvent ()
341                 {
342                         PokerImageMap imageMap = new PokerImageMap ();
343                         ResetEvents ();
344                         ImageMapEventArgs args = new ImageMapEventArgs ("HotSpotName");
345                         imageMap.Click += new ImageMapEventHandler (ImageMapClickHandler);
346                         Assert.AreEqual (false, clicked, "BeforeClick");
347                         imageMap.DoOnBubbleEven (imageMap, args);
348                         Assert.AreEqual (true, clicked, "AfterClick");
349                 }
350
351                 private static void ImageMapClickHandler2 (object sender, ImageMapEventArgs e)
352                 {
353                         WebTest.CurrentTest.UserData = e.PostBackValue;
354                 }
355
356                 [Test]
357                 [Category ("NunitWeb")]
358                 public void ImageMap_PostBackRectangle ()
359                 {
360                         WebTest t = new WebTest (PageInvoker.CreateOnLoad (myPageLoad));
361                         t.Run ();
362                         FormRequest fr = new FormRequest (t.Response, "form1");
363                         fr.Controls.Add ("__EVENTTARGET");
364                         fr.Controls.Add ("__EVENTARGUMENT");
365                         fr.Controls["__EVENTTARGET"].Value = "imgmap";
366                         fr.Controls["__EVENTARGUMENT"].Value = "0";
367                         t.Request = fr;
368                         t.Run ();
369                         Assert.AreEqual ("Rectangle", t.UserData, "AfterPostBack");
370                 }
371
372                 [Test]
373                 [Category ("NunitWeb")]
374                 public void ImageMap_PostBackFireEvent ()
375                 {
376                         WebTest t = new WebTest ("NoEventValidation.aspx");
377                         t.Invoker = PageInvoker.CreateOnLoad (PostBackFireEvent_Init);
378                         t.Run ();
379                         FormRequest fr = new FormRequest (t.Response, "form1");
380                         fr.Controls.Add ("__EVENTTARGET");
381                         fr.Controls.Add ("__EVENTARGUMENT");
382                         fr.Controls["__EVENTTARGET"].Value = "imgmap";
383                         fr.Controls["__EVENTARGUMENT"].Value = "0";
384                         t.Request = fr;
385                         t.Run ();
386                         if (t.UserData == null)
387                                 Assert.Fail ("Event not fired fail");
388                         Assert.AreEqual ("ImageMapClickHandler", t.UserData.ToString (), "PostBackFireEvent");
389                 }
390
391                 #region PostBackFireEvent
392                 public static void PostBackFireEvent_Init (Page p)
393                 {
394                         ImageMap imgmap = new ImageMap ();
395                         imgmap.ID = "imgmap";
396                         imgmap.HotSpotMode = HotSpotMode.NotSet;
397                         imgmap.Click += new ImageMapEventHandler (ImageMapClickHandler3);
398                         RectangleHotSpot rect = new RectangleHotSpot ();
399                         rect.HotSpotMode = HotSpotMode.PostBack;
400                         rect.PostBackValue = "Rectangle";
401                         imgmap.HotSpots.Add (rect);
402                         p.Form.Controls.Add (imgmap);
403                 }
404
405                 public static void ImageMapClickHandler3 (object sender, ImageMapEventArgs e)
406                 {
407                         WebTest.CurrentTest.UserData = "ImageMapClickHandler";
408                 }
409                 #endregion
410
411                 [Test]
412                 [Category ("NunitWeb")]
413                 public void ImageMap_PostBackCircle ()
414                 {
415                         WebTest t = new WebTest (PageInvoker.CreateOnLoad (myPageLoad));
416                         t.Run ();
417                         FormRequest fr = new FormRequest (t.Response, "form1");
418                         fr.Controls.Add ("__EVENTTARGET");
419                         fr.Controls.Add ("__EVENTARGUMENT");
420                         fr.Controls["__EVENTTARGET"].Value = "imgmap";
421                         fr.Controls["__EVENTARGUMENT"].Value = "2";
422                         t.Request = fr;
423                         t.Run ();
424                         Assert.AreEqual ("Circle", t.UserData, "AfterPostBack");
425                 }
426
427                 [Test]
428                 [Category ("NunitWeb")]
429                 public void ImageMap_PostBackPolygon ()
430                 {
431                         WebTest t = new WebTest (PageInvoker.CreateOnLoad (myPageLoad));
432                         t.Run ();
433                         FormRequest fr = new FormRequest (t.Response, "form1");
434                         fr.Controls.Add ("__EVENTTARGET");
435                         fr.Controls.Add ("__EVENTARGUMENT");
436                         fr.Controls["__EVENTTARGET"].Value = "imgmap";
437                         fr.Controls["__EVENTARGUMENT"].Value = "1";
438                         t.Request = fr;
439                         t.Run ();
440                         Assert.AreEqual ("Polygon", t.UserData, "AfterPostBack");
441                 }
442
443                 [Test]
444                 [Category ("NunitWeb")]
445                 public void ImageMap_PostBack_RenderBefore ()
446                 {
447                         WebTest t = new WebTest (PageInvoker.CreateOnLoad (myPageLoad));
448                         #region orig
449                         string strTarget = "<img id=\"imgmap\" src=\"\" usemap=\"#ImageMapimgmap\" /><map name=\"ImageMapimgmap\" id=\"ImageMapimgmap\">\r\n\t<area shape=\"rect\" coords=\"0,0,0,0\" href=\"javascript:__doPostBack(&#39;imgmap&#39;,&#39;0&#39;)\" title=\"\" alt=\"\" /><area shape=\"poly\" coords=\"\" href=\"javascript:__doPostBack(&#39;imgmap&#39;,&#39;1&#39;)\" title=\"\" alt=\"\" /><area shape=\"circle\" coords=\"0,0,0\" href=\"javascript:__doPostBack(&#39;imgmap&#39;,&#39;2&#39;)\" title=\"\" alt=\"\" />\r\n</map>";
450                         #endregion
451                         string RenderedPageHtml = t.Run ();
452                         string RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
453                         HtmlDiff.AssertAreEqual (strTarget, RenderedControlHtml, "BeforePostBack");
454                 }
455
456                 [Test]
457                 [Category ("NunitWeb")]
458                 public void ImageMap_PostBack_RenderAfter ()
459                 {
460                         WebTest t = new WebTest (PageInvoker.CreateOnLoad (myPageLoad));
461                         t.Run ();
462                         FormRequest fr = new FormRequest (t.Response, "form1");
463                         fr.Controls.Add ("__EVENTTARGET");
464                         fr.Controls.Add ("__EVENTARGUMENT");
465                         fr.Controls["__EVENTTARGET"].Value = "imgmap";
466                         fr.Controls["__EVENTARGUMENT"].Value = "0";
467                         t.Request = fr;
468                         #region orig
469                         string strTarget = "<img id=\"imgmap\" src=\"\" usemap=\"#ImageMapimgmap\" /><map name=\"ImageMapimgmap\" id=\"ImageMapimgmap\">\r\n\t<area shape=\"rect\" coords=\"0,0,0,0\" href=\"javascript:__doPostBack(&#39;imgmap&#39;,&#39;0&#39;)\" title=\"\" alt=\"\" /><area shape=\"poly\" coords=\"\" href=\"javascript:__doPostBack(&#39;imgmap&#39;,&#39;1&#39;)\" title=\"\" alt=\"\" /><area shape=\"circle\" coords=\"0,0,0\" href=\"javascript:__doPostBack(&#39;imgmap&#39;,&#39;2&#39;)\" title=\"\" alt=\"\" />\r\n</map>";
470                         #endregion
471                         string RenderedPageHtml = t.Run ();
472                         string RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
473                         HtmlDiff.AssertAreEqual (strTarget, RenderedControlHtml, "AfterPostBack");
474                 }
475
476                 public static void myPageLoad (Page page)
477                 {
478                         WebTest.CurrentTest.UserData = "Init";
479                         ImageMap imgmap = new ImageMap ();
480                         imgmap.ID = "imgmap";
481                         imgmap.HotSpotMode = HotSpotMode.NotSet;
482                         imgmap.Click += new ImageMapEventHandler (ImageMapClickHandler2);
483                         RectangleHotSpot rect = new RectangleHotSpot ();
484                         rect.HotSpotMode = HotSpotMode.PostBack;
485                         rect.PostBackValue = "Rectangle";
486                         imgmap.HotSpots.Add (rect);
487                         PolygonHotSpot poly = new PolygonHotSpot ();
488                         poly.HotSpotMode = HotSpotMode.PostBack;
489                         poly.PostBackValue = "Polygon";
490                         imgmap.HotSpots.Add (poly);
491                         imgmap.HotSpotMode = HotSpotMode.PostBack;
492                         CircleHotSpot circle = new CircleHotSpot ();
493                         circle.PostBackValue = "Circle";
494                         imgmap.HotSpots.Add (circle);
495                         // Two marks for getting controls from form
496                         LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
497                         LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
498                         page.Form.Controls.Add (lcb);
499                         page.Form.Controls.Add (imgmap);
500                         page.Form.Controls.Add (lce);
501                 }
502
503                 [SetUp]
504                 public void SetUpTest ()
505                 {
506                         Thread.Sleep (100);
507                 }
508
509                 [TestFixtureTearDown]
510                 public void TearDown ()
511                 {
512                         WebTest.Unload ();
513                 }
514         }
515 }
516
517