Skip to content
Browse files

add some unittests, add more camera properties

  • Loading branch information...
1 parent 18411b0 commit e3838af734824c892f23509a5455f1096d5ef175 @esskar committed Jan 30, 2012
View
2 Canon.Eos.CameraCockpit/Forms/CockpitForm.cs
@@ -63,6 +63,8 @@ private void LoadCameras()
_cameraCollectionComboBox.Items.Clear();
foreach (var camera in _manager.GetCameras())
{
+ var iq = camera.ImageQuality;
+
camera.Shutdown += this.HandleCameraShutdown;
camera.PictureTaken += this.HandlePictureTaken;
_cameraCollectionComboBox.Items.Add(camera);
View
8 Canon.Eos.Framework/Canon.Eos.Framework.csproj
@@ -36,6 +36,8 @@
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="EosBatteryQuality.cs" />
+ <Compile Include="EosBracketMode.cs" />
<Compile Include="EosCamera.cs" />
<Compile Include="EosCamera.HandePropertyEvents.cs">
<DependentUpon>EosCamera.cs</DependentUpon>
@@ -47,14 +49,20 @@
<Compile Include="EosCamera.HandeObjectEvents.cs">
<DependentUpon>EosCamera.cs</DependentUpon>
</Compile>
+ <Compile Include="EosCompressLevel.cs" />
+ <Compile Include="EosImageFormat.cs" />
+ <Compile Include="EosImageQuality.cs" />
+ <Compile Include="EosImageSize.cs" />
<Compile Include="EosLiveViewDevice.cs" />
<Compile Include="EosErrorCode.cs" />
<Compile Include="EosException.cs" />
<Compile Include="EosFramework.cs" />
<Compile Include="EosDisposable.cs" />
<Compile Include="EosObject.cs" />
+ <Compile Include="EosPropertyAttribute.cs" />
<Compile Include="EosPropertyException.cs" />
<Compile Include="EosVolumeInfo.cs" />
+ <Compile Include="EosWhiteBalance.cs" />
<Compile Include="Eventing\EosFileImageEventArgs.cs" />
<Compile Include="Eventing\EosImageEventArgs.cs" />
<Compile Include="Eventing\EosVolumeInfoEventArgs.cs" />
View
10 Canon.Eos.Framework/EosBatteryQuality.cs
@@ -0,0 +1,10 @@
+namespace Canon.Eos.Framework
+{
+ public enum EosBatteryQuality : long
+ {
+ Low = 0,
+ Half,
+ High,
+ Full,
+ }
+}
View
10 Canon.Eos.Framework/EosBracketMode.cs
@@ -0,0 +1,10 @@
+namespace Canon.Eos.Framework
+{
+ public enum EosBracketMode : long
+ {
+ Off = 0,
+ AmberBlue = 1,
+ GreenMagenta = 2,
+ NotSupported = 0xFFFFFFFF,
+ }
+}
View
36 Canon.Eos.Framework/EosCamera.cs
@@ -45,6 +45,19 @@ public new string Artist
EosCamera.MaximumArtistLengthInBytes); }
}
+ [EosProperty(Edsdk.PropID_BatteryQuality)]
+ public long BatteryLevel
+ {
+ get { return this.GetPropertyIntegerData(Edsdk.PropID_BatteryLevel); }
+ set { this.SetPropertyIntegerData(Edsdk.PropID_BatteryLevel, value); }
+ }
+
+ public EosBatteryQuality BatteryQuality
+ {
+ get { return (EosBatteryQuality)this.GetPropertyIntegerData(Edsdk.PropID_BatteryQuality); }
+ set { this.SetPropertyIntegerData(Edsdk.PropID_BatteryQuality, (long)value); }
+ }
+
public new string Copyright
{
get { return base.Copyright; }
@@ -57,18 +70,41 @@ public string DeviceDescription
get { return _deviceInfo.szDeviceDescription; }
}
+ [EosProperty(Edsdk.PropID_ImageQuality)]
+ public EosImageQuality ImageQuality
+ {
+ get { return EosImageQuality.Create(this.GetPropertyIntegerData(Edsdk.PropID_ImageQuality)); }
+ set { this.SetPropertyIntegerData(Edsdk.PropID_ImageQuality, value.ToBitMask()); }
+ }
+
+ [EosProperty(Edsdk.PropID_Evf_Mode)]
public bool IsInLiveViewMode
{
get { return this.GetPropertyIntegerData(Edsdk.PropID_Evf_Mode) != 0; }
set { this.SetPropertyIntegerData(Edsdk.PropID_Evf_Mode, value ? 1 : 0); }
}
+ [EosProperty(Edsdk.PropID_Evf_ColorTemperature)]
+ public long LiveViewColorTemperature
+ {
+ get { return this.GetPropertyIntegerData(Edsdk.PropID_Evf_ColorTemperature); }
+ set { this.SetPropertyIntegerData(Edsdk.PropID_Evf_ColorTemperature, value); }
+ }
+
+ [EosProperty(Edsdk.PropID_Evf_OutputDevice)]
public EosLiveViewDevice LiveViewDevice
{
get { return (EosLiveViewDevice)this.GetPropertyIntegerData(Edsdk.PropID_Evf_OutputDevice); }
set { this.SetPropertyIntegerData(Edsdk.PropID_Evf_OutputDevice, (long)value); }
}
+ [EosProperty(Edsdk.PropID_Evf_WhiteBalance)]
+ public EosWhiteBalance LiveViewWhiteBalance
+ {
+ get { return (EosWhiteBalance)this.GetPropertyIntegerData(Edsdk.PropID_Evf_WhiteBalance); }
+ set { this.SetPropertyIntegerData(Edsdk.PropID_Evf_WhiteBalance, (long)value); }
+ }
+
public bool IsLegacy
{
get { return _deviceInfo.DeviceSubType == 0; }
View
18 Canon.Eos.Framework/EosCompressLevel.cs
@@ -0,0 +1,18 @@
+namespace Canon.Eos.Framework
+{
+ public enum EosCompressLevel : byte
+ {
+ Unknown = 0xF,
+ JpegUncompressed = 0,
+ JpegCompression1 = 1,
+ Normal = 2,
+ Fine = 3,
+ Lossless = 4,
+ SuperFine = 5,
+ JpegCompression6 = 6,
+ JpegCompression7 = 7,
+ JpegCompression8 = 8,
+ JpegCompression9 = 9,
+ JpegCompression10 = 10,
+ }
+}
View
11 Canon.Eos.Framework/EosImageFormat.cs
@@ -0,0 +1,11 @@
+namespace Canon.Eos.Framework
+{
+ public enum EosImageFormat : byte
+ {
+ Unknown = 0x0,
+ Jpeg = 0x1,
+ Crw = 0x2,
+ Raw = 0x4,
+ Cr2 = 0x6,
+ }
+}
View
54 Canon.Eos.Framework/EosImageQuality.cs
@@ -0,0 +1,54 @@
+namespace Canon.Eos.Framework
+{
+ public struct EosImageQuality
+ {
+ private EosImageSize _secondaryImageSize;
+
+ public EosImageSize PrimaryImageSize { get; set; }
+
+ public EosImageFormat PrimaryImageFormat { get; set; }
+
+ public EosCompressLevel PrimaryCompressLevel { get; set; }
+
+ public EosImageSize SecondaryImageSize
+ {
+ get { return (byte)_secondaryImageSize >= 0xF ? EosImageSize.Unknown : _secondaryImageSize; }
+ set { _secondaryImageSize = value; }
+ }
+
+ public EosImageFormat SecondaryImageFormat { get; set; }
+
+ public EosCompressLevel SecondaryCompressLevel { get; set; }
+
+ public override string ToString()
+ {
+ return string.Format("Primary Image: Size <{0}>, Format <{1}>, CompressLevel <{2}>\n"
+ + "Secondary Image: Size <{3}>, Format <{4}>, CompressLevel <{5}>",
+ this.PrimaryImageSize, this.PrimaryImageFormat, this.PrimaryCompressLevel,
+ this.SecondaryImageSize, this.SecondaryImageFormat, this.SecondaryCompressLevel);
+ }
+
+ internal static EosImageQuality Create(long bitMask)
+ {
+ var quality = new EosImageQuality {
+ PrimaryImageSize = (EosImageSize)((bitMask >> 24) & 0xFF),
+ PrimaryImageFormat = (EosImageFormat)((bitMask >> 20) & 0xF),
+ PrimaryCompressLevel = (EosCompressLevel)((bitMask >> 16) & 0xF),
+ SecondaryImageSize = (EosImageSize)((bitMask >> 8) & 0xF),
+ SecondaryImageFormat = (EosImageFormat)((bitMask >> 4) & 0xF),
+ SecondaryCompressLevel = (EosCompressLevel)(bitMask & 0xF),
+ };
+ return quality;
+ }
+
+ internal long ToBitMask()
+ {
+ return (uint)this.PrimaryImageSize << 24 |
+ (uint)this.PrimaryImageFormat << 20 |
+ (uint)this.PrimaryCompressLevel << 16 |
+ (uint)this.SecondaryImageSize << 8 |
+ (uint)this.SecondaryImageFormat << 4 |
+ (uint)this.SecondaryCompressLevel;
+ }
+ }
+}
View
15 Canon.Eos.Framework/EosImageSize.cs
@@ -0,0 +1,15 @@
+namespace Canon.Eos.Framework
+{
+ public enum EosImageSize : uint
+ {
+ Unknown = 0xFF,
+ Large = 0,
+ Middle = 1,
+ Small = 2,
+ Middle2 = 5,
+ Middle3 = 6,
+ Small2 = 14,
+ Small3 = 15,
+ Small4 = 16,
+ }
+}
View
29 Canon.Eos.Framework/EosObject.cs
@@ -2,7 +2,6 @@
using System.Runtime.InteropServices;
using Canon.Eos.Framework.Extensions;
using Canon.Eos.Framework.Helper;
-using Canon.Eos.Framework.Internal;
using Canon.Eos.Framework.Internal.SDK;
namespace Canon.Eos.Framework
@@ -21,42 +20,63 @@ protected internal IntPtr Handle
get { return _handle; }
}
+ [EosProperty(Edsdk.PropID_Artist)]
public string Artist
{
get { return this.GetPropertyStringData(Edsdk.PropID_Artist); }
}
+ [EosProperty(Edsdk.PropID_Copyright)]
public string Copyright
{
get { return this.GetPropertyStringData(Edsdk.PropID_Copyright); }
}
+ [EosProperty(Edsdk.PropID_FirmwareVersion)]
public string FirmwareVersion
{
get { return this.GetPropertyStringData(Edsdk.PropID_FirmwareVersion); }
}
+ [EosProperty(Edsdk.PropID_OwnerName)]
public string OwnerName
{
get { return this.GetPropertyStringData(Edsdk.PropID_OwnerName); }
}
+ [EosProperty(Edsdk.PropID_ProductName)]
public string ProductName
{
get { return this.GetPropertyStringData(Edsdk.PropID_ProductName); }
}
+ [EosProperty(Edsdk.PropID_BodyIDEx)]
public string SerialNumber
{
get { return this.GetPropertyStringData(Edsdk.PropID_BodyIDEx); }
}
+ [EosProperty(Edsdk.PropID_WhiteBalance)]
+ public EosWhiteBalance WhiteBalance
+ {
+ get { return (EosWhiteBalance)this.GetPropertyIntegerData(Edsdk.PropID_WhiteBalance); }
+ set { this.SetPropertyIntegerData(Edsdk.PropID_WhiteBalance, (long)value); }
+ }
+
protected internal override void DisposeUnmanaged()
{
Edsdk.EdsRelease(_handle);
base.DisposeUnmanaged();
}
+ protected string GetPropertyDescription(uint propertyId)
+ {
+ Edsdk.EdsPropertyDesc desc;
+ this.Assert(Edsdk.EdsGetPropertyDesc(this.Handle, propertyId, out desc),
+ string.Format("Failed to get property description for data: propertyId {0}", propertyId), propertyId);
+ return null;
+ }
+
protected long GetPropertyIntegerData(uint propertyId)
{
uint data;
@@ -80,6 +100,13 @@ protected void SetPropertyIntegerData(uint propertyId, long data)
propertyId, data);
}
+ protected void SetPropertyIntegerArrayData(uint propertyId, uint[] data)
+ {
+ this.Assert(Edsdk.EdsSetPropertyData(this.Handle, propertyId, 0, Marshal.SizeOf(typeof(uint))*data.Length, data),
+ string.Format("Failed to set property integer array data: propertyId {0}, data {1}", propertyId, data),
+ propertyId, data);
+ }
+
protected void SetPropertyStringData(uint propertyId, string data, int maxByteLength)
{
var bytes = Util.ConvertStringToBytesWithNullByteAtEnd(data);
View
14 Canon.Eos.Framework/EosPropertyAttribute.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace Canon.Eos.Framework
+{
+ public class EosPropertyAttribute : Attribute
+ {
+ public EosPropertyAttribute(uint propertyId)
+ {
+ this.PropertyId = propertyId;
+ }
+
+ public uint PropertyId { get; private set; }
+ }
+}
View
26 Canon.Eos.Framework/EosWhiteBalance.cs
@@ -0,0 +1,26 @@
+namespace Canon.Eos.Framework
+{
+ public enum EosWhiteBalance : long
+ {
+ Pasted = -2,
+ Click = -1,
+ Auto = 0,
+ Daylight = 1,
+ Cloudy = 2,
+ Tungsten = 3,
+ Fluorescent = 4,
+ Flash = 5,
+ Manual = 6,
+ Shade = 8,
+ ColorTemperature = 9,
+ Custom = 10,
+ Custom2 = 11,
+ Custom3 = 12,
+ Manual2 = 15,
+ Manual3 = 16,
+ Manual4 = 18,
+ Manual5 = 19,
+ Custom4 = 20,
+ Custom5 = 21,
+ }
+}
View
27 Canon.Eos.Framework/Extensions/EosAssertableExtensions.cs
@@ -1,6 +1,5 @@
using System;
using Canon.Eos.Framework.Interfaces;
-using Canon.Eos.Framework.Internal;
using Canon.Eos.Framework.Internal.SDK;
namespace Canon.Eos.Framework.Extensions
@@ -29,31 +28,5 @@ public static void Assert(this IEosAssertable assertable, uint result, string me
if (assertable.HasFailed(result))
throw new EosPropertyException(result, message) { PropertyId = propertyId, PropertyValue = propertyValue };
}
-
- public static void TryAndCatch(this IEosAssertable assertable, Action action, string unexpectedMessage = null)
- {
- assertable.TryAndCatch(action, null, unexpectedMessage);
- }
-
- public static void TryAndCatch(this IEosAssertable assertable, Action action, Action final, string unexpectedMessage = null)
- {
- try
- {
- action();
- }
- catch (EosException)
- {
- throw;
- }
- catch (Exception ex)
- {
- throw new EosException(-1, unexpectedMessage ?? "Unexpected exception", ex);
- }
- finally
- {
- if (final != null)
- final();
- }
- }
}
}
View
41 Canon.Eos.Framework/Internal/EosImageTransporter.cs
@@ -44,20 +44,39 @@ private void Download(IntPtr directoryItem, uint size, IntPtr stream)
{
if (stream == IntPtr.Zero)
return;
- this.TryAndCatch(
- () => {
- this.Assert(Edsdk.EdsDownload(directoryItem, size, stream), "Failed to download to stream");
- this.Assert(Edsdk.EdsDownloadComplete(directoryItem), "Failed to complete download");
- },
- "Unexpected exception while downloading.");
+ try
+ {
+ this.Assert(Edsdk.EdsDownload(directoryItem, size, stream), "Failed to download to stream");
+ this.Assert(Edsdk.EdsDownloadComplete(directoryItem), "Failed to complete download");
+ }
+ catch (EosException)
+ {
+ throw;
+ }
+ catch (Exception ex)
+ {
+ throw new EosException(-1, "Unexpected exception while downloading.", ex);
+ }
}
private void Transport(IntPtr directoryItem, uint size, IntPtr stream, bool destroyStream)
{
- this.TryAndCatch(
- () => { this.Download(directoryItem, size, stream); },
- () => { if (destroyStream) this.DestroyStream(ref stream); },
- "Unexpected exception while transporting.");
+ try
+ {
+ this.Download(directoryItem, size, stream);
+ }
+ catch (EosException)
+ {
+ throw;
+ }
+ catch (Exception ex)
+ {
+ throw new EosException(-1, "Unexpected exception while transporting.", ex);
+ }
+ finally
+ {
+ if (destroyStream) this.DestroyStream(ref stream);
+ }
}
public EosImageEventArgs TransportAsFile(IntPtr directoryItem, string imageBasePath)
@@ -67,7 +86,7 @@ public EosImageEventArgs TransportAsFile(IntPtr directoryItem, string imageBaseP
var stream = this.CreateFileStream(imageFilePath);
this.Transport(directoryItem, directoryItemInfo.Size, stream, true);
- return new EosFileImageEventArgs(imageBasePath);
+ return new EosFileImageEventArgs(imageFilePath);
}
public EosImageEventArgs TransportInMemory(IntPtr directoryItem)
View
2 Canon.Eos.Framework/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Canon.Eos.Framework")]
@@ -13,3 +14,4 @@
[assembly: Guid("3a70507d-c50a-47ca-b920-303d687631ec")]
[assembly: AssemblyVersion("0.1.0.1")]
[assembly: AssemblyFileVersion("0.1.0.1")]
+[assembly: InternalsVisibleTo("Canon.Eos.UnitTests")]
View
22 Canon.Eos.Solution.sln
@@ -5,7 +5,19 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canon.Eos.Framework", "Cano
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canon.Eos.CameraCockpit", "Canon.Eos.CameraCockpit\Canon.Eos.CameraCockpit.csproj", "{BC8E799D-14D7-48AD-8AC4-45BF7CB67D46}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canon.Eos.UnitTests", "Canon.Eos.UnitTests\Canon.Eos.UnitTests.csproj", "{CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{70C5F29D-C9A4-495B-B52E-32A9E9892A46}"
+ ProjectSection(SolutionItems) = preProject
+ Canon.Eos.Solution.vsmdi = Canon.Eos.Solution.vsmdi
+ Local.testsettings = Local.testsettings
+ TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
+ EndProjectSection
+EndProject
Global
+ GlobalSection(TestCaseManagementSettings) = postSolution
+ CategoryFile = Canon.Eos.Solution.vsmdi
+ EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
@@ -35,6 +47,16 @@ Global
{BC8E799D-14D7-48AD-8AC4-45BF7CB67D46}.Release|Mixed Platforms.Build.0 = Release|x86
{BC8E799D-14D7-48AD-8AC4-45BF7CB67D46}.Release|x86.ActiveCfg = Release|x86
{BC8E799D-14D7-48AD-8AC4-45BF7CB67D46}.Release|x86.Build.0 = Release|x86
+ {CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
10 Canon.Eos.UnitTests/BaseTests.cs
@@ -0,0 +1,10 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Canon.Eos.UnitTests
+{
+ [TestClass]
+ public class BaseTests
+ {
+ public TestContext TestContext { get; set; }
+ }
+}
View
66 Canon.Eos.UnitTests/Canon.Eos.UnitTests.csproj
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>
+ </ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{CD5524BB-7BB7-4E91-B973-F0327E5E1DE9}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Canon.Eos.UnitTests</RootNamespace>
+ <AssemblyName>Canon.Eos.UnitTests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="EosImageQualityTests.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="BaseTests.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Canon.Eos.Framework\Canon.Eos.Framework.csproj">
+ <Project>{F809DBB6-E0E8-47A8-92ED-C24575576A5D}</Project>
+ <Name>Canon.Eos.Framework</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
51 Canon.Eos.UnitTests/EosImageQualityTests.cs
@@ -0,0 +1,51 @@
+using Canon.Eos.Framework;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Canon.Eos.UnitTests
+{
+ [TestClass]
+ public class EosImageQualityTests
+ {
+ private static void AssertConversion(long expectedValue, EosImageQuality expectedQuality)
+ {
+ var actualQuality = EosImageQuality.Create(expectedValue);
+ Assert.AreEqual(expectedQuality.PrimaryCompressLevel, actualQuality.PrimaryCompressLevel, "PrimaryCompressLevel");
+ Assert.AreEqual(expectedQuality.PrimaryImageFormat, actualQuality.PrimaryImageFormat, "PrimaryImageFormat");
+ Assert.AreEqual(expectedQuality.PrimaryImageSize, actualQuality.PrimaryImageSize, "PrimaryImageSize");
+ Assert.AreEqual(expectedQuality.SecondaryCompressLevel, actualQuality.SecondaryCompressLevel, "SecondaryCompressLevel");
+ Assert.AreEqual(expectedQuality.SecondaryImageFormat, actualQuality.SecondaryImageFormat, "SecondaryImageFormat");
+ Assert.AreEqual(expectedQuality.SecondaryImageSize, actualQuality.SecondaryImageSize, "SecondaryImageSize");
+
+ var actualValue = actualQuality.ToBitMask();
+ Assert.AreEqual(expectedValue, actualValue, "ToBitMask");
+ }
+
+ [TestMethod]
+ public void CheckLargeCrwTest()
+ {
+ AssertConversion(0x002f000f, new EosImageQuality
+ {
+ PrimaryCompressLevel = EosCompressLevel.Unknown,
+ PrimaryImageFormat = EosImageFormat.Crw,
+ PrimaryImageSize = EosImageSize.Large,
+ SecondaryCompressLevel = EosCompressLevel.Unknown,
+ SecondaryImageFormat = EosImageFormat.Unknown,
+ SecondaryImageSize = EosImageSize.Large,
+ });
+ }
+
+ [TestMethod]
+ public void CheckLargeJpegTest()
+ {
+ AssertConversion(0x0010ff0f, new EosImageQuality
+ {
+ SecondaryCompressLevel = EosCompressLevel.Unknown,
+ SecondaryImageFormat = EosImageFormat.Unknown,
+ SecondaryImageSize = EosImageSize.Unknown,
+ PrimaryCompressLevel = EosCompressLevel.JpegUncompressed,
+ PrimaryImageFormat = EosImageFormat.Jpeg,
+ PrimaryImageSize = EosImageSize.Large,
+ });
+ }
+ }
+}
View
35 Canon.Eos.UnitTests/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 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("Canon.Eos.UnitTests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Canon.Eos.UnitTests")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("aa483176-6d66-471e-963e-ab235890e13b")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit e3838af

Please sign in to comment.
Something went wrong with that request. Please try again.