1 /* 2 * "GEDKeeper", the personal genealogical database editor. 3 * Copyright (C) 2009-2017 by Sergey V. Zhdanovskih. 4 * 5 * This file is part of "GEDKeeper". 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #if !MONO 22 23 using System.Drawing; 24 using System.Windows.Forms; 25 using BSLib; 26 using BSLib.Design.Graphics; 27 using GKTests; 28 using NUnit.Extensions.Forms; 29 using NUnit.Framework; 30 31 namespace GKUI.Components 32 { 33 [TestFixture] 34 public class ImageViewTests : CustomWindowTest 35 { 36 private Form fForm; 37 private ImageView fImageView; 38 39 [TestFixtureSetUp] Init()40 public void Init() 41 { 42 fForm = new Form(); 43 fForm.ClientSize = new Size(383, 221); 44 fForm.Text = "ImageViewTests"; 45 46 fImageView = new ImageView(); 47 fImageView.Dock = DockStyle.Fill; 48 49 fForm.SuspendLayout(); 50 fForm.Controls.Add(fImageView); 51 fForm.ResumeLayout(false); 52 fForm.PerformLayout(); 53 } 54 55 [TestFixtureTearDown] Done()56 public void Done() 57 { 58 fForm.Dispose(); 59 } 60 61 [Test] TestMethod()62 public void TestMethod() 63 { 64 IImage image1 = null; 65 fImageView.OpenImage(image1); // return without exceptions 66 67 Image image2 = null; 68 fImageView.OpenImage(image2); // return without exceptions 69 70 Bitmap img = new Bitmap(TestUtils.LoadResourceStream("shaytan_plant.jpg")); 71 72 fImageView.OpenImage(img); 73 74 fForm.Show(); 75 76 fImageView.ShowToolbar = false; 77 Assert.IsFalse(fImageView.ShowToolbar); 78 79 fImageView.ShowToolbar = true; 80 Assert.IsTrue(fImageView.ShowToolbar); 81 82 fImageView.SelectionMode = ImageBoxSelectionMode.Zoom; 83 Assert.AreEqual(ImageBoxSelectionMode.Zoom, fImageView.SelectionMode); 84 85 fImageView.SelectionRegion = ExtRect.Empty; 86 Assert.AreEqual(ExtRect.Empty, fImageView.SelectionRegion); 87 88 ClickToolStripButton("btnZoomIn", fForm); 89 ClickToolStripButton("btnZoomOut", fForm); 90 ClickToolStripButton("btnSizeToFit", fForm); 91 92 var tscbZoomLevels = new ToolStripComboBoxTester("zoomLevelsToolStripComboBox", fForm); 93 tscbZoomLevels.Enter("500"); 94 95 fForm.Close(); 96 } 97 } 98 } 99 100 #endif 101