2 // ToolStripContentPanelTests.cs
\r
4 // Permission is hereby granted, free of charge, to any person obtaining
\r
5 // a copy of this software and associated documentation files (the
\r
6 // "Software"), to deal in the Software without restriction, including
\r
7 // without limitation the rights to use, copy, modify, merge, publish,
\r
8 // distribute, sublicense, and/or sell copies of the Software, and to
\r
9 // permit persons to whom the Software is furnished to do so, subject to
\r
10 // the following conditions:
\r
12 // The above copyright notice and this permission notice shall be
\r
13 // included in all copies or substantial portions of the Software.
\r
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 // Copyright (c) 2007 Jonathan Pobst
\r
26 // Jonathan Pobst (monkey@jpobst.com)
\r
30 using System.Collections.Generic;
\r
32 using NUnit.Framework;
\r
33 using System.Drawing;
\r
34 using System.Windows.Forms;
\r
36 namespace MonoTests.System.Windows.Forms
\r
39 public class ToolStripContentPanelTests : TestHelper
\r
42 public void Constructor ()
\r
44 ToolStripContentPanel tsp = new ToolStripContentPanel ();
\r
46 Assert.AreEqual (SystemColors.Control, tsp.BackColor, "A1");
\r
47 Assert.AreEqual ("System.Windows.Forms.ToolStripSystemRenderer", tsp.Renderer.ToString (), "A2");
\r
48 Assert.AreEqual (ToolStripRenderMode.System, tsp.RenderMode, "A3");
\r
52 public void PropertyBackColor ()
\r
54 ToolStripContentPanel tsp = new ToolStripContentPanel ();
\r
55 EventWatcher ew = new EventWatcher (tsp);
\r
57 tsp.BackColor = Color.Green;
\r
58 Assert.AreEqual (Color.Green, tsp.BackColor, "B1");
\r
59 Assert.AreEqual (string.Empty, ew.ToString (), "B2");
\r
62 tsp.BackColor = Color.Green;
\r
63 Assert.AreEqual (string.Empty, ew.ToString (), "B3");
\r
67 public void PropertyRenderer ()
\r
69 ToolStripContentPanel tsp = new ToolStripContentPanel ();
\r
70 EventWatcher ew = new EventWatcher (tsp);
\r
72 ToolStripProfessionalRenderer pr = new ToolStripProfessionalRenderer ();
\r
75 Assert.AreSame (pr, tsp.Renderer, "B1");
\r
76 Assert.AreEqual (ToolStripRenderMode.Custom, tsp.RenderMode, "B1-2");
\r
77 // I refuse to call the event twice like .Net does.
\r
78 //Assert.AreEqual ("RendererChanged;RendererChanged", ew.ToString (), "B2");
\r
82 //Assert.AreEqual (string.Empty, ew.ToString (), "B3");
\r
86 public void PropertyRenderMode ()
\r
88 ToolStripContentPanel tsp = new ToolStripContentPanel ();
\r
89 EventWatcher ew = new EventWatcher (tsp);
\r
91 tsp.RenderMode = ToolStripRenderMode.ManagerRenderMode;
\r
92 Assert.AreEqual (ToolStripRenderMode.ManagerRenderMode, tsp.RenderMode, "B1");
\r
93 // I refuse to call the event twice like .Net does.
\r
94 //Assert.AreEqual ("RendererChanged;RendererChanged", ew.ToString (), "B2");
\r
97 tsp.RenderMode = ToolStripRenderMode.ManagerRenderMode;
\r
98 Assert.AreEqual (string.Empty, ew.ToString (), "B3");
\r
101 private class EventWatcher
\r
103 private string events = string.Empty;
\r
105 public EventWatcher (ToolStripContentPanel tsp)
\r
107 tsp.Load += new EventHandler (delegate (Object obj, EventArgs e) { events += ("Load;"); });
\r
108 tsp.RendererChanged += new EventHandler (delegate (Object obj, EventArgs e) { events += ("RendererChanged;"); });
\r
111 public override string ToString ()
\r
113 return events.TrimEnd (';');
\r
116 public void Clear ()
\r
118 events = string.Empty;
\r