"Merged" 0.8 with HEAD, so we can continue developing

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1282 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2011-07-17 12:05:59 +00:00
commit f3b0878b02
539 changed files with 86855 additions and 0 deletions

View file

@ -0,0 +1,70 @@
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{EFD01BC7-15E5-48AD-BE68-D7B62FEEED2D}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>Library</OutputType>
<RootNamespace>GreenshotTest</RootNamespace>
<AssemblyName>GreenshotTest</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Users\Robin\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Test\Drawing\Filters\BitmapByteBufferTest.cs" />
<Compile Include="Test\Drawing\Properties\PropertyAggregatorTest.cs" />
<Compile Include="Test\SaveImageFileDialogTest.cs" />
<None Include="lib\nunit.framework.dll" />
</ItemGroup>
<ItemGroup>
<Folder Include="lib" />
<Folder Include="Test" />
<Folder Include="Test\Drawing" />
<Folder Include="Test\Drawing\Filters" />
<Folder Include="Test\Drawing\Properties" />
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj">
<Project>{5B924697-4DCD-4F98-85F1-105CB84B7341}</Project>
<Name>GreenshotPlugin</Name>
</ProjectReference>
<ProjectReference Include="..\Greenshot\Greenshot.csproj">
<Project>{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}</Project>
<Name>Greenshot</Name>
</ProjectReference>
</ItemGroup>
</Project>

View file

@ -0,0 +1,31 @@
#region Using directives
using System;
using System.Reflection;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("GreenshotTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GreenshotTest")]
[assembly: AssemblyCopyright("Copyright 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]

View file

@ -0,0 +1,197 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using NUnit.Framework;
using System;
using System.Drawing;
using System.Drawing.Imaging;
using Greenshot.Drawing;
using Greenshot.Drawing.Filters;
namespace Greenshot.Test.Drawing.Filters {
/// <summary>
/// Description of BitmapBufferTest.
/// </summary>
[TestFixture]
public class BitmapBufferTest
{
private Bitmap bmp;
private BitmapBuffer buf;
private Bitmap bmpRect;
private BitmapBuffer bufRect;
[SetUp]
public void Init()
{
bmp = new Bitmap(6,6);
for(int i=0; i<6; i++) {
int col = 255-i*51;
bmp.SetPixel(0,i, Color.FromArgb(col,0,0));
bmp.SetPixel(1,i, Color.FromArgb(col,col,0));
bmp.SetPixel(2,i, Color.FromArgb(0,col,0));
bmp.SetPixel(3,i, Color.FromArgb(0,col,col));
bmp.SetPixel(4,i, Color.FromArgb(0,0,col));
bmp.SetPixel(5,i, Color.FromArgb(col,0,col));
}
buf = new BitmapBuffer(bmp);
bmpRect = new Bitmap(6,6);
for(int i=0; i<6; i++) {
int col = 255-i*51;
bmpRect.SetPixel(0,i, Color.FromArgb(col,0,0));
bmpRect.SetPixel(1,i, Color.FromArgb(col,col,0));
bmpRect.SetPixel(2,i, Color.FromArgb(0,col,0));
bmpRect.SetPixel(3,i, Color.FromArgb(0,col,col));
bmpRect.SetPixel(4,i, Color.FromArgb(0,0,col));
bmpRect.SetPixel(5,i, Color.FromArgb(col,0,col));
}
bufRect = new BitmapBuffer(bmpRect,new Rectangle(2,2,2,2));
}
[TearDown]
public void Dispose()
{
buf.Dispose();
buf = null;
bmp.Dispose();
bmp = null;
}
[Test]
public void TestGetSetColor()
{
// Assert.AreEqual(255, buf.R);
// Assert.AreEqual(0, buf.G);
// Assert.AreEqual(0, buf.B);
// Assert.AreEqual(Color.FromArgb(255,0,0), buf.Color);
//
// buf.B = 255;
// Assert.AreEqual(255, buf.R);
// Assert.AreEqual(0, buf.G);
// Assert.AreEqual(255, buf.B);
// Assert.AreEqual(Color.FromArgb(255,0,255), buf.Color);
//
// buf.Color = Color.Red;
// Assert.AreEqual(255, buf.R);
// Assert.AreEqual(0, buf.G);
// Assert.AreEqual(0, buf.B);
// Assert.AreEqual(Color.FromArgb(255,0,0), buf.Color);
}
[Test]
public void TestGetSetColorRect()
{
// Assert.AreEqual(0, bufRect.R);
// Assert.AreEqual(153, bufRect.G);
// Assert.AreEqual(0, bufRect.B);
// Assert.AreEqual(Color.FromArgb(0,153,0), bufRect.Color);
//
// bufRect.B = 255;
// Assert.AreEqual(0, bufRect.R);
// Assert.AreEqual(153, bufRect.G);
// Assert.AreEqual(255, bufRect.B);
// Assert.AreEqual(Color.FromArgb(0,153,255), bufRect.Color);
//
// bufRect.Color = Color.FromArgb(0,153,0);
// Assert.AreEqual(0, bufRect.R);
// Assert.AreEqual(153, bufRect.G);
// Assert.AreEqual(0, bufRect.B);
// Assert.AreEqual(Color.FromArgb(0,153,0), bufRect.Color);
}
[Test]
public void TestModifyBitmap()
{
// //buf.MoveTo(0,0);
// buf.Color = Color.FromArgb(255,255,255);
// buf.Dispose();
// buf = new BitmapBuffer(bmp);
// Assert.AreEqual(Color.FromArgb(255,255,255), buf.Color);
// buf.Color = Color.FromArgb(255,0,0);
}
[Test]
public void TestTraverse()
{
/*buf.MoveTo(0,0);
buf.Traverse(1,0);
Assert.AreEqual(Color.FromArgb(255,255,0), buf.Color);
buf.Traverse(0,1);
Assert.AreEqual(Color.FromArgb(204,204,0), buf.Color);
buf.Traverse(2,2);
Assert.AreEqual(Color.FromArgb(0,102,102), buf.Color);
buf.MoveTo(4,4);
Assert.AreEqual(Color.FromArgb(0,0,51), buf.Color);
buf.MoveTo(2,2);
Assert.AreEqual(Color.FromArgb(0,153,0), buf.Color);
buf.MoveTo(0,0);
Assert.AreEqual(Color.FromArgb(255,0,0), buf.Color);*/
}
[Test]
public void TestColorAt(){
Assert.AreEqual(Color.FromArgb(255,0,0),buf.GetColorAt(0,0));
Assert.AreEqual(Color.FromArgb(255,255,0),buf.GetColorAt(1,0));
Assert.AreEqual(Color.FromArgb(204,204,0),buf.GetColorAt(1,1));
Assert.AreEqual(Color.FromArgb(0,153,0),buf.GetColorAt(2,2));
Assert.AreEqual(Color.FromArgb(204,204,0),buf.GetColorAt(1,1));
Assert.AreEqual(Color.FromArgb(0,0,51),buf.GetColorAt(4,4));
}
[Test]
public void TestIterate()
{
// buf.IteratePixel += delegate {
// if(buf.Location.X == 0 && buf.Location.Y == 0)
// {
// Assert.AreEqual(Color.FromArgb(255,0,0), buf.Color);
// }
// else if(buf.Location.X == 3 && buf.Location.Y == 3)
// {
// Assert.AreEqual(Color.FromArgb(0,102,102), buf.Color);
// }
// };
// buf.Iterate();
}
[Test]
public void TestIterateRect()
{
// bufRect.IteratePixel += delegate {
// if(bufRect.Location.X == 0 && bufRect.Location.Y == 0)
// {
// Assert.AreEqual(Color.FromArgb(0,153,0), bufRect.Color);
// }
// else if(bufRect.Location.X == 1 && bufRect.Location.Y == 0)
// {
// Assert.AreEqual(Color.FromArgb(0,153,153), bufRect.Color);
// }
// };
// bufRect.Iterate();
}
}
}

View file

@ -0,0 +1,111 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using NUnit.Framework;
using System;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Drawing;
using Greenshot.Drawing.Fields;
namespace Greenshot.Test.Drawing.Properties
{
/// <summary>
/// Description of PropertyAggregatorTest.
/// </summary>
[TestFixture]
public class PropertyAggregatorTest
{
[SetUp]
public void Init()
{
}
[TearDown]
public void Dispose()
{
}
[Test]
public void Test()
{
FieldType t = FieldType.LINE_THICKNESS;
Surface s = new Surface();
FieldAggregator ep = new FieldAggregator();
//ep.SetFieldValue(t,598);
RectangleContainer rc = new RectangleContainer(s);
rc.SetFieldValue(t,597);
//Assert.AreNotEqual(ep.GetField(t), rc.GetField(t));
ep.BindElement(rc);
Assert.AreEqual(597, ep.GetField(t).Value);
Assert.AreEqual(597, rc.GetField(t).Value);
RectangleContainer rc2 = new RectangleContainer(s);
Assert.AreEqual(597, ep.GetField(t).Value);
rc2.SetFieldValue(t,595);
Assert.AreEqual(595, rc2.GetField(t).Value);
ep.BindElement(rc2);
Assert.AreEqual(595, ep.GetField(t).Value);
Assert.AreEqual(597, rc.GetField(t).Value);
RectangleContainer rc3 = new RectangleContainer(s);
rc3.SetFieldValue(t,600);
ep.BindElement(rc3);
//Assert.AreEqual(600, ep.GetField(t).Value);
Assert.AreEqual(600, rc3.GetField(t).Value);
Assert.AreEqual(597, rc.GetField(t).Value);
ep.SetFieldValue(t, 599);
Assert.AreEqual(599, ep.GetField(t).Value);
Assert.AreEqual(599, rc.GetField(t).Value);
Assert.AreEqual(599, rc2.GetField(t).Value);
Assert.AreEqual(599, rc3.GetField(t).Value);
}
public class TestIrrelevantPropertyHolder : RectangleContainer
{
public TestIrrelevantPropertyHolder() : base(new Surface())
{
}
public int Leet = 1337;
}
}
}

View file

@ -0,0 +1,90 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using NUnit.Framework;
using System;
using Greenshot.Drawing;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Filters;
using Greenshot.Helpers;
namespace Greenshot.Test.Drawing.Properties
{
/// <summary>
/// Description of SerializationTest.
/// </summary>
[TestFixture]
public class SerializationTest
{
public SerializationTest()
{
}
[Test]
public void TestSerializeField() {
Field f = new Field(FieldType.ARROWHEADS, GetType());
f.myValue = ArrowContainer.ArrowHeadCombination.BOTH;
Field clone = (Field) Objects.DeepClone(f);
Assert.AreEqual(f, clone);
Assert.AreEqual(f.Value, clone.Value);
Assert.AreEqual(f.Scope, clone.Scope);
f.Scope = this.GetType().ToString();
clone = (Field) Objects.DeepClone(f);
Assert.AreEqual(f, clone);
Assert.AreEqual(f.Value, clone.Value);
Assert.AreEqual(f.Scope, clone.Scope);
}
[Test]
public void TestSerializeFieldHolder() {
AbstractFieldHolder afh = new TestFieldHolder();
AbstractFieldHolder clone = (AbstractFieldHolder)Objects.DeepClone(afh);
Assert.AreEqual(afh.GetFields(), clone.GetFields());
}
[Test]
public void TestSerializeFieldHolderWithChildren() {
AbstractFieldHolderWithChildren afh = new TestFieldHolderWithChildren();
AbstractFieldHolderWithChildren clone = (AbstractFieldHolderWithChildren)Objects.DeepClone(afh);
Assert.AreEqual(afh.GetFields(), clone.GetFields());
}
[Test]
public void TestSerializeFilterContainer() {
ObfuscateContainer oc = new ObfuscateContainer(new Surface());
ObfuscateContainer clone = (ObfuscateContainer)Objects.DeepClone(oc);
Assert.AreEqual(oc.Children.GetType(), clone.Children.GetType());
System.Collections.Generic.List<Field> ocFields = oc.GetFields();
System.Collections.Generic.List<Field> cloneFields = clone.GetFields();
Assert.AreEqual(ocFields, cloneFields);
}
[Serializable]
private class TestFieldHolder : AbstractFieldHolder {}
[Serializable]
private class TestFieldHolderWithChildren : AbstractFieldHolderWithChildren {}
}
}

View file

@ -0,0 +1,77 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Forms;
using GreenshotPlugin.Core;
using NUnit.Framework;
namespace Greenshot.Test
{
[TestFixture]
public class SaveImageFileDialogTest {
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
[Test]
public void GetSetExtensionTest() {
SaveImageFileDialog sifd = new SaveImageFileDialog();
sifd.Extension = "jpg";
Assert.AreEqual(sifd.Extension, "jpg");
sifd.Extension = "gif";
Assert.AreEqual(sifd.Extension, "gif");
sifd.Extension = "png";
Assert.AreEqual(sifd.Extension, "png");
sifd.Extension = "bmp";
Assert.AreEqual(sifd.Extension, "bmp");
}
[Test]
public void GetFileNameWithExtensionTest() {
SaveImageFileDialog sifd = new SaveImageFileDialog();
sifd.InitialDirectory = @"C:\some\path";
sifd.FileName = "myimage.jpg";
sifd.Extension = "jpg";
Assert.AreEqual("myimage.jpg",sifd.FileNameWithExtension);
sifd.Extension = "gif";
Assert.AreEqual("myimage.jpg.gif",sifd.FileNameWithExtension);
sifd.FileName = "myimage";
Assert.AreEqual("myimage.gif",sifd.FileNameWithExtension);
}
[Test]
public void SuggestBasicFileNameTest() {
//conf.Output_FileAs_Fullpath = @"c:\path\to\greenshot_testdir\gstest_28.jpg";
conf.OutputFilePath = @"c:\path\to\greenshot_testdir\";
conf.OutputFileFilenamePattern = "gstest_${NUM}";
conf.OutputFileFormat = OutputFormat.png;
conf.OutputFileIncrementingNumber = 28;
SaveImageFileDialog sifd = new SaveImageFileDialog();
Assert.AreEqual(sifd.InitialDirectory, @"c:\path\to\greenshot_testdir");
Assert.AreEqual(sifd.FileNameWithExtension, "gstest_000028.jpg");
}
}
}

Binary file not shown.