(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Drawing / Test / System.Drawing / TestSystemPens.cs
blobee492ad2f135e1947423e5784a2b1e13ed8147d8
1 // Tests for System.Drawing.SystemPens.cs
2 //
3 // Author:
4 // Ravindra (rkumar@novell.com)
5 //
7 //
8 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using NUnit.Framework;
32 using System;
33 using System.Drawing;
34 using System.Drawing.Drawing2D;
36 namespace MonoTests.System.Drawing
38 [TestFixture]
39 public class SystemPensTest : Assertion
41 [TearDown]
42 public void TearDown () {}
44 [SetUp]
45 public void SetUp () {}
47 [Test]
48 public void TestActiveCaptionText ()
50 Pen pen;
51 pen = SystemPens.ActiveCaptionText;
52 CheckProperties (pen, "P1", SystemColors.ActiveCaptionText);
53 CheckMethods (pen, "M1");
56 [Test]
57 public void TestControl ()
59 Pen pen;
60 pen = SystemPens.Control;
61 CheckProperties (pen, "P2", SystemColors.Control);
62 CheckMethods (pen, "M2");
65 [Test]
66 public void TestControlDark ()
68 Pen pen;
69 pen = SystemPens.ControlDark;
70 CheckProperties (pen, "P3", SystemColors.ControlDark);
71 CheckMethods (pen, "M3");
74 [Test]
75 public void TestControlDarkDark ()
77 Pen pen;
78 pen = SystemPens.ControlDarkDark;
79 CheckProperties (pen, "P4", SystemColors.ControlDarkDark);
80 CheckMethods (pen, "M4");
83 [Test]
84 public void TestControlLight ()
86 Pen pen;
87 pen = SystemPens.ControlLight;
88 CheckProperties (pen, "P5", SystemColors.ControlLight);
89 CheckMethods (pen, "M5");
92 [Test]
93 public void TestControlLightLight ()
95 Pen pen;
96 pen = SystemPens.ControlLightLight;
97 CheckProperties (pen, "P6", SystemColors.ControlLightLight);
98 CheckMethods (pen, "M6");
101 [Test]
102 public void TestControlText ()
104 Pen pen;
105 pen = SystemPens.ControlText;
106 CheckProperties (pen, "P7", SystemColors.ControlText);
107 CheckMethods (pen, "M7");
110 [Test]
111 public void TestGrayText ()
113 Pen pen;
114 pen = SystemPens.GrayText;
115 CheckProperties (pen, "P8", SystemColors.GrayText);
116 CheckMethods (pen, "M8");
119 [Test]
120 public void TestHighlight ()
122 Pen pen;
123 pen = SystemPens.Highlight;
124 CheckProperties (pen, "P9", SystemColors.Highlight);
125 CheckMethods (pen, "M9");
128 [Test]
129 public void TestHighlightText ()
131 Pen pen;
132 pen = SystemPens.HighlightText;
133 CheckProperties (pen, "P10", SystemColors.HighlightText);
134 CheckMethods (pen, "M10");
137 [Test]
138 public void TestInactiveCaptionText ()
140 Pen pen;
141 pen = SystemPens.InactiveCaptionText;
142 CheckProperties (pen, "P11", SystemColors.InactiveCaptionText);
143 CheckMethods (pen, "M11");
146 [Test]
147 public void TestInfoText ()
149 Pen pen;
150 pen = SystemPens.InfoText;
151 CheckProperties (pen, "P12", SystemColors.InfoText);
152 CheckMethods (pen, "M12");
155 [Test]
156 public void TestMenuText ()
158 Pen pen;
159 pen = SystemPens.MenuText;
160 CheckProperties (pen, "P13", SystemColors.MenuText);
161 CheckMethods (pen, "M13");
164 [Test]
165 public void TestWindowFrame ()
167 Pen pen;
168 pen = SystemPens.WindowFrame;
169 CheckProperties (pen, "P14", SystemColors.WindowFrame);
170 CheckMethods (pen, "M14");
173 [Test]
174 public void TestWindowText ()
176 Pen pen;
177 pen = SystemPens.WindowText;
178 CheckProperties (pen, "P15", SystemColors.WindowText);
179 CheckMethods (pen, "M15");
182 [Test]
183 public void TestFromSystemColor ()
185 Pen pen;
187 pen = SystemPens.FromSystemColor (SystemColors.MenuText);
188 CheckProperties (pen, "P16", SystemColors.MenuText);
189 CheckMethods (pen, "M16");
191 try {
192 pen = SystemPens.FromSystemColor (Color.Red);
193 Fail ("M17: must throw ArgumentException");
194 } catch (Exception e) {
195 Assert ("M17", e is ArgumentException);
199 // helper test functions
200 void CheckProperties (Pen pen, String tag, Color sysColor)
202 // Try modifying properties of a SystemPen.
203 // ArgumentException must be thrown.
205 Assert (tag + "#1", pen.Color.IsSystemColor);
206 AssertEquals (tag + "#1", sysColor, pen.Color);
208 try {
209 pen.Alignment = PenAlignment.Center;
210 Fail (tag + "#2: must throw ArgumentException");
211 } catch (Exception e) {
212 Assert (tag + "#2", e is ArgumentException);
215 try {
216 pen.Brush = new SolidBrush(Color.Red);
217 Fail (tag + "#3: must throw ArgumentException");
218 } catch (Exception e) {
219 Assert (tag + "#3", e is ArgumentException);
222 try {
223 pen.Color = Color.Red;
224 Fail (tag + "#4: must throw ArgumentException");
225 } catch (Exception e) {
226 Assert (tag + "#4", e is ArgumentException);
229 try {
230 pen.Color = sysColor;
231 Fail (tag + "#5" + ": must throw ArgumentException");
232 } catch (Exception e) {
233 Assert (tag + "#5", e is ArgumentException);
236 try {
237 // NotImplemented
238 pen.CompoundArray = new float[2];
239 Fail (tag + "#6: must throw ArgumentException");
240 } catch (Exception e) {
241 Assert (tag + "#6", e is ArgumentException);
244 try {
245 // NotImplemented
246 pen.CustomEndCap = null;
247 Fail (tag + "#7: must throw ArgumentException");
248 } catch (Exception e) {
249 Assert (tag + "#7", e is ArgumentException);
252 try {
253 // NotImplemented
254 pen.CustomStartCap = null;
255 Fail (tag + "#8: must throw ArgumentException");
256 } catch (Exception e) {
257 Assert (tag + "#8", e is ArgumentException);
260 try {
261 // NotImplemented
262 pen.DashCap = DashCap.Flat;
263 Fail (tag + "#9: must throw ArgumentException");
264 } catch (Exception e) {
265 Assert (tag + "#9", e is ArgumentException);
268 try {
269 pen.DashOffset = 5.5F;
270 Fail (tag + "#10: must throw ArgumentException");
271 } catch (Exception e) {
272 Assert (tag + "#10", e is ArgumentException);
275 try {
276 pen.DashPattern = null;
277 Fail (tag + "#11: must throw ArgumentException");
278 } catch (Exception e) {
279 Assert (tag + "#11", e is ArgumentException);
282 try {
283 pen.DashStyle = DashStyle.Dot; // hangs!prob
284 Fail (tag + "#12: must throw ArgumentException");
285 } catch (Exception e) {
286 Assert (tag + "#12", e is ArgumentException);
289 try {
290 // NotImplemented
291 pen.EndCap = LineCap.Round;
292 Fail (tag + "#13: must throw ArgumentException");
293 } catch (Exception e) {
294 Assert (tag + "#13", e is ArgumentException);
297 try {
298 pen.LineJoin = LineJoin.Round;
299 Fail (tag + "#14: must throw ArgumentException");
300 } catch (Exception e) {
301 Assert (tag + "#14", e is ArgumentException);
304 try {
305 pen.MiterLimit = 0.1f;
306 Fail (tag + "#15: must throw ArgumentException");
307 } catch (Exception e) {
308 Assert (tag + "#15", e is ArgumentException);
311 try {
312 // NotImplemented
313 pen.StartCap = LineCap.Square;
314 Fail (tag + "#16: must throw ArgumentException");
315 } catch (Exception e) {
316 Assert (tag + "#16", e is ArgumentException);
319 try {
320 pen.Transform = new Matrix (); //Matrix hangs!problem
321 Fail (tag + "#17: must throw ArgumentException");
322 } catch (Exception e) {
323 Assert (tag + "#17", e is ArgumentException);
326 try {
327 pen.Width = 0.5F;
328 Fail (tag + "#18: must throw ArgumentException");
329 } catch (Exception e) {
330 Assert (tag + "#18", e is ArgumentException);
334 void CheckMethods (Pen pen, String tag)
336 // Try modifying a SystemPen by calling methods.
337 // ArgumentException must be thrown in some cases.
339 try {
340 // NotImplemented
341 pen.SetLineCap (LineCap.Flat, LineCap.Round, DashCap.Triangle);
342 Fail (tag + "#1: must throw ArgumentException");
343 } catch (Exception e) {
344 Assert (tag + "#1", e is ArgumentException);
347 try {
348 pen.ResetTransform ();
349 } catch {
350 Fail (tag + "#2: unexpected Exception");
353 try {
354 pen.RotateTransform (90);
355 } catch {
356 Fail (tag + "#3: unexpected Exception");
359 try {
360 pen.ScaleTransform (2, 1);
361 } catch {
362 Fail (tag + "#4: unexpected Exception");
365 try {
366 pen.TranslateTransform (10, 20);
367 } catch {
368 Fail (tag + "#5: unexpected Exception");
371 try {
372 pen.MultiplyTransform (new Matrix ());
373 } catch {
374 Fail (tag + "#6: unexpected Exception");
377 try {
378 pen.Clone ();
379 } catch {
380 Fail (tag + "#7: unexpected Exception");
383 try {
384 pen.Dispose ();
385 Fail (tag + "#8: must throw ArgumentException");
386 } catch (Exception e) {
387 Assert (tag + "#8", e is ArgumentException);