Author: yonik
Date: 2006-08-10 10:09:04 -0400 (Thu, 10 Aug 2006)
New Revision: 63591

Added:
   trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/CallBackTest.cs
   trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/CallbackTest1.aspx
   trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/CallbackTest2.aspx
Modified:
   trunk/mcs/class/System.Web/ChangeLog
   trunk/mcs/class/System.Web/Makefile
   trunk/mcs/class/System.Web/System.Web_test.dll.sources
   trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
   trunk/mcs/class/System.Web/Test/mainsoft/ChangeLog
Log:
Add new test CallBackTest.cs and 2 new resources for this test 
CallbackTest1.aspx and CallbackTest2.aspx

Modified: trunk/mcs/class/System.Web/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/ChangeLog        2006-08-10 14:05:55 UTC (rev 
63590)
+++ trunk/mcs/class/System.Web/ChangeLog        2006-08-10 14:09:04 UTC (rev 
63591)
@@ -1,3 +1,8 @@
+2006-08-10 Yoni Klain <[EMAIL PROTECTED]>
+       
+       * System.Web_test.dll.sources:add new CallBackTest.cs                   
 
+       * Makefile: add resources for CallBackTest - CallbackTest2.aspx; 
CallbackTest1.aspx
+
 2006-08-010 Hagit Yidov <[EMAIL PROTECTED]>
                                 
        * System.Web_test.dll.sources:add ImageMapTest.cs 

Modified: trunk/mcs/class/System.Web/Makefile
===================================================================
--- trunk/mcs/class/System.Web/Makefile 2006-08-10 14:05:55 UTC (rev 63590)
+++ trunk/mcs/class/System.Web/Makefile 2006-08-10 14:09:04 UTC (rev 63591)
@@ -100,6 +100,8 @@
        Test/mainsoft/NunitWebResources/XMLDataSourceTest4.aspx \
        Test/mainsoft/NunitWebResources/LoginViewTest1.aspx \
        Test/mainsoft/NunitWebResources/WebLogin.config \
+       Test/mainsoft/NunitWebResources/CallbackTest1.aspx \
+       Test/mainsoft/NunitWebResources/CallbackTest2.aspx \
        Test/mainsoft/MainsoftWebTest/nunitweb_config.xml 
 
 NUNIT_RESOURCE_FILES = $(TEST_RESOURCE_FILES)

Modified: trunk/mcs/class/System.Web/System.Web_test.dll.sources
===================================================================
--- trunk/mcs/class/System.Web/System.Web_test.dll.sources      2006-08-10 
14:05:55 UTC (rev 63590)
+++ trunk/mcs/class/System.Web/System.Web_test.dll.sources      2006-08-10 
14:09:04 UTC (rev 63591)
@@ -135,6 +135,7 @@
 System.Web.UI.WebControls/ButtonTest.cs
 System.Web.UI.WebControls/CalendarDayTest.cs
 System.Web.UI.WebControls/CalendarTest.cs
+System.Web.UI.WebControls/CallBackTest.cs
 System.Web.UI.WebControls/CheckBoxFieldTest.cs
 System.Web.UI.WebControls/CheckBoxListTest.cs
 System.Web.UI.WebControls/CheckBoxTest.cs

Added: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/CallBackTest.cs
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/CallBackTest.cs   
2006-08-10 14:05:55 UTC (rev 63590)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/CallBackTest.cs   
2006-08-10 14:09:04 UTC (rev 63591)
@@ -0,0 +1,155 @@
+//
+// Tests for System.Web.UI.WebControls.CallBackTest.cs
+//
+// Author:
+//     Yoni Klein ([EMAIL PROTECTED])
+//
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using MonoTests.SystemWeb.Framework;
+using System.Web.UI;
+using System.Threading;
+
+namespace MonoTests.System.Web.UI.WebControls
+{
+
+
+       [TestFixture]
+       public class CallBackTest
+       {
+               [TestFixtureSetUp]
+               public void Set_Up ()
+               {
+#if DOT_NET
+                       WebTest.CopyResource (GetType (), 
"MonoTests.System.Web.UI.WebControls.Resources.CallbackTest1.aspx", 
"CallbackTest1.aspx");
+                       WebTest.CopyResource (GetType (), 
"MonoTests.System.Web.UI.WebControls.Resources.CallbackTest2.aspx", 
"CallbackTest2.aspx");
+#else
+                       WebTest.CopyResource (GetType (), "CallbackTest1.aspx", 
"CallbackTest1.aspx");
+                       WebTest.CopyResource (GetType (), "CallbackTest2.aspx", 
"CallbackTest2.aspx");
+#endif
+               }
+
+               [SetUp]
+               public void SetupTestCase ()
+               {
+                       Thread.Sleep (100);
+               }
+
+               [Test]
+               [Category("NunitWeb")]
+               [Category("NotWorking")]
+               public void CallBackResulrValues ()
+               {
+                       WebTest t = new WebTest ("CallbackTest1.aspx");
+                       string html = t.Run ();
+                       PageDelegates pd = new PageDelegates ();
+                       pd.Load = Load;
+                       t.Invoker = new PageInvoker (pd);
+
+                       FormRequest fr = new FormRequest (t.Response, "form1");
+                       fr.Controls.Add ("__EVENTTARGET");
+                       fr.Controls.Add ("__EVENTARGUMENT");
+                       fr.Controls.Add ("__CALLBACKID");
+                       fr.Controls.Add ("__CALLBACKPARAM");
+                       fr.Controls["__EVENTTARGET"].Value = "";
+                       fr.Controls["__EVENTARGUMENT"].Value = "";
+                       fr.Controls["__CALLBACKID"].Value = "__Page";
+                       fr.Controls["__CALLBACKPARAM"].Value = "monitor";
+
+                       t.Request = fr;
+                       html = t.Run ();
+                       
+                       // Into result string the last 2 variables shows if 
events been done
+                       // first - RaiseCallbackEvent
+                       // second - GetCallbackResult
+
+                       Assert.AreEqual ("0|12|true|true", html, "CallBack#1");
+
+                       fr.Controls["__EVENTTARGET"].Value = "";
+                       fr.Controls["__EVENTARGUMENT"].Value = "";
+                       fr.Controls["__CALLBACKID"].Value = "__Page";
+                       fr.Controls["__CALLBACKPARAM"].Value = "laptop";
+
+                       t.Request = fr;
+                       html = t.Run ();
+
+                       // Into result string the last 2 variables shows if 
events been done
+                       // first - RaiseCallbackEvent
+                       // second - GetCallbackResult
+
+                       Assert.AreEqual ("0|10|true|true", html, "CallBack#2");
+               }
+
+               public static void Load (Page p)
+               {
+                       Assert.AreEqual (true, p.IsCallback, 
"IsCallbackDoneFail");
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+               [Category ("NotWorking")]
+               public void CallBackFlow ()
+               {
+                       WebTest t = new WebTest ("CallbackTest2.aspx");
+                       string html = t.Run ();
+
+                       PageDelegates pd = new PageDelegates ();
+                       pd.Load = callBackFlow_Load;
+                       t.Invoker = new PageInvoker (pd);
+
+                       FormRequest fr = new FormRequest (t.Response, "form1");
+                       fr.Controls.Add ("__EVENTTARGET");
+                       fr.Controls.Add ("__EVENTARGUMENT");
+                       fr.Controls.Add ("__CALLBACKID");
+                       fr.Controls.Add ("__CALLBACKPARAM");
+                       fr.Controls["__EVENTTARGET"].Value = "";
+                       fr.Controls["__EVENTARGUMENT"].Value = "";
+                       fr.Controls["__CALLBACKID"].Value = "__Page";
+                       fr.Controls["__CALLBACKPARAM"].Value = "";
+                       t.Request = fr;
+                       
+                       html = t.Run ();
+
+                       // GetCallbackResult return string contained all flow 
functions name
+
+                       Assert.AreEqual 
("0||PreInit|Init|InitComplete|PreLoad|Load|LoadComplete|RaiseCallbackEvent|GetCallbackResult",
 html, "CallBackPageFlow"); 
+               }
+
+               public static void callBackFlow_Load (Page p)
+               {
+                       Assert.AreEqual (true, p.IsCallback, 
"IsCallbackDoneFail");
+               }
+
+               [TestFixtureTearDown]
+               public void Unload ()
+               {
+                       WebTest.Unload ();
+               }
+       }
+}

Modified: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog 
2006-08-10 14:05:55 UTC (rev 63590)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog 
2006-08-10 14:09:04 UTC (rev 63591)
@@ -1,3 +1,7 @@
+2006-08-10 Yoni Klain <[EMAIL PROTECTED]>
+
+       * CallBackTest.cs: New test was added
+
 2006-08-010 Hagit Yidov <[EMAIL PROTECTED]>
 
        * ImageMapTest.cs: New test was added

Modified: trunk/mcs/class/System.Web/Test/mainsoft/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/mainsoft/ChangeLog  2006-08-10 14:05:55 UTC 
(rev 63590)
+++ trunk/mcs/class/System.Web/Test/mainsoft/ChangeLog  2006-08-10 14:09:04 UTC 
(rev 63591)
@@ -1,3 +1,7 @@
+2006-08-10 Yoni Klain <[EMAIL PROTECTED]>
+
+       * new resources : CallbackTest1.aspx; CallbackTest2.aspx 
+
 2006-08-08 Yoni Klain <[EMAIL PROTECTED]>
 
        * new: WebLogin.config; LoginViewTest1.aspx

Added: 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/CallbackTest1.aspx
===================================================================
--- 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/CallbackTest1.aspx   
    2006-08-10 14:05:55 UTC (rev 63590)
+++ 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/CallbackTest1.aspx   
    2006-08-10 14:09:04 UTC (rev 63591)
@@ -0,0 +1,104 @@
+<%@ Page Language="C#" AutoEventWireup="true" %>
+<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %> 
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+
+  <script runat="server" >
+      protected System.Collections.Specialized.ListDictionary catalog;
+      protected String returnValue;
+      public bool raiseCallbackEvent;
+      public bool getCallbackResult;
+      protected void Page_Load (object sender, EventArgs e)
+      {
+          String cbReference =
+             Page.ClientScript.GetCallbackEventReference (this,
+             "arg", "ReceiveServerData", "context", null, false);
+          String callbackScript;
+          callbackScript = "function CallServer(arg, context)" +
+             "{ " + cbReference + ";}";
+          Page.ClientScript.RegisterClientScriptBlock (this.GetType (),
+             "CallServer", callbackScript, true);
+          catalog = new System.Collections.Specialized.ListDictionary ();
+          catalog.Add ("monitor", 12);
+          catalog.Add ("laptop", 10);
+          catalog.Add ("keyboard", 23);
+          catalog.Add ("mouse", 17);
+
+          ListBox1.DataSource = catalog;
+          ListBox1.DataTextField = "key";
+          ListBox1.DataBind ();
+      }
+
+      protected override void OnPreInit (EventArgs e)
+      {
+          MonoTests.SystemWeb.Framework.WebTest t = 
MonoTests.SystemWeb.Framework.WebTest.CurrentTest;
+          if (t != null)
+              t.Invoke (this);
+          
+          base.OnPreInit (e);
+      }
+
+      
+
+      void System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent (String 
eventArgument)
+      {
+          raiseCallbackEvent = true;
+          if (catalog[eventArgument] == null) {
+              returnValue = "-1";
+          }
+          else {
+              returnValue = catalog[eventArgument].ToString ();
+          }
+      }
+
+      String System.Web.UI.ICallbackEventHandler.GetCallbackResult ()
+      {
+          getCallbackResult = true;
+          
+          if (getCallbackResult == true)
+              returnValue += "|true";
+          else
+              returnValue += "|false";
+          
+          if (raiseCallbackEvent == true)
+              returnValue += "|true";
+          else
+              returnValue += "|false";  
+          
+          return returnValue;
+      }
+      
+  </script>
+   
+<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" >
+<head id="Head1" runat="server">
+  <title>Client Callback Example</title>
+  
+  <script type="text/ecmascript">
+    function LookUpStock()
+    {
+        var lb = document.getElementById("ListBox1");
+        var product = lb.options[lb.selectedIndex].text;
+        CallServer(product, "");
+    }
+    
+    function ReceiveServerData(rValue)
+    {   
+        document.getElementById("ResultsSpan").innerHTML = rValue;
+    }
+  </script>
+</head>
+<body>
+  <form id="form1" runat="server">
+    <div>
+      <asp:ListBox ID="ListBox1" Runat="server"></asp:ListBox>
+      <br />
+      <br />
+      <button type="Button" onclick="LookUpStock()">Look Up Stock</button>
+      <br />
+      <br />
+      Items in stock: <span id="ResultsSpan" runat="server"></span>
+      <br />
+    </div>
+  </form>
+</body>
+</html>
\ No newline at end of file

Added: 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/CallbackTest2.aspx
===================================================================
--- 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/CallbackTest2.aspx   
    2006-08-10 14:05:55 UTC (rev 63590)
+++ 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/CallbackTest2.aspx   
    2006-08-10 14:09:04 UTC (rev 63591)
@@ -0,0 +1,109 @@
+<%@ Page Language="C#" AutoEventWireup="true" %>
+<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %> 
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+
+  <script runat="server" >
+      
+      
+      protected String returnValue;
+      protected void Page_Load (object sender, EventArgs e)
+      {
+          String cbReference =
+             Page.ClientScript.GetCallbackEventReference (this,
+             "arg", "ReceiveServerData", "context", null, false);
+          String callbackScript;
+          callbackScript = "function CallServer(arg, context)" +
+             "{ " + cbReference + ";}";
+          Page.ClientScript.RegisterClientScriptBlock (this.GetType (),
+             "CallServer", callbackScript, true);
+          returnValue += "|Load";
+      }
+
+      protected override void OnPreInit (EventArgs e)
+      {
+          MonoTests.SystemWeb.Framework.WebTest t = 
MonoTests.SystemWeb.Framework.WebTest.CurrentTest;
+          if (t != null)
+              t.Invoke (this);
+          returnValue += "|PreInit";
+          base.OnPreInit (e);
+      }
+
+      protected override void OnInit (EventArgs e)
+      {
+          returnValue += "|Init";
+          base.OnInit (e);
+      }
+
+      protected override void OnInitComplete (EventArgs e)
+      {
+          returnValue += "|InitComplete";
+          base.OnInitComplete (e);
+      }
+
+      protected override void OnLoadComplete (EventArgs e)
+      {
+          returnValue += "|LoadComplete";
+          base.OnLoadComplete (e);
+      }
+
+      protected override void OnPreLoad (EventArgs e)
+      {
+          returnValue += "|PreLoad";
+          base.OnPreLoad (e);
+      }
+
+      protected override void OnPreRender (EventArgs e)
+      {
+          returnValue += "|PreRender";
+          base.OnPreRender (e);
+      }
+
+      protected override void OnUnload (EventArgs e)
+      {
+          returnValue += "|Unload";
+          base.OnUnload (e);
+      }
+
+      protected override void OnSaveStateComplete (EventArgs e)
+      {
+          returnValue += "|SaveStateComplete";
+          base.OnSaveStateComplete (e);
+      }
+
+      void System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent (String 
eventArgument)
+      {
+          returnValue += "|RaiseCallbackEvent";
+      }
+
+      String System.Web.UI.ICallbackEventHandler.GetCallbackResult ()
+      {
+          returnValue += "|GetCallbackResult";
+          return returnValue;
+      }
+      
+  </script>
+   
+<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" >
+<head id="Head1" runat="server">
+  <title>Client Callback Example</title>
+  
+  <script type="text/ecmascript">
+    function LookUpStock()
+    {
+        CallServer("" , "");
+    }
+    
+    function ReceiveServerData(rValue)
+    {   
+        
+    }
+  </script>
+</head>
+<body>
+  <form id="form1" runat="server">
+    <div>
+      
+    </div>
+  </form>
+</body>
+</html>
\ No newline at end of file

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to