Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4179 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts^2
113 changed files with 2229 additions and 1051 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,23 +0,0 @@
@@ -1,23 +0,0 @@
|
||||
// <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 ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Indicates whether the python console is running.
|
||||
/// </summary>
|
||||
public class IsPythonRunningCondition : IConditionEvaluator |
||||
{ |
||||
public bool IsValid(object caller, Condition condition) |
||||
{ |
||||
return RunPythonCommand.IsRunning; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonContextMenuComponent : PythonDesignerComponent |
||||
{ |
||||
public PythonContextMenuComponent(PythonDesignerComponent parent, IComponent component) |
||||
: base(parent, component) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Always ignore the OwnerItem property. This is set if the context menu is open and displayed in
|
||||
/// the designer when the user switches to the source tab. This method works around the problem by
|
||||
/// ignoring the OwnerItem property when generating the form designer code.
|
||||
/// </summary>
|
||||
protected override bool IgnoreProperty(PropertyDescriptor property) |
||||
{ |
||||
return property.Name == "OwnerItem"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
// <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.CodeDom; |
||||
using System.CodeDom.Compiler; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Converter |
||||
{ |
||||
[TestFixture] |
||||
public class BooleanVariableConversionTestFixture |
||||
{ |
||||
string csharp = "class Foo\r\n" + |
||||
"{\r\n" + |
||||
"\tbool a;\r\n" + |
||||
"\r\n" + |
||||
"\tpublic Foo()\r\n" + |
||||
"\t{\r\n" + |
||||
"\t\ta = true;\r\n" + |
||||
"\t}\r\n" + |
||||
"}"; |
||||
|
||||
[Test] |
||||
public void ConvertedPythonCode() |
||||
{ |
||||
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp); |
||||
string python = converter.Convert(csharp); |
||||
string expectedPython = "class Foo(object):\r\n" + |
||||
"\tdef __init__(self):\r\n" + |
||||
"\t\tself._a = True"; |
||||
|
||||
Assert.AreEqual(expectedPython, python); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// <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 ICSharpCode.NRefactory; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Converter |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the code to create an instance of a generic list is converted to python
|
||||
/// correctly.
|
||||
///
|
||||
/// C#: List<string> list = new List<string>();
|
||||
///
|
||||
/// Python: list = List[str]()
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class GenericListConversionTestFixture |
||||
{ |
||||
string csharp = "using System.Collections.Generic;\r\n" + |
||||
"\r\n" + |
||||
"class Foo\r\n" + |
||||
"{\r\n" + |
||||
" public Foo()\r\n" + |
||||
" {\r\n" + |
||||
" List<string> list = new List<string>();\r\n" + |
||||
" Dictionary<string, int> dictionary = new Dictionary<string, int>();\r\n" + |
||||
" }\r\n" + |
||||
"}"; |
||||
|
||||
[Test] |
||||
public void ConvertedPythonCode() |
||||
{ |
||||
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp); |
||||
converter.IndentString = " "; |
||||
string python = converter.Convert(csharp); |
||||
string expectedPython = "from System.Collections.Generic import *\r\n" + |
||||
"class Foo(object):\r\n" + |
||||
" def __init__(self):\r\n" + |
||||
" list = List[System.String]()\r\n" + |
||||
" dictionary = Dictionary[System.String, System.Int32]()"; |
||||
|
||||
Assert.AreEqual(expectedPython, python); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
// <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.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.DefaultEditor.Codons; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Converter |
||||
{ |
||||
[TestFixture] |
||||
public class ProjectHasStartupObjectTestFixture |
||||
{ |
||||
DerivedConvertProjectToPythonProjectCommand convertProjectCommand; |
||||
FileProjectItem mainFile; |
||||
FileProjectItem main2File; |
||||
FileProjectItem targetMainFile; |
||||
FileProjectItem targetMain2File; |
||||
MSBuildBasedProject sourceProject; |
||||
PythonProject targetProject; |
||||
MockTextEditorProperties mockTextEditorProperties; |
||||
MockProjectContent mockProjectContent; |
||||
|
||||
string startupObject = "RootNamespace.Main"; |
||||
|
||||
string mainSource = "class Foo\r\n" + |
||||
"{\r\n" + |
||||
" static void Main()\r\n" + |
||||
" {\r\n" + |
||||
" }\r\n" + |
||||
"}"; |
||||
|
||||
string main2Source = "class Bar\r\n" + |
||||
"{\r\n" + |
||||
" static void Main()\r\n" + |
||||
" {\r\n" + |
||||
" }\r\n" + |
||||
"}"; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
MSBuildEngineHelper.InitMSBuildEngine(); |
||||
|
||||
List<LanguageBindingDescriptor> bindings = new List<LanguageBindingDescriptor>(); |
||||
using (TextReader reader = PythonBindingAddInFile.ReadAddInFile()) { |
||||
AddIn addin = AddIn.Load(reader, String.Empty); |
||||
bindings.Add(new LanguageBindingDescriptor(AddInHelper.GetCodon(addin, "/SharpDevelop/Workbench/LanguageBindings", "Python"))); |
||||
} |
||||
LanguageBindingService.SetBindings(bindings); |
||||
|
||||
// Set up IProjectContent so the ConvertProjectToPythonProjectCommand can
|
||||
// locate the startup object and determine it's filename.
|
||||
|
||||
mockProjectContent = new MockProjectContent(); |
||||
MockClass mainClass = new MockClass(mockProjectContent, startupObject); |
||||
mainClass.CompilationUnit.FileName = @"d:\projects\test\src\Main2.cs"; |
||||
mockProjectContent.ClassToReturnFromGetClass = mainClass; |
||||
|
||||
mockTextEditorProperties = new MockTextEditorProperties(); |
||||
convertProjectCommand = new DerivedConvertProjectToPythonProjectCommand(mockTextEditorProperties); |
||||
convertProjectCommand.ProjectContent = mockProjectContent; |
||||
mockTextEditorProperties.Encoding = Encoding.Unicode; |
||||
|
||||
Solution solution = new Solution(); |
||||
sourceProject = new MSBuildBasedProject(solution.BuildEngine); |
||||
sourceProject.Parent = solution; |
||||
sourceProject.FileName = @"d:\projects\test\source.csproj"; |
||||
sourceProject.SetProperty(null, null, "StartupObject", startupObject, PropertyStorageLocations.Base, true); |
||||
mainFile = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Main.cs"); |
||||
targetProject = (PythonProject)convertProjectCommand.CallCreateProject(@"d:\projects\test\converted", sourceProject); |
||||
convertProjectCommand.CallCopyProperties(sourceProject, targetProject); |
||||
targetMainFile = new FileProjectItem(targetProject, mainFile.ItemType, mainFile.Include); |
||||
mainFile.CopyMetadataTo(targetMainFile); |
||||
|
||||
main2File = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Main2.cs"); |
||||
targetMain2File = new FileProjectItem(targetProject, main2File.ItemType, main2File.Include); |
||||
main2File.CopyMetadataTo(targetMain2File); |
||||
|
||||
convertProjectCommand.AddParseableFileContent(mainFile.FileName, mainSource); |
||||
convertProjectCommand.AddParseableFileContent(main2File.FileName, main2Source); |
||||
|
||||
convertProjectCommand.CallConvertFile(mainFile, targetMainFile); |
||||
convertProjectCommand.CallConvertFile(main2File, targetMain2File); |
||||
} |
||||
|
||||
[Test] |
||||
public void MainFileIsMain2PyFile() |
||||
{ |
||||
PropertyStorageLocations location; |
||||
Assert.AreEqual(@"src\Main2.py", targetProject.GetProperty(null, null, "MainFile", out location)); |
||||
} |
||||
|
||||
[Test] |
||||
public void PropertyStorageLocationForMainFilePropertyIsGlobal() |
||||
{ |
||||
PropertyStorageLocations location; |
||||
targetProject.GetProperty(null, null, "MainFile", out location); |
||||
Assert.AreEqual(PropertyStorageLocations.Base, location); |
||||
} |
||||
|
||||
[Test] |
||||
public void ClassSearchedFor() |
||||
{ |
||||
Assert.AreEqual(startupObject, mockProjectContent.GetClassName); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
// <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.Diagnostics; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.PythonBinding; |
||||
using PythonBinding.Tests.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class DebugPythonCommandTestFixture |
||||
{ |
||||
MockDebugger debugger; |
||||
RunDebugPythonCommand command; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
// Create dummy view content with the Python script.
|
||||
MockViewContent viewContent = new MockViewContent(); |
||||
viewContent.PrimaryFileName = @"C:\Projects\test.py"; |
||||
MockWorkbenchWindow workbenchWindow = new MockWorkbenchWindow(); |
||||
workbenchWindow.ActiveViewContent = viewContent; |
||||
MockWorkbench workbench = new MockWorkbench(); |
||||
workbench.ActiveWorkbenchWindow = workbenchWindow; |
||||
|
||||
// Create the Python binding addin options.
|
||||
Properties p = new Properties(); |
||||
AddInOptions options = new AddInOptions(p); |
||||
options.PythonFileName = @"C:\IronPython\ipy.exe"; |
||||
|
||||
debugger = new MockDebugger(); |
||||
command = new RunDebugPythonCommand(workbench, options, debugger); |
||||
command.Run(); |
||||
} |
||||
|
||||
[Test] |
||||
public void DebuggerStartMethodCalled() |
||||
{ |
||||
Assert.IsTrue(debugger.StartMethodCalled); |
||||
} |
||||
|
||||
[Test] |
||||
public void ProcessInfoFileName() |
||||
{ |
||||
Assert.AreEqual(@"C:\IronPython\ipy.exe", debugger.ProcessStartInfo.FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ProcessInfoArgs() |
||||
{ |
||||
Assert.AreEqual("-D \"C:\\Projects\\test.py\"", debugger.ProcessStartInfo.Arguments); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,105 @@
@@ -0,0 +1,105 @@
|
||||
// <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.ComponentModel.Design.Serialization; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
[TestFixture] |
||||
public class GenerateContextMenuStripTestFixture |
||||
{ |
||||
string generatedPythonCode; |
||||
string createContextMenuStripCode; |
||||
Size menuStripSize; |
||||
PythonDesignerComponent contextMenuDesignerComponent; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) { |
||||
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); |
||||
IEventBindingService eventBindingService = new MockEventBindingService(host); |
||||
Form form = (Form)host.RootComponent; |
||||
form.ClientSize = new Size(200, 300); |
||||
|
||||
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form); |
||||
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false); |
||||
namePropertyDescriptor.SetValue(form, "MainForm"); |
||||
|
||||
// Add timer. This checks that the components Container is only created once in the
|
||||
// generated code.
|
||||
Timer timer = (Timer)host.CreateComponent(typeof(Timer), "timer1"); |
||||
|
||||
// Add menu strip.
|
||||
ContextMenuStrip menuStrip = (ContextMenuStrip)host.CreateComponent(typeof(ContextMenuStrip), "contextMenuStrip1"); |
||||
|
||||
// Set the context menu strip OwnerItem to simulate leaving the context menu
|
||||
// open in the designer before generating the source code. We do not want the
|
||||
// OwnerItem to be serialized.
|
||||
menuStrip.OwnerItem = new DerivedToolStripMenuItem(); |
||||
menuStrip.RightToLeft = RightToLeft.No; |
||||
menuStripSize = menuStrip.Size; |
||||
|
||||
PythonControl pythonForm = new PythonControl(" "); |
||||
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form); |
||||
|
||||
PythonCodeBuilder codeBuilder = new PythonCodeBuilder(); |
||||
contextMenuDesignerComponent = PythonDesignerComponentFactory.CreateDesignerComponent(menuStrip); |
||||
contextMenuDesignerComponent.AppendCreateInstance(codeBuilder); |
||||
|
||||
createContextMenuStripCode = codeBuilder.ToString(); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void GeneratedCode() |
||||
{ |
||||
string expectedCode = "def InitializeComponent(self):\r\n" + |
||||
" self._components = System.ComponentModel.Container()\r\n" + |
||||
" self._timer1 = System.Windows.Forms.Timer(self._components)\r\n" + |
||||
" self._contextMenuStrip1 = System.Windows.Forms.ContextMenuStrip(self._components)\r\n" + |
||||
" self.SuspendLayout()\r\n" + |
||||
" # \r\n" + |
||||
" # contextMenuStrip1\r\n" + |
||||
" # \r\n" + |
||||
" self._contextMenuStrip1.Name = \"contextMenuStrip1\"\r\n" + |
||||
" self._contextMenuStrip1.Size = " + PythonPropertyValueAssignment.ToString(menuStripSize) + "\r\n" + |
||||
" # \r\n" + |
||||
" # MainForm\r\n" + |
||||
" # \r\n" + |
||||
" self.ClientSize = System.Drawing.Size(200, 300)\r\n" + |
||||
" self.Name = \"MainForm\"\r\n" + |
||||
" self.ResumeLayout(False)\r\n" + |
||||
" self.PerformLayout()\r\n"; |
||||
|
||||
Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateContextMenuStripCodeUsesIContainerConstructor() |
||||
{ |
||||
string expectedCode = "self._components = System.ComponentModel.Container()\r\n" + |
||||
"self._contextMenuStrip1 = System.Windows.Forms.ContextMenuStrip(self._components)\r\n"; |
||||
Assert.AreEqual(expectedCode, createContextMenuStripCode); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContextMenuDesignerComponentCreatedFromFactory() |
||||
{ |
||||
Assert.IsInstanceOf(typeof(PythonContextMenuComponent), contextMenuDesignerComponent); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
// <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 |
||||
{ |
||||
[TestFixture] |
||||
public class GenerateToolTipFormTestFixture |
||||
{ |
||||
string generatedPythonCode; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) { |
||||
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); |
||||
IEventBindingService eventBindingService = new MockEventBindingService(host); |
||||
Form form = (Form)host.RootComponent; |
||||
form.ClientSize = new Size(284, 264); |
||||
|
||||
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form); |
||||
PropertyDescriptor descriptor = descriptors.Find("Name", false); |
||||
descriptor.SetValue(form, "MainForm"); |
||||
|
||||
ToolTip toolTip = (ToolTip)host.CreateComponent(typeof(ToolTip), "toolTip1"); |
||||
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._components = System.ComponentModel.Container()\r\n" + |
||||
" self._toolTip1 = System.Windows.Forms.ToolTip(self._components)\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._toolTip1.SetToolTip(self, \"test\")\r\n" + |
||||
" self.ResumeLayout(False)\r\n" + |
||||
" self.PerformLayout()\r\n"; |
||||
|
||||
Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// <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 LoadToolTipTestFixture : LoadFormTestFixtureBase |
||||
{ |
||||
public override string PythonCode { |
||||
get { |
||||
return "class TestForm(System.Windows.Forms.Form):\r\n" + |
||||
" def InitializeComponent(self):\r\n" + |
||||
" self._components = System.ComponentModel.Container()\r\n" + |
||||
" self._toolTip1 = System.Windows.Forms.ToolTip(self._components)\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._toolTip1.SetToolTip(self, \"test\")\r\n" + |
||||
" self.ResumeLayout(False)\r\n" + |
||||
" self.PerformLayout()\r\n"; |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void FormHasToolTip() |
||||
{ |
||||
ToolTip toolTip = (ToolTip)base.ComponentCreator.GetComponent("toolTip1"); |
||||
Assert.AreEqual("test",toolTip.GetToolTip(Form)); |
||||
} |
||||
} |
||||
} |
@ -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.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.PythonBinding; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// When a MenuStrip is added to a form and then removed the python designer generates code
|
||||
/// for the form's MainMenuStrip property even though the MenuStrip has been removed.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class RemoveMainMenuStripFromFormTestFixture |
||||
{ |
||||
string generatedPythonCode; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) { |
||||
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); |
||||
IEventBindingService eventBindingService = new MockEventBindingService(host); |
||||
Form form = (Form)host.RootComponent; |
||||
form.ClientSize = new Size(200, 300); |
||||
|
||||
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form); |
||||
PropertyDescriptor descriptor = descriptors.Find("Name", false); |
||||
descriptor.SetValue(form, "MainForm"); |
||||
|
||||
// Add menu strip.
|
||||
MenuStrip menuStrip = (MenuStrip)host.CreateComponent(typeof(MenuStrip), "menuStrip1"); |
||||
menuStrip.Text = "menuStrip1"; |
||||
menuStrip.TabIndex = 0; |
||||
menuStrip.Location = new Point(0, 0); |
||||
form.Controls.Add(menuStrip); |
||||
|
||||
descriptor = descriptors.Find("MainMenuStrip", false); |
||||
descriptor.SetValue(form, menuStrip); |
||||
|
||||
form.Controls.Remove(menuStrip); |
||||
host.Container.Remove(menuStrip); |
||||
|
||||
PythonControl pythonForm = new PythonControl(" "); |
||||
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(200, 300)\r\n" + |
||||
" self.Name = \"MainForm\"\r\n" + |
||||
" self.ResumeLayout(False)\r\n" + |
||||
" self.PerformLayout()\r\n"; |
||||
|
||||
Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode); |
||||
} |
||||
} |
||||
} |
@ -1,73 +0,0 @@
@@ -1,73 +0,0 @@
|
||||
// <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 ICSharpCode.Core; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the StopPythonCommand kills the python console process.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class StopPythonCommandTestFixture |
||||
{ |
||||
MockProcessRunner processRunner; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
// Create dummy view content with the Python script.
|
||||
MockViewContent viewContent = new MockViewContent(); |
||||
viewContent.PrimaryFileName = @"C:\Projects\test.py"; |
||||
MockWorkbenchWindow workbenchWindow = new MockWorkbenchWindow(); |
||||
workbenchWindow.ActiveViewContent = viewContent; |
||||
MockWorkbench workbench = new MockWorkbench(); |
||||
workbench.ActiveWorkbenchWindow = workbenchWindow; |
||||
|
||||
// Create a dummy output window pad descriptor.
|
||||
MockPadDescriptor padDescriptor = new MockPadDescriptor(); |
||||
|
||||
// Create the Python binding addin options.
|
||||
Properties p = new Properties(); |
||||
AddInOptions options = new AddInOptions(p); |
||||
options.PythonFileName = @"C:\IronPython\ipy.exe"; |
||||
|
||||
// Create the process runner.
|
||||
processRunner = new MockProcessRunner(); |
||||
|
||||
// Create the message view category.
|
||||
MessageViewCategory messageViewCategory = new MessageViewCategory("Python"); |
||||
|
||||
// Run the command.
|
||||
RunPythonCommand command = new RunPythonCommand(workbench, options, processRunner, messageViewCategory, padDescriptor); |
||||
command.Run(); |
||||
|
||||
StopPythonCommand stopCommand = new StopPythonCommand(); |
||||
stopCommand.Run(); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsStopped() |
||||
{ |
||||
// Check that the IsPythonRunning thinks the command has stopped
|
||||
IsPythonRunningCondition condition = new IsPythonRunningCondition(); |
||||
Assert.IsFalse(condition.IsValid(null, null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ProcessRunnerStopped() |
||||
{ |
||||
Assert.IsTrue(processRunner.KillCalled); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
// <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.Windows.Forms; |
||||
|
||||
namespace PythonBinding.Tests.Utils |
||||
{ |
||||
public class DerivedToolStripMenuItem : ToolStripMenuItem |
||||
{ |
||||
public DerivedToolStripMenuItem() : base() |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,178 @@
@@ -0,0 +1,178 @@
|
||||
// <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.Diagnostics; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace PythonBinding.Tests.Utils |
||||
{ |
||||
public class MockDebugger : IDebugger |
||||
{ |
||||
ProcessStartInfo processStartInfo; |
||||
bool startMethodCalled; |
||||
bool startWithoutDebuggingMethodCalled; |
||||
bool stopMethodCalled; |
||||
|
||||
public MockDebugger() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the ProcessStartInfo passed to the Start or StartWithoutDebugging methods.
|
||||
/// </summary>
|
||||
public ProcessStartInfo ProcessStartInfo { |
||||
get { return processStartInfo; } |
||||
} |
||||
|
||||
public bool StartMethodCalled { |
||||
get { return startMethodCalled; } |
||||
} |
||||
|
||||
public bool StartWithoutDebuggingMethodCalled { |
||||
get { return startWithoutDebuggingMethodCalled; } |
||||
} |
||||
|
||||
public bool StopMethodCalled { |
||||
get { return stopMethodCalled; } |
||||
} |
||||
|
||||
public event EventHandler DebugStarting; |
||||
public event EventHandler DebugStarted; |
||||
public event EventHandler IsProcessRunningChanged; |
||||
public event EventHandler DebugStopped; |
||||
|
||||
public bool IsDebugging { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsProcessRunning { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool CanDebug(IProject project) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Start(ProcessStartInfo processStartInfo) |
||||
{ |
||||
this.processStartInfo = processStartInfo; |
||||
startMethodCalled = true; |
||||
} |
||||
|
||||
public void StartWithoutDebugging(ProcessStartInfo processStartInfo) |
||||
{ |
||||
this.processStartInfo = processStartInfo; |
||||
startWithoutDebuggingMethodCalled = true; |
||||
} |
||||
|
||||
public void Stop() |
||||
{ |
||||
stopMethodCalled = true; |
||||
} |
||||
|
||||
public void Break() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Continue() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void StepInto() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void StepOver() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void StepOut() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void ShowAttachDialog() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Attach(System.Diagnostics.Process process) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Detach() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public string GetValueAsString(string variable) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public DebuggerGridControl GetTooltipControl(string variable) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool CanSetInstructionPointer(string filename, int line, int column) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool SetInstructionPointer(string filename, int line, int column) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
protected virtual void OnDebugStarting(EventArgs e) |
||||
{ |
||||
if (DebugStarting != null) { |
||||
DebugStarting(this, e); |
||||
} |
||||
} |
||||
|
||||
|
||||
protected virtual void OnDebugStarted(EventArgs e) |
||||
{ |
||||
if (DebugStarted != null) { |
||||
DebugStarted(this, e); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnIsProcessRunningChanged(EventArgs e) |
||||
{ |
||||
if (IsProcessRunningChanged != null) { |
||||
IsProcessRunningChanged(this, e); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnDebugStopped(EventArgs e) |
||||
{ |
||||
if (DebugStopped != null) { |
||||
DebugStopped(this, e); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,25 +0,0 @@
@@ -1,25 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
#pragma warning disable 108, 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System.Runtime.CompilerServices; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
[ComImport, Guid("0C733A30-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType((short) 1)] |
||||
public interface ISequentialStream |
||||
{ |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void RemoteRead(out byte pv, [In] uint cb, out uint pcbRead); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 108, 1591
|
@ -1,43 +0,0 @@
@@ -1,43 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
#pragma warning disable 108, 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System.Runtime.CompilerServices; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
[ComImport, InterfaceType((short) 1), Guid("0000000C-0000-0000-C000-000000000046")] |
||||
public interface IStream : ISequentialStream |
||||
{ |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void RemoteRead(out byte pv, [In] uint cb, out uint pcbRead); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void RemoteSeek([In] _LARGE_INTEGER dlibMove, [In] uint dwOrigin, out _ULARGE_INTEGER plibNewPosition); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void SetSize([In] _ULARGE_INTEGER libNewSize); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void RemoteCopyTo([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In] _ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void Commit([In] uint grfCommitFlags); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void Revert(); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void LockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void UnlockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void Stat(out tagSTATSTG pstatstg, [In] uint grfStatFlag); |
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] |
||||
void Clone([MarshalAs(UnmanagedType.Interface)] out IStream ppstm); |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 108, 1591
|
@ -1,21 +0,0 @@
@@ -1,21 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
#pragma warning disable 108, 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System.Runtime.InteropServices; |
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack=8)] |
||||
public struct _LARGE_INTEGER |
||||
{ |
||||
public long QuadPart; |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 108, 1591
|
@ -1,21 +0,0 @@
@@ -1,21 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
#pragma warning disable 108, 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System.Runtime.InteropServices; |
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack=8)] |
||||
public struct _ULARGE_INTEGER |
||||
{ |
||||
public ulong QuadPart; |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 108, 1591
|
@ -1,33 +0,0 @@
@@ -1,33 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
#pragma warning disable 108, 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack=8)] |
||||
public struct tagSTATSTG |
||||
{ |
||||
[MarshalAs(UnmanagedType.LPWStr)] |
||||
public string pwcsName; |
||||
public uint type; |
||||
public _ULARGE_INTEGER cbSize; |
||||
public _FILETIME mtime; |
||||
public _FILETIME ctime; |
||||
public _FILETIME atime; |
||||
public uint grfMode; |
||||
public uint grfLocksSupported; |
||||
public Guid clsid; |
||||
public uint grfStateBits; |
||||
public uint reserved; |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 108, 1591
|
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue