Browse Source

Style.cs: implemented SetBit().

svn path=/trunk/mcs/; revision=64860
Igor Zelmanovich 19 years ago
parent
commit
39e8a15e8b

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

@@ -1,3 +1,7 @@
+2006-09-04 Igor Zelmanovich <[email protected]>
+
+	* Style.cs: implemented SetBit().	 
+
 2006-09-03 Igor Zelmanovich <[email protected]>
 
 	* CompareValidator.cs: fixed controltocompare attribute.	 

+ 21 - 18
mcs/class/System.Web/System.Web.UI.WebControls/Style.cs

@@ -47,13 +47,13 @@ namespace System.Web.UI.WebControls {
 		internal enum Styles 
 		{
 			None		= 0,
-			BackColor	= 0x00000001,
-			BorderColor	= 0x00000002,
-			BorderStyle	= 0x00000004,
-			BorderWidth	= 0x00000008,
-			CssClass	= 0x00000010,
-			Font		= 0x00000020,
-			ForeColor	= 0x00000040,
+			BackColor	= 0x00000008,
+			BorderColor	= 0x00000010,
+			BorderStyle	= 0x00000040,
+			BorderWidth	= 0x00000020,
+			CssClass	= 0x00000002,
+			Font		= 0x00000001,
+			ForeColor	= 0x00000004,
 			Height		= 0x00000080,
 			Width		= 0x00000100,
 
@@ -128,7 +128,7 @@ namespace System.Web.UI.WebControls {
 			set 
 			{
 				viewstate["BackColor"] = value;
-				styles |= Styles.BackColor;
+				SetBit ((int) Styles.BackColor);
 			}
 		}
 
@@ -155,7 +155,7 @@ namespace System.Web.UI.WebControls {
 			set 
 			{
 				viewstate["BorderColor"] = value;
-				styles |= Styles.BorderColor;
+				SetBit ((int) Styles.BorderColor);
 			}
 		}
 
@@ -181,7 +181,7 @@ namespace System.Web.UI.WebControls {
 			set 
 			{
 				viewstate["BorderStyle"] = value;
-				styles |= Styles.BorderStyle;
+				SetBit ((int) Styles.BorderStyle);
 			}
 		}
 
@@ -212,7 +212,7 @@ namespace System.Web.UI.WebControls {
 				}
 
 				viewstate["BorderWidth"] = value;
-				styles |= Styles.BorderWidth;
+				SetBit ((int) Styles.BorderWidth);
 			}
 		}
 
@@ -235,7 +235,7 @@ namespace System.Web.UI.WebControls {
 			set 
 			{
 				viewstate["CssClass"] = value;
-				styles |= Styles.CssClass;
+				SetBit ((int) Styles.CssClass);
 			}
 		}
 
@@ -278,7 +278,7 @@ namespace System.Web.UI.WebControls {
 			set 
 			{
 				viewstate["ForeColor"] = value;
-				styles |= Styles.ForeColor;
+				SetBit ((int) Styles.ForeColor);
 			}
 		}
 
@@ -309,7 +309,7 @@ namespace System.Web.UI.WebControls {
 				}
 
 				viewstate["Height"] = value;
-				styles |= Styles.Height;
+				SetBit ((int) Styles.Height);
 			}
 		}
 
@@ -340,7 +340,7 @@ namespace System.Web.UI.WebControls {
 				}
 
 				viewstate["Width"] = value;
-				styles |= Styles.Width;
+				SetBit ((int) Styles.Width);
 			}
 		}
 		#endregion	// Public Instance Properties
@@ -783,13 +783,16 @@ namespace System.Web.UI.WebControls {
 			return null;
 		}
 
-		[MonoTODO]
 		protected internal virtual void SetBit( int bit ) 
 		{
-			throw new NotImplementedException();
+			styles |= (Styles) bit;
+		}
+
+		internal bool CheckBit (int bit) {
+			return (styles & (Styles) bit) != 0;
 		}
 
-		protected internal virtual void TrackViewState() 
+		protected internal virtual void TrackViewState () 
 		{
 			tracking = true;
 			viewstate.TrackViewState();

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

@@ -1,3 +1,7 @@
+2006-09-04 Igor Zelmanovich <[email protected]>
+
+	* StyleTest.cs: New test was added
+
 2006-08-31 Igor Zelmanovich <[email protected]>
 
 	* CompleteWizardStepTest.cs: New tests were added

+ 53 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/StyleTest.cs

@@ -124,6 +124,14 @@ namespace MonoTests.System.Web.UI.WebControls
 
 			return result;
 		}
+
+		public bool SetBitCalledFlag = false;
+		public int SetBitCalledValue = 0;
+		protected override void SetBit (int bit) {
+			SetBitCalledFlag = true;
+			SetBitCalledValue = bit;
+			base.SetBit (bit);
+		}
 	}
 
 	[TestFixture]	
@@ -588,6 +596,51 @@ namespace MonoTests.System.Web.UI.WebControls
 			s.Font.Name = "Arial";
 			Assert.IsFalse (s.Empty, "No longer empty");
 		}
+		
+		[Test]
+		public void SetBitCalledWhenSetProperty () {
+			StyleTestClass s = new StyleTestClass ();
+
+			s.SetBitCalledFlag = false;
+			s.BackColor = Color.Aqua;
+			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BackColor");
+			Assert.AreEqual (0x08, s.SetBitCalledValue, "SetBit() was called with wrong argument : BackColor");
+
+			s.SetBitCalledFlag = false;
+			s.BorderColor = Color.Blue;
+			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderColor");
+			Assert.AreEqual (0x10, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderColor");
+
+			s.SetBitCalledFlag = false;
+			s.BorderStyle = BorderStyle.Dashed;
+			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderStyle");
+			Assert.AreEqual (0x40, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderStyle");
+
+			s.SetBitCalledFlag = false;
+			s.BorderWidth = 1;
+			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderWidth");
+			Assert.AreEqual (0x20, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderWidth");
+
+			s.SetBitCalledFlag = false;
+			s.CssClass = "class";
+			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : CssClass");
+			Assert.AreEqual (0x02, s.SetBitCalledValue, "SetBit() was called with wrong argument : CssClass");
+
+			s.SetBitCalledFlag = false;
+			s.ForeColor = Color.Red;
+			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : ForeColor");
+			Assert.AreEqual (0x04, s.SetBitCalledValue, "SetBit() was called with wrong argument : ForeColor");
+
+			s.SetBitCalledFlag = false;
+			s.Height = 1;
+			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Height");
+			Assert.AreEqual (0x80, s.SetBitCalledValue, "SetBit() was called with wrong argument : Height");
+
+			s.SetBitCalledFlag = false;
+			s.Width = 1;
+			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Width");
+			Assert.AreEqual (0x100, s.SetBitCalledValue, "SetBit() was called with wrong argument : Width");
+		}
 
 		public void Render ()
 		{