Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4575 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
5 changed files with 152 additions and 2 deletions
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
class PublicToolTipBaseForm : Form |
||||
{ |
||||
public ToolTip toolTip; |
||||
Container components = new Container(); |
||||
|
||||
public PublicToolTipBaseForm() |
||||
{ |
||||
toolTip = new ToolTip(components); |
||||
} |
||||
} |
||||
|
||||
class PublicToolTipDerivedForm : PublicToolTipBaseForm |
||||
{ |
||||
} |
||||
|
||||
[TestFixture] |
||||
public class GenerateInheritedToolTipTestFixture |
||||
{ |
||||
string generatedPythonCode; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
using (DesignSurface designSurface = new DesignSurface(typeof(PublicToolTipDerivedForm))) { |
||||
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); |
||||
IEventBindingService eventBindingService = new MockEventBindingService(host); |
||||
PublicToolTipDerivedForm form = (PublicToolTipDerivedForm)host.RootComponent; |
||||
form.ClientSize = new Size(284, 264); |
||||
|
||||
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form); |
||||
PropertyDescriptor descriptor = descriptors.Find("Name", false); |
||||
descriptor.SetValue(form, "MainForm"); |
||||
|
||||
form.toolTip.SetToolTip(form, "test"); |
||||
|
||||
string indentString = " "; |
||||
PythonControl pythonForm = new PythonControl(indentString); |
||||
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void GeneratedCode() |
||||
{ |
||||
string expectedCode = "def InitializeComponent(self):\r\n" + |
||||
" self.SuspendLayout()\r\n" + |
||||
" # \r\n" + |
||||
" # MainForm\r\n" + |
||||
" # \r\n" + |
||||
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" + |
||||
" self.Name = \"MainForm\"\r\n" + |
||||
" self.toolTip.SetToolTip(self, \"test\")\r\n" + |
||||
" self.ResumeLayout(False)\r\n" + |
||||
" self.PerformLayout()\r\n"; |
||||
|
||||
Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.Drawing; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
[TestFixture] |
||||
public class LoadInheritedToolTipTestFixture : LoadFormTestFixtureBase |
||||
{ |
||||
public override string PythonCode { |
||||
get { |
||||
ComponentCreator.AddType("PythonBinding.Tests.Designer.PublicToolTipDerivedForm", typeof(PythonBinding.Tests.Designer.PublicToolTipDerivedForm)); |
||||
|
||||
return "class TestForm(PythonBinding.Tests.Designer.PublicToolTipDerivedForm):\r\n" + |
||||
" def InitializeComponent(self):\r\n" + |
||||
" self._button1 = System.Windows.Forms.Button()\r\n" + |
||||
" self.SuspendLayout()\r\n" + |
||||
" # \r\n" + |
||||
" # button1\r\n" + |
||||
" # \r\n" + |
||||
" self._button1.Location = System.Drawing.Point(0, 0)\r\n" + |
||||
" self._button1.Name = \"button1\"\r\n" + |
||||
" self._button1.Size = System.Drawing.Size(10, 10)\r\n" + |
||||
" self._button1.TabIndex = 0\r\n" + |
||||
" self._button1.Text = \"button1\"\r\n" + |
||||
" self.toolTip.SetToolTip(self._button1, \"buttonTest\")\r\n" + |
||||
" # \r\n" + |
||||
" # MainForm\r\n" + |
||||
" # \r\n" + |
||||
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" + |
||||
" self.Controls.Add(self._button1)\r\n" + |
||||
" self.Name = \"MainForm\"\r\n" + |
||||
" self.toolTip.SetToolTip(self, \"test\")\r\n" + |
||||
" self.ResumeLayout(False)\r\n" + |
||||
" self.PerformLayout()\r\n"; |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void FormHasToolTip() |
||||
{ |
||||
PublicToolTipDerivedForm form = Form as PublicToolTipDerivedForm; |
||||
Assert.AreEqual("test", form.toolTip.GetToolTip(form)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ButtonHasToolTip() |
||||
{ |
||||
PublicToolTipDerivedForm form = Form as PublicToolTipDerivedForm; |
||||
Assert.AreEqual("buttonTest", form.toolTip.GetToolTip(form.Controls[0])); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue