Quellcode durchsuchen

2005-09-29 Gonzalo Paniagua Javier <[email protected]>

	* TableCellTest.cs: the "Text" viewstate value does not control whether
	we render the children or not.

	* EditCommandColumnTest.cs: some tests do not pass on MS rutime for me,
	so I've made them NotDotNet and fixed all the problems. Also added tests
	to ensure that the TextBox's form the BoundColumns are present in the
	hierarchy, as before we did nothing there.
	
	* ButtonTest.cs: test to show that a Button's children are not rendered.


svn path=/trunk/mcs/; revision=51016
Gonzalo Paniagua Javier vor 20 Jahren
Ursprung
Commit
e202ca1f06

+ 14 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/ButtonTest.cs

@@ -3,6 +3,7 @@
 //
 // Author:
 //	Jordi Mas i Hernandez ([email protected])
+//	Gonzalo Paniagua Javier ([email protected])
 //
 
 //
@@ -110,6 +111,19 @@ namespace MonoTests.System.Web.UI.WebControls
 			Assert.AreEqual (true, sw.ToString().IndexOf ("<input") != -1, "A5");
 			Assert.AreEqual (true, sw.ToString().IndexOf ("type=\"submit\"") != -1, "A6");
 		}
+
+		[Test]
+		public void IgnoresChildren ()
+		{
+			Button b = new  Button ();
+			b.Controls.Add (new LiteralControl ("hola"));
+			Assert.AreEqual (1, b.Controls.Count, "controls");
+			StringWriter sw = new StringWriter ();
+			HtmlTextWriter tw = new HtmlTextWriter (sw);
+			b.RenderControl (tw);
+			string str = tw.ToString ();
+			Assert.AreEqual (-1, str.IndexOf ("hola"), "hola");
+		}
 	}
 }
 

+ 12 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,15 @@
+2005-09-29 Gonzalo Paniagua Javier <[email protected]>
+
+	* TableCellTest.cs: the "Text" viewstate value does not control whether
+	we render the children or not.
+
+	* EditCommandColumnTest.cs: some tests do not pass on MS rutime for me,
+	so I've made them NotDotNet and fixed all the problems. Also added tests
+	to ensure that the TextBox's form the BoundColumns are present in the
+	hierarchy, as before we did nothing there.
+	
+	* ButtonTest.cs: test to show that a Button's children are not rendered.
+
 2005-09-29 Gonzalo Paniagua Javier <[email protected]>
 
 	* PagedDataSourceTest.cs: more tests.

+ 32 - 8
mcs/class/System.Web/Test/System.Web.UI.WebControls/EditCommandColumnTest.cs

@@ -34,6 +34,7 @@ using System.Collections;
 using System.Data;
 using System.IO;
 using System.Globalization;
+using System.Text;
 using System.Web;
 using System.Web.UI;
 using System.Web.UI.WebControls;
@@ -110,6 +111,7 @@ namespace MonoTests.System.Web.UI.WebControls
 		}
 
 		[Test]
+		[Category ("NotDotNet")]
 		public void InitializeCell () {
 			DataGridTest	p = new DataGridTest ();
 			DataTable	table = new DataTable ();
@@ -156,7 +158,7 @@ namespace MonoTests.System.Web.UI.WebControls
 #else
 			Assert.AreEqual (
 				"<table border=\"0\" id=\"sucker\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td>" +
-				"</tr><tr><td><a>Edit</a></td><td><input name type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" + 
+				"</tr><tr><td><a>Edit</a></td><td><input name=\"sucker:_ctl1:_ctl0\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" + 
 				"</tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>" +
 				"</tr></table>", markup, "I2");
 #endif
@@ -164,6 +166,7 @@ namespace MonoTests.System.Web.UI.WebControls
 		}
 
 		[Test]
+		[Category ("NotDotNet")]
 		public void ThisIsADGTest () {
 			DataGridTest	p = new DataGridTest ();
 			DataTable	table = new DataTable ();
@@ -213,13 +216,22 @@ namespace MonoTests.System.Web.UI.WebControls
 #else
 			Assert.AreEqual (
 				"<table border=\"0\" id=\"sucker_tbl\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td>" +
-				"</tr><tr><td><a>Edit</a></td><td><input name type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" + 
+				"</tr><tr><td><a>Edit</a></td><td><input name=\"sucker:_ctl1:_ctl0\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" + 
 				"</tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>" +
 				"</tr></table>", markup, "I2");
 #endif
 		}
 
+		static void GetHierarchy (ControlCollection coll, int level, StringBuilder sb)
+		{
+			foreach (Control c in coll) {
+				sb.AppendFormat ("{0}{1}\n", new string (' ', 2 * level), c.GetType ());
+				GetHierarchy (c.Controls, level + 1, sb);
+			}
+		}
+
 		[Test]
+		[Category ("NotDotNet")]
 		public void InitializeEditCell () {
 			DataGridTest	p = new DataGridTest ();
 			DataTable	table = new DataTable ();
@@ -254,6 +266,19 @@ namespace MonoTests.System.Web.UI.WebControls
 			p.CreateControls (true);
 			p.ID = "sucker";
 
+			StringBuilder sb = new StringBuilder ();
+			GetHierarchy (p.Controls, 0, sb);
+			string h = sb.ToString ();
+			int x = h.IndexOf (".TextBox");
+			// These are from the BoundColumns
+			Assert.IsTrue (x != -1, "textbox1");
+			x = h.IndexOf (".TextBox", x + 1);
+			Assert.IsTrue (x != -1, "textbox2");
+			x = h.IndexOf (".TextBox", x + 1);
+			Assert.IsTrue (x != -1, "textbox3");
+			x = h.IndexOf (".TextBox", x + 1);
+			Assert.IsTrue (x == -1, "textbox-end");
+
 			markup = ControlMarkup (p.Controls[0]);
 			markup = markup.Replace ("\t", "");
 			markup = markup.Replace ("\r", "");
@@ -275,11 +300,11 @@ namespace MonoTests.System.Web.UI.WebControls
 #else
 			Assert.AreEqual (
 				"<table border=\"0\" id=\"sucker\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td>" +
-				"</tr><tr><td><a>Update</a>&nbsp;<a>Cancel</a></td><td><input name type=\"submit\" value=\"Refresh\" />&nbsp;" +
-				"<input name type=\"submit\" value=\"Abbrechen\" /></td>" +
-				"<td><input name=\"sucker:_ctl2:_ctl0\" type=\"text\" value=\"1\" /></td>" +
-				"<td><input name=\"sucker:_ctl2:_ctl1\" type=\"text\" value=\"2\" /></td>" +
-				"<td><input name=\"sucker:_ctl2:_ctl2\" type=\"text\" value=\"3\" /></td>" + 
+				"</tr><tr><td><a>Update</a>&nbsp;<a>Cancel</a></td><td><input name=\"sucker:_ctl1:_ctl0\" type=\"submit\" value=\"Refresh\" />&nbsp;" +
+				"<input name=\"sucker:_ctl1:_ctl1\" type=\"submit\" value=\"Abbrechen\" /></td>" +
+				"<td><input name=\"sucker:_ctl1:_ctl2\" type=\"text\" value=\"1\" /></td>" +
+				"<td><input name=\"sucker:_ctl1:_ctl3\" type=\"text\" value=\"2\" /></td>" +
+				"<td><input name=\"sucker:_ctl1:_ctl4\" type=\"text\" value=\"3\" /></td>" + 
 				"</tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>" +
 				"</tr></table>", markup, "I2");
 #endif
@@ -328,7 +353,6 @@ namespace MonoTests.System.Web.UI.WebControls
 			markup = markup.Replace ("\r", "");
 			markup = markup.Replace ("\n", "");
 
-			Console.WriteLine ("Markup:>{0}<", markup);
 			Assert.AreEqual (2, p.Columns.Count, "I1");
 			Assert.AreEqual (
 				"<table border=\"0\" id=\"sucker\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td>" +

+ 22 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/TableCellTest.cs

@@ -357,6 +357,28 @@ namespace MonoTests.System.Web.UI.WebControls {
 			Assert.AreEqual (null, tc.ID, "#01");
 			page.Controls.Add (tc);
 			Assert.AreEqual (null, tc.ID, "#02");
+			Assert.IsNotNull (tc.UniqueID, "#03");
+			Assert.IsNull (tc.ID, "#04");
+		}
+
+		[Test]
+		public void PropertyOrControls ()
+		{
+			TestTableCell tc = new TestTableCell ();
+			tc.Controls.Add (new LiteralControl ("hola"));
+			tc.StateBag ["Text"] = "adios";
+			string str = tc.Render ();
+			Assert.AreEqual (1, tc.Controls.Count, "#01");
+			Assert.IsTrue (-1 != str.IndexOf ("hola"), "#02");
+			Assert.IsTrue (-1 == str.IndexOf ("adios"), "#03");
+
+			tc = new TestTableCell ();
+			tc.StateBag ["Text"] = "adios";
+			str = tc.Render ();
+			Assert.AreEqual (0, tc.Controls.Count, "#04");
+			Assert.IsTrue (-1 == str.IndexOf ("hola"), "#05");
+			Assert.IsTrue (-1 != str.IndexOf ("adios"), "#06");
 		}
 	}
 }
+