2009-11-16 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / CreateUserWizardTest.cs
index 22072b559a002852ce8ead79b4f47487294a4e76..8ae0582acb75d96d63da5a313c61d7f96efecaa9 100644 (file)
@@ -116,20 +116,54 @@ namespace MonoTests.System.Web.UI.WebControls
                {
                        base.EnsureChildControls ();
                }
-               
-               public bool DoOnBubbleEvent (EventArgs e) {
+
+               public bool DoOnBubbleEvent (EventArgs e)
+               {
                        return base.OnBubbleEvent (this, e);
                }
+
+               public int ActiveStepIndex_Before_Init;
+               public int ActiveStepIndex_After_Init;
+               protected override void OnInit (EventArgs e) {
+                       ActiveStepIndex_Before_Init = ActiveStepIndex;
+                       base.OnInit (e);
+                       ActiveStepIndex_After_Init = ActiveStepIndex;
+               }
        }
 
        [Serializable]
        [TestFixture]
        public class CreateUserWizardTest
        {
-               [SetUp]
-               public void TestSetup ()
+
+               [TestFixtureTearDown]
+               public void Unload ()
                {
-                       Thread.Sleep (150);
+                       WebTest.Unload ();
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+#if TARGET_JVM
+               [Ignore ("TD #7024")]
+#endif
+               public void ActiveStepIndex () {
+                       new WebTest (PageInvoker.CreateOnLoad (ActiveStepIndex_Load)).Run ();
+               }
+
+               public static void ActiveStepIndex_Load (Page p) {
+                       TestCreateUserWizard wizard = new TestCreateUserWizard ();
+                       p.Controls.Add (wizard);
+                       Assert.AreEqual (-1, wizard.ActiveStepIndex_Before_Init, "ActiveStepIndex_Before_Init #1");
+                       Assert.AreEqual (0, wizard.ActiveStepIndex_After_Init, "ActiveStepIndex_After_Init #1");
+                       Assert.AreEqual (2, wizard.WizardSteps.Count);
+
+                       wizard = new TestCreateUserWizard ();
+                       wizard.ActiveStepIndex = 1;
+                       p.Controls.Add (wizard);
+                       Assert.AreEqual (1, wizard.ActiveStepIndex_Before_Init, "ActiveStepIndex_Before_Init #2");
+                       Assert.AreEqual (1, wizard.ActiveStepIndex_After_Init, "ActiveStepIndex_After_Init #2");
+                       Assert.AreEqual (2, wizard.WizardSteps.Count);
                }
 
                [Test]
@@ -516,7 +550,7 @@ namespace MonoTests.System.Web.UI.WebControls
 
                private string GetDecoratedId (string html, string id)
                {
-                       Regex reg = new Regex ("name=\".*[\\$\\:_]" + id + "\"");
+                       Regex reg = new Regex ("name=\".*[\\$\\:]" + id + "\"");
                        Match match = reg.Match (html);
 
                        string fixedId = match.Value;
@@ -652,7 +686,8 @@ namespace MonoTests.System.Web.UI.WebControls
                        if (button.Length > 0)
                                fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
                        else
-                               fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
+                               //fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
 
                        test.Request = fr;
                        html = test.Run ();
@@ -706,9 +741,9 @@ namespace MonoTests.System.Web.UI.WebControls
                        fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
                        string button = GetDecoratedId (html, "StepNextButtonButton");
                        if (button.Length > 0)
-                               fr.Controls.Add (new BaseControl (button, "Create User"));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
                        else
-                               fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
 
                        test.Request = fr;
                        html = test.Run ();
@@ -725,9 +760,9 @@ namespace MonoTests.System.Web.UI.WebControls
                        fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
                        button = GetDecoratedId (html, "StepNextButtonButton");
                        if (button.Length > 0)
-                               fr.Controls.Add (new BaseControl (button, "Create User"));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
                        else
-                               fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
 
                        test.Request = fr;
                        html = test.Run ();
@@ -744,9 +779,9 @@ namespace MonoTests.System.Web.UI.WebControls
                        fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
                        button = GetDecoratedId (html, "StepNextButtonButton");
                        if (button.Length > 0)
-                               fr.Controls.Add (new BaseControl (button, "Create User"));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
                        else
-                               fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
 
                        test.Request = fr;
                        html = test.Run ();
@@ -763,9 +798,9 @@ namespace MonoTests.System.Web.UI.WebControls
                        fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
                        button = GetDecoratedId (html, "StepNextButtonButton");
                        if (button.Length > 0)
-                               fr.Controls.Add (new BaseControl (button, "Create User"));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
                        else
-                               fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
 
                        test.Request = fr;
                        html = test.Run ();
@@ -782,9 +817,9 @@ namespace MonoTests.System.Web.UI.WebControls
                        fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
                        button = GetDecoratedId (html, "StepNextButtonButton");
                        if (button.Length > 0)
-                               fr.Controls.Add (new BaseControl (button, "Create User"));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
                        else
-                               fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
 
                        test.Request = fr;
                        html = test.Run ();
@@ -801,9 +836,9 @@ namespace MonoTests.System.Web.UI.WebControls
                        fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "123"));
                        button = GetDecoratedId (html, "StepNextButtonButton");
                        if (button.Length > 0)
-                               fr.Controls.Add (new BaseControl (button, "Create User"));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
                        else
-                               fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
 
                        test.Request = fr;
                        html = test.Run ();
@@ -820,9 +855,9 @@ namespace MonoTests.System.Web.UI.WebControls
                        fr.Controls.Add (new BaseControl (GetDecoratedId (html, "Answer"), "incorrect"));
                        button = GetDecoratedId (html, "StepNextButtonButton");
                        if (button.Length > 0)
-                               fr.Controls.Add (new BaseControl (button, "Create User"));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StepNextButtonButton"), "Create User"));
                        else
-                               fr.Controls.Add (new BaseControl ("__EVENTTARGET", GetEventTarget (html, "StartNextButton")));
+                               fr.Controls.Add (new BaseControl (GetDecoratedId (html, "StartNextButton"), "Create User"));
 
                        test.Request = fr;
                        html = test.Run ();
@@ -853,9 +888,10 @@ namespace MonoTests.System.Web.UI.WebControls
                }
 
                [Test]
-               public void BibbleEvent_ContinueButtonCommand () {
+               public void BibbleEvent_ContinueButtonCommand ()
+               {
                        TestCreateUserWizard w = new TestCreateUserWizard ();
-                       w.ContinueButtonClick+=new EventHandler(w_ContinueButtonClick);
+                       w.ContinueButtonClick += new EventHandler (w_ContinueButtonClick);
                        w.FinishButtonClick += new WizardNavigationEventHandler (w_FinishButtonClick);
                        _ContinueButtonClickFlag = false;
                        _FinishButtonClickFlag = false;
@@ -869,11 +905,13 @@ namespace MonoTests.System.Web.UI.WebControls
                bool _ContinueButtonClickFlag;
                bool _FinishButtonClickFlag;
 
-               void w_ContinueButtonClick (object sender, EventArgs e) {
+               void w_ContinueButtonClick (object sender, EventArgs e)
+               {
                        _ContinueButtonClickFlag = true;
                }
 
-               void w_FinishButtonClick (object sender, WizardNavigationEventArgs e) {
+               void w_FinishButtonClick (object sender, WizardNavigationEventArgs e)
+               {
                        _FinishButtonClickFlag = true;
                }
        }