Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4729 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
5 changed files with 167 additions and 8 deletions
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
// <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.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the control's BeginInit and EndInit methods are called.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class CallBeginInitOnLoadTestFixture : LoadFormTestFixtureBase |
||||
{ |
||||
public override string PythonCode { |
||||
get { |
||||
ComponentCreator.AddType("PythonBinding.Tests.Utils.SupportInitCustomControl", typeof(SupportInitCustomControl)); |
||||
|
||||
return "class TestForm(System.Windows.Forms.Form):\r\n" + |
||||
" def InitializeComponent(self):\r\n" + |
||||
" self._control = PythonBinding.Tests.Utils.SupportInitCustomControl()\r\n" + |
||||
" self._control.BeginInit()\r\n" + |
||||
" localVariable = PythonBinding.Tests.Utils.SupportInitCustomControl()\r\n" + |
||||
" localVariable.BeginInit()\r\n" + |
||||
" self.SuspendLayout()\r\n" + |
||||
" # \r\n" + |
||||
" # TestForm\r\n" + |
||||
" # \r\n" + |
||||
" self.AccessibleRole = System.Windows.Forms.AccessibleRole.None\r\n" + |
||||
" self.Controls.Add(self._control)\r\n" + |
||||
" self.Name = \"TestForm\"\r\n" + |
||||
" self._control.EndInit()\r\n" + |
||||
" localVariable.EndInit()\r\n" + |
||||
" self.ResumeLayout(False)\r\n"; |
||||
} |
||||
} |
||||
|
||||
public SupportInitCustomControl Control { |
||||
get { return Form.Controls[0] as SupportInitCustomControl; } |
||||
} |
||||
|
||||
public SupportInitCustomControl LocalControl { |
||||
get { return base.ComponentCreator.GetInstance("localVariable") as SupportInitCustomControl; } |
||||
} |
||||
|
||||
[Test] |
||||
public void BeginInitCalled() |
||||
{ |
||||
Assert.IsTrue(Control.IsBeginInitCalled); |
||||
} |
||||
|
||||
[Test] |
||||
public void EndInitCalled() |
||||
{ |
||||
Assert.IsTrue(Control.IsEndInitCalled); |
||||
} |
||||
|
||||
[Test] |
||||
public void BeginInitCalledOnLocalVariable() |
||||
{ |
||||
Assert.IsTrue(LocalControl.IsBeginInitCalled); |
||||
} |
||||
|
||||
[Test] |
||||
public void EndInitCalledOnLocalVariable() |
||||
{ |
||||
Assert.IsTrue(LocalControl.IsEndInitCalled); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
// <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.Windows.Forms; |
||||
|
||||
namespace PythonBinding.Tests.Utils |
||||
{ |
||||
public class SupportInitCustomControl : UserControl, ISupportInitialize |
||||
{ |
||||
bool beginInitCalled; |
||||
bool endInitCalled; |
||||
|
||||
public SupportInitCustomControl() |
||||
{ |
||||
} |
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] |
||||
[Browsable(false)] |
||||
public bool IsBeginInitCalled { |
||||
get { return beginInitCalled; } |
||||
} |
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] |
||||
[Browsable(false)] |
||||
public bool IsEndInitCalled { |
||||
get { return endInitCalled; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Deliberately making the interface explicit for the BeginInit method but not the EndInit method.
|
||||
/// </summary>
|
||||
void ISupportInitialize.BeginInit() |
||||
{ |
||||
beginInitCalled = true; |
||||
} |
||||
|
||||
public void EndInit() |
||||
{ |
||||
endInitCalled = true; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue