Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4159 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
11 changed files with 391 additions and 299 deletions
@ -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,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); |
||||
} |
||||
} |
||||
} |
||||
@ -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,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); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue