[mapguide-commits] r1161 - trunk/MgDev/Server/src/UnitTesting
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Mar 6 20:05:59 EST 2007
Author: waltweltonlair
Date: 2007-03-06 20:05:59 -0500 (Tue, 06 Mar 2007)
New Revision: 1161
Modified:
trunk/MgDev/Server/src/UnitTesting/TestRenderingService.cpp
trunk/MgDev/Server/src/UnitTesting/TestRenderingService.h
Log:
Add symbology unit tests (temporarily disabled for Linux)...
Modified: trunk/MgDev/Server/src/UnitTesting/TestRenderingService.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestRenderingService.cpp 2007-03-07 00:25:22 UTC (rev 1160)
+++ trunk/MgDev/Server/src/UnitTesting/TestRenderingService.cpp 2007-03-07 01:05:59 UTC (rev 1161)
@@ -19,6 +19,7 @@
#include "TestRenderingService.h"
#include "ServiceManager.h"
#include "../Common/Manager/FdoConnectionManager.h"
+#include "SAX2Parser.h"
const STRING TEST_LOCALE = L"en";
@@ -29,12 +30,10 @@
{
MgServiceManager* serviceManager = MgServiceManager::GetInstance();
- m_svcResource = dynamic_cast<MgResourceService*>(
- serviceManager->RequestService(MgServiceType::ResourceService));
+ m_svcResource = dynamic_cast<MgResourceService*>(serviceManager->RequestService(MgServiceType::ResourceService));
assert(m_svcResource != NULL);
- m_svcRendering = dynamic_cast<MgRenderingService*>(
- serviceManager->RequestService(MgServiceType::RenderingService));
+ m_svcRendering = dynamic_cast<MgRenderingService*>(serviceManager->RequestService(MgServiceType::RenderingService));
assert(m_svcRendering != NULL);
}
@@ -143,6 +142,115 @@
Ptr<MgByteSource> datasrc = new MgByteSource(L"../UnitTestFiles/UT_Symbols.dwf", false);
Ptr<MgByteReader> datardr = datasrc->GetReader();
m_svcResource->SetResourceData(slres1, L"symbols.dwf", L"File", datardr);
+
+
+ //
+ // publish symbology stuff
+ //
+
+ // the point feature source
+ Ptr<MgResourceIdentifier> fsres4 = new MgResourceIdentifier(L"Library://Symbology/Data/Capitals.FeatureSource");
+ Ptr<MgByteSource> fssrc4 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyPoints.fs", false);
+ Ptr<MgByteReader> fsrdr4 = fssrc4->GetReader();
+ m_svcResource->SetResource(fsres4, fsrdr4, NULL);
+
+ // point sdf file
+ Ptr<MgByteSource> dataSource4 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyPoints.sdf", false);
+ Ptr<MgByteReader> dataReader4 = dataSource4->GetReader();
+ m_svcResource->SetResourceData(fsres4, L"UT_SymbologyPoints.sdf", L"File", dataReader4);
+
+ // point symbols
+ Ptr<MgResourceIdentifier> sdres1 = new MgResourceIdentifier(L"Library://Symbology/Symbols/PointSymbol.SymbolDefinition");
+ Ptr<MgByteSource> sdsrc1 = new MgByteSource(L"../UnitTestFiles/symbol.sd", false);
+ Ptr<MgByteReader> sdrdr1 = sdsrc1->GetReader();
+ m_svcResource->SetResource(sdres1, sdrdr1, NULL);
+
+ Ptr<MgResourceIdentifier> sdres2 = new MgResourceIdentifier(L"Library://Symbology/Symbols/PointSymbolParam.SymbolDefinition");
+ Ptr<MgByteSource> sdsrc2 = new MgByteSource(L"../UnitTestFiles/symbolp.sd", false);
+ Ptr<MgByteReader> sdrdr2 = sdsrc2->GetReader();
+ m_svcResource->SetResource(sdres2, sdrdr2, NULL);
+
+ // point ldf
+ Ptr<MgResourceIdentifier> ldfres4 = new MgResourceIdentifier(L"Library://Symbology/Layers/Capitals.LayerDefinition");
+ Ptr<MgByteSource> ldfsrc4 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyPoints.ldf", false);
+ Ptr<MgByteReader> ldfrdr4 = ldfsrc4->GetReader();
+ m_svcResource->SetResource(ldfres4, ldfrdr4, NULL);
+
+ Ptr<MgResourceIdentifier> ldfres5 = new MgResourceIdentifier(L"Library://Symbology/Layers/CapitalsParam.LayerDefinition");
+ Ptr<MgByteSource> ldfsrc5 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyPointsParam.ldf", false);
+ Ptr<MgByteReader> ldfrdr5 = ldfsrc5->GetReader();
+ m_svcResource->SetResource(ldfres5, ldfrdr5, NULL);
+
+ // point mdf
+ Ptr<MgResourceIdentifier> mapres2 = new MgResourceIdentifier(L"Library://Symbology/Maps/Capitals.MapDefinition");
+ Ptr<MgByteSource> mdfsrc2 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyPoints.mdf", false);
+ Ptr<MgByteReader> mdfrdr2 = mdfsrc2->GetReader();
+ m_svcResource->SetResource(mapres2, mdfrdr2, NULL);
+
+ Ptr<MgResourceIdentifier> mapres3 = new MgResourceIdentifier(L"Library://Symbology/Maps/CapitalsParam.MapDefinition");
+ Ptr<MgByteSource> mdfsrc3 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyPointsParam.mdf", false);
+ Ptr<MgByteReader> mdfrdr3 = mdfsrc3->GetReader();
+ m_svcResource->SetResource(mapres3, mdfrdr3, NULL);
+
+ // the line feature source
+ Ptr<MgResourceIdentifier> fsres5 = new MgResourceIdentifier(L"Library://Symbology/Data/Lines.FeatureSource");
+ Ptr<MgByteSource> fssrc5 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyLines.fs", false);
+ Ptr<MgByteReader> fsrdr5 = fssrc5->GetReader();
+ m_svcResource->SetResource(fsres5, fsrdr5, NULL);
+
+ // line sdf file
+ Ptr<MgByteSource> dataSource5 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyLines.sdf", false);
+ Ptr<MgByteReader> dataReader5 = dataSource5->GetReader();
+ m_svcResource->SetResourceData(fsres5, L"UT_SymbologyLines.sdf", L"File", dataReader5);
+
+ // line symbols
+ Ptr<MgResourceIdentifier> sdres3 = new MgResourceIdentifier(L"Library://Symbology/Symbols/LineSymbol.SymbolDefinition");
+ Ptr<MgByteSource> sdsrc3 = new MgByteSource(L"../UnitTestFiles/linesymbol.sd", false);
+ Ptr<MgByteReader> sdrdr3 = sdsrc3->GetReader();
+ m_svcResource->SetResource(sdres3, sdrdr3, NULL);
+
+ Ptr<MgResourceIdentifier> sdres4 = new MgResourceIdentifier(L"Library://Symbology/Symbols/MTYP1500a.SymbolDefinition");
+ Ptr<MgByteSource> sdsrc4 = new MgByteSource(L"../UnitTestFiles/MTYP1500a.sd", false);
+ Ptr<MgByteReader> sdrdr4 = sdsrc4->GetReader();
+ m_svcResource->SetResource(sdres4, sdrdr4, NULL);
+
+ // line ldf
+ Ptr<MgResourceIdentifier> ldfres6 = new MgResourceIdentifier(L"Library://Symbology/Layers/Lines.LayerDefinition");
+ Ptr<MgByteSource> ldfsrc6 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyLines.ldf", false);
+ Ptr<MgByteReader> ldfrdr6 = ldfsrc6->GetReader();
+ m_svcResource->SetResource(ldfres6, ldfrdr6, NULL);
+
+ Ptr<MgResourceIdentifier> ldfres7 = new MgResourceIdentifier(L"Library://Symbology/Layers/LinesCrossTick.LayerDefinition");
+ Ptr<MgByteSource> ldfsrc7 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyLinesCrossTick.ldf", false);
+ Ptr<MgByteReader> ldfrdr7 = ldfsrc7->GetReader();
+ m_svcResource->SetResource(ldfres7, ldfrdr7, NULL);
+
+ // line mdf
+ Ptr<MgResourceIdentifier> mapres4 = new MgResourceIdentifier(L"Library://Symbology/Maps/Lines.MapDefinition");
+ Ptr<MgByteSource> mdfsrc4 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyLines.mdf", false);
+ Ptr<MgByteReader> mdfrdr4 = mdfsrc4->GetReader();
+ m_svcResource->SetResource(mapres4, mdfrdr4, NULL);
+
+ Ptr<MgResourceIdentifier> mapres5 = new MgResourceIdentifier(L"Library://Symbology/Maps/LinesCrossTick.MapDefinition");
+ Ptr<MgByteSource> mdfsrc5 = new MgByteSource(L"../UnitTestFiles/UT_SymbologyLinesCrossTick.mdf", false);
+ Ptr<MgByteReader> mdfrdr5 = mdfsrc5->GetReader();
+ m_svcResource->SetResource(mapres5, mdfrdr5, NULL);
+
+ // symbols / layer definitions for testing MdfModel / MdfParser
+ Ptr<MgResourceIdentifier> sdres5 = new MgResourceIdentifier(L"Library://Symbology/Symbols/MdfTestSimpleSymbol.SymbolDefinition");
+ Ptr<MgByteSource> sdsrc5 = new MgByteSource(L"../UnitTestFiles/MdfTestSimpleSymbol.sd", false);
+ Ptr<MgByteReader> sdrdr5 = sdsrc5->GetReader();
+ m_svcResource->SetResource(sdres5, sdrdr5, NULL);
+
+ Ptr<MgResourceIdentifier> sdres6 = new MgResourceIdentifier(L"Library://Symbology/Symbols/MdfTestCompoundSymbol.SymbolDefinition");
+ Ptr<MgByteSource> sdsrc6 = new MgByteSource(L"../UnitTestFiles/MdfTestCompoundSymbol.sd", false);
+ Ptr<MgByteReader> sdrdr6 = sdsrc6->GetReader();
+ m_svcResource->SetResource(sdres6, sdrdr6, NULL);
+
+ Ptr<MgResourceIdentifier> ldfres8 = new MgResourceIdentifier(L"Library://Symbology/Layers/MdfTestCompTypeStyle.LayerDefinition");
+ Ptr<MgByteSource> ldfsrc8 = new MgByteSource(L"../UnitTestFiles/MdfTestCompTypeStyle.ldf", false);
+ Ptr<MgByteReader> ldfrdr8 = ldfsrc8->GetReader();
+ m_svcResource->SetResource(ldfres8, ldfrdr8, NULL);
}
catch (MgException* e)
{
@@ -201,6 +309,44 @@
Ptr<MgResourceIdentifier> slres1 = new MgResourceIdentifier(L"Library://UnitTests/Symbols/SymbolMart.SymbolLibrary");
m_svcResource->DeleteResource(slres1);
+ // delete symbology stuff
+ Ptr<MgResourceIdentifier> fsres4 = new MgResourceIdentifier(L"Library://Symbology/Data/Capitals.FeatureSource");
+ m_svcResource->DeleteResource(fsres4);
+ Ptr<MgResourceIdentifier> sdres1 = new MgResourceIdentifier(L"Library://Symbology/Symbols/PointSymbol.SymbolDefinition");
+ m_svcResource->DeleteResource(sdres1);
+ Ptr<MgResourceIdentifier> sdres2 = new MgResourceIdentifier(L"Library://Symbology/Symbols/PointSymbolParam.SymbolDefinition");
+ m_svcResource->DeleteResource(sdres2);
+ Ptr<MgResourceIdentifier> ldfres4 = new MgResourceIdentifier(L"Library://Symbology/Layers/Capitals.LayerDefinition");
+ m_svcResource->DeleteResource(ldfres4);
+ Ptr<MgResourceIdentifier> ldfres5 = new MgResourceIdentifier(L"Library://Symbology/Layers/CapitalsParam.LayerDefinition");
+ m_svcResource->DeleteResource(ldfres5);
+ Ptr<MgResourceIdentifier> mapres2 = new MgResourceIdentifier(L"Library://Symbology/Maps/Capitals.MapDefinition");
+ m_svcResource->DeleteResource(mapres2);
+ Ptr<MgResourceIdentifier> mapres3 = new MgResourceIdentifier(L"Library://Symbology/Maps/CapitalsParam.MapDefinition");
+ m_svcResource->DeleteResource(mapres3);
+
+ Ptr<MgResourceIdentifier> fsres5 = new MgResourceIdentifier(L"Library://Symbology/Data/Lines.FeatureSource");
+ m_svcResource->DeleteResource(fsres5);
+ Ptr<MgResourceIdentifier> sdres3 = new MgResourceIdentifier(L"Library://Symbology/Symbols/LineSymbol.SymbolDefinition");
+ m_svcResource->DeleteResource(sdres3);
+ Ptr<MgResourceIdentifier> sdres4 = new MgResourceIdentifier(L"Library://Symbology/Symbols/MTYP1500a.SymbolDefinition");
+ m_svcResource->DeleteResource(sdres4);
+ Ptr<MgResourceIdentifier> ldfres6 = new MgResourceIdentifier(L"Library://Symbology/Layers/Lines.LayerDefinition");
+ m_svcResource->DeleteResource(ldfres6);
+ Ptr<MgResourceIdentifier> ldfres7 = new MgResourceIdentifier(L"Library://Symbology/Layers/LinesCrossTick.LayerDefinition");
+ m_svcResource->DeleteResource(ldfres7);
+ Ptr<MgResourceIdentifier> mapres4 = new MgResourceIdentifier(L"Library://Symbology/Maps/Lines.MapDefinition");
+ m_svcResource->DeleteResource(mapres4);
+ Ptr<MgResourceIdentifier> mapres5 = new MgResourceIdentifier(L"Library://Symbology/Maps/LinesCrossTick.MapDefinition");
+ m_svcResource->DeleteResource(mapres5);
+
+ Ptr<MgResourceIdentifier> sdres5 = new MgResourceIdentifier(L"Library://Symbology/Symbols/MdfTestSimpleSymbol.SymbolDefinition");
+ m_svcResource->DeleteResource(sdres5);
+ Ptr<MgResourceIdentifier> sdres6 = new MgResourceIdentifier(L"Library://Symbology/Symbols/MdfTestCompoundSymbol.SymbolDefinition");
+ m_svcResource->DeleteResource(sdres6);
+ Ptr<MgResourceIdentifier> ldfres8 = new MgResourceIdentifier(L"Library://Symbology/Layers/MdfTestCompTypeStyle.LayerDefinition");
+ m_svcResource->DeleteResource(ldfres8);
+
#ifdef _DEBUG
MgFdoConnectionManager* pFdoConnectionManager = MgFdoConnectionManager::GetInstance();
if(pFdoConnectionManager)
@@ -367,3 +513,319 @@
throw;
}
}
+
+
+void TestRenderingService::TestCase_SymbologyMdfModel()
+{
+ try
+ {
+ MdfParser::SAX2Parser parser;
+
+ // ------------------------------------------------------
+ // process symbol #1 - a simple symbol definition
+ // ------------------------------------------------------
+
+ // create a scope so temp files are unlocked
+ {
+ Ptr<MgResourceIdentifier> sdres = new MgResourceIdentifier(L"Library://Symbology/Symbols/MdfTestSimpleSymbol.SymbolDefinition");
+
+ // parse the symbol - this exercises MdfParser deserialization
+ Ptr<MgByteReader> rdr = m_svcResource->GetResourceContent(sdres);
+ Ptr<MgByteSink> sink = new MgByteSink(rdr);
+ Ptr<MgByte> bytes = sink->ToBuffer();
+ CPPUNIT_ASSERT(bytes->GetLength() > 0);
+
+ parser.ParseString((const char*)bytes->Bytes(), bytes->GetLength());
+ CPPUNIT_ASSERT(parser.GetSucceeded());
+
+ // write the file - this exercises MdfParser serialization
+ auto_ptr<SymbolDefinition> symbolDef1(parser.DetachSymbolDefinition());
+ CPPUNIT_ASSERT(symbolDef1.get() != NULL);
+
+ parser.WriteToFile("../UnitTestFiles/MdfTestSimpleSymbolCopy1.sd", symbolDef1.get());
+ CPPUNIT_ASSERT(MgFileUtil::IsFile(L"../UnitTestFiles/MdfTestSimpleSymbolCopy1.sd"));
+
+ // parse and resave the newly written file
+ Ptr<MgByteSource> src1 = new MgByteSource(L"../UnitTestFiles/MdfTestSimpleSymbolCopy1.sd");
+ Ptr<MgByteReader> rdr1 = src1->GetReader();
+ Ptr<MgByteSink> sink1 = new MgByteSink(rdr1);
+ Ptr<MgByte> bytes1 = sink1->ToBuffer();
+ parser.ParseString((const char*)bytes1->Bytes(), bytes1->GetLength());
+ auto_ptr<SymbolDefinition> symbolDef2(parser.DetachSymbolDefinition());
+ parser.WriteToFile("../UnitTestFiles/MdfTestSimpleSymbolCopy2.sd", symbolDef2.get());
+
+ // compare the two files
+ Ptr<MgByteSource> src2 = new MgByteSource(L"../UnitTestFiles/MdfTestSimpleSymbolCopy2.sd");
+ Ptr<MgByteReader> rdr2 = src2->GetReader();
+ Ptr<MgByteSink> sink2 = new MgByteSink(rdr2);
+ Ptr<MgByte> bytes2 = sink2->ToBuffer();
+ CPPUNIT_ASSERT(bytes1->GetLength() == bytes2->GetLength());
+ CPPUNIT_ASSERT(memcmp(bytes1->Bytes(), bytes2->Bytes(), bytes1->GetLength()) == 0);
+ }
+
+ // delete the files
+ MgFileUtil::DeleteFileW(L"../UnitTestFiles/MdfTestSimpleSymbolCopy1.sd", true);
+ MgFileUtil::DeleteFileW(L"../UnitTestFiles/MdfTestSimpleSymbolCopy2.sd", true);
+
+ // ------------------------------------------------------
+ // process symbol #2 - a compound symbol definition
+ // ------------------------------------------------------
+
+ // create a scope so temp files are unlocked
+ {
+ Ptr<MgResourceIdentifier> sdres = new MgResourceIdentifier(L"Library://Symbology/Symbols/MdfTestCompoundSymbol.SymbolDefinition");
+
+ // parse the symbol - this exercises MdfParser deserialization
+ Ptr<MgByteReader> rdr = m_svcResource->GetResourceContent(sdres);
+ Ptr<MgByteSink> sink = new MgByteSink(rdr);
+ Ptr<MgByte> bytes = sink->ToBuffer();
+ CPPUNIT_ASSERT(bytes->GetLength() > 0);
+
+ parser.ParseString((const char*)bytes->Bytes(), bytes->GetLength());
+ CPPUNIT_ASSERT(parser.GetSucceeded());
+
+ // write the file - this exercises MdfParser serialization
+ auto_ptr<SymbolDefinition> symbolDef1(parser.DetachSymbolDefinition());
+ CPPUNIT_ASSERT(symbolDef1.get() != NULL);
+
+ parser.WriteToFile("../UnitTestFiles/MdfTestCompoundSymbolCopy1.sd", symbolDef1.get());
+ CPPUNIT_ASSERT(MgFileUtil::IsFile(L"../UnitTestFiles/MdfTestCompoundSymbolCopy1.sd"));
+
+ // parse and resave the newly written file
+ Ptr<MgByteSource> src1 = new MgByteSource(L"../UnitTestFiles/MdfTestCompoundSymbolCopy1.sd");
+ Ptr<MgByteReader> rdr1 = src1->GetReader();
+ Ptr<MgByteSink> sink1 = new MgByteSink(rdr1);
+ Ptr<MgByte> bytes1 = sink1->ToBuffer();
+ parser.ParseString((const char*)bytes1->Bytes(), bytes1->GetLength());
+ auto_ptr<SymbolDefinition> symbolDef2(parser.DetachSymbolDefinition());
+ parser.WriteToFile("../UnitTestFiles/MdfTestCompoundSymbolCopy2.sd", symbolDef2.get());
+
+ // compare the two files
+ Ptr<MgByteSource> src2 = new MgByteSource(L"../UnitTestFiles/MdfTestCompoundSymbolCopy2.sd");
+ Ptr<MgByteReader> rdr2 = src2->GetReader();
+ Ptr<MgByteSink> sink2 = new MgByteSink(rdr2);
+ Ptr<MgByte> bytes2 = sink2->ToBuffer();
+ CPPUNIT_ASSERT(bytes1->GetLength() == bytes2->GetLength());
+ CPPUNIT_ASSERT(memcmp(bytes1->Bytes(), bytes2->Bytes(), bytes1->GetLength()) == 0);
+ }
+
+ // delete the files
+ MgFileUtil::DeleteFileW(L"../UnitTestFiles/MdfTestCompoundSymbolCopy1.sd", true);
+ MgFileUtil::DeleteFileW(L"../UnitTestFiles/MdfTestCompoundSymbolCopy2.sd", true);
+
+ // ------------------------------------------------------
+ // process layer definition with composite type style
+ // ------------------------------------------------------
+
+ // create a scope so temp files are unlocked
+ {
+ Ptr<MgResourceIdentifier> ldfres = new MgResourceIdentifier(L"Library://Symbology/Layers/MdfTestCompTypeStyle.LayerDefinition");
+
+ // parse the LDF - this exercises MdfParser deserialization
+ Ptr<MgByteReader> rdr = m_svcResource->GetResourceContent(ldfres);
+ Ptr<MgByteSink> sink = new MgByteSink(rdr);
+ Ptr<MgByte> bytes = sink->ToBuffer();
+ CPPUNIT_ASSERT(bytes->GetLength() > 0);
+
+ parser.ParseString((const char*)bytes->Bytes(), bytes->GetLength());
+ CPPUNIT_ASSERT(parser.GetSucceeded());
+
+ // write the file - this exercises MdfParser serialization
+ auto_ptr<VectorLayerDefinition> layerDef1(parser.DetachVectorLayerDefinition());
+ CPPUNIT_ASSERT(layerDef1.get() != NULL);
+
+ parser.WriteToFile("../UnitTestFiles/MdfTestCompTypeStyleCopy1.ldf", NULL, layerDef1.get(), NULL, NULL);
+ CPPUNIT_ASSERT(MgFileUtil::IsFile(L"../UnitTestFiles/MdfTestCompTypeStyleCopy1.ldf"));
+
+ // parse and resave the newly written file
+ Ptr<MgByteSource> src1 = new MgByteSource(L"../UnitTestFiles/MdfTestCompTypeStyleCopy1.ldf");
+ Ptr<MgByteReader> rdr1 = src1->GetReader();
+ Ptr<MgByteSink> sink1 = new MgByteSink(rdr1);
+ Ptr<MgByte> bytes1 = sink1->ToBuffer();
+ parser.ParseString((const char*)bytes1->Bytes(), bytes1->GetLength());
+ auto_ptr<VectorLayerDefinition> layerDef2(parser.DetachVectorLayerDefinition());
+ parser.WriteToFile("../UnitTestFiles/MdfTestCompTypeStyleCopy2.ldf", NULL, layerDef2.get(), NULL, NULL);
+
+ // compare the two files
+ Ptr<MgByteSource> src2 = new MgByteSource(L"../UnitTestFiles/MdfTestCompTypeStyleCopy2.ldf");
+ Ptr<MgByteReader> rdr2 = src2->GetReader();
+ Ptr<MgByteSink> sink2 = new MgByteSink(rdr2);
+ Ptr<MgByte> bytes2 = sink2->ToBuffer();
+ CPPUNIT_ASSERT(bytes1->GetLength() == bytes2->GetLength());
+ CPPUNIT_ASSERT(memcmp(bytes1->Bytes(), bytes2->Bytes(), bytes1->GetLength()) == 0);
+ }
+
+ // delete the files
+ MgFileUtil::DeleteFileW(L"../UnitTestFiles/MdfTestCompTypeStyleCopy1.ldf", true);
+ MgFileUtil::DeleteFileW(L"../UnitTestFiles/MdfTestCompTypeStyleCopy2.ldf", true);
+ }
+ catch (MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+}
+
+
+void TestRenderingService::TestCase_SymbologyPoints()
+{
+ try
+ {
+ // get root
+ Ptr<MgSiteConnection> conn = new MgSiteConnection();
+
+ // make a runtime map
+ Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://Symbology/Maps/Capitals.MapDefinition");
+ Ptr<MgMap> map = new MgMap();
+ map->Create(m_svcResource, mdfres, L"UnitTestSymbology");
+
+ INT32 pixels = 512;
+
+ Ptr<MgCoordinate> coordNewCenter = new MgCoordinateXY(-88, 48); //about the center of the map
+ Ptr<MgPoint> ptNewCenter = new MgPoint(coordNewCenter);
+ map->SetViewCenter(ptNewCenter);
+ map->SetDisplayDpi(96);
+ map->SetDisplayWidth(pixels*2);
+ map->SetDisplayHeight(pixels);
+
+ // the map is a little silly -- it's in degrees but thinks it's in meters --
+ // hence the 111000 is commented out
+ double mapHeight = 50.0;
+ double scale = mapHeight * /*111000.0 **/ 100.0 / 2.54 * 96.0 / (double)pixels;
+ map->SetViewScale(scale);
+
+ // call the API
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
+
+ rdr->ToFile(L"C:\\SymbologyPoints.png");
+ }
+ catch (MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+}
+
+
+void TestRenderingService::TestCase_SymbologyPointsParam()
+{
+ try
+ {
+ // get root
+ Ptr<MgSiteConnection> conn = new MgSiteConnection();
+
+ // make a runtime map
+ Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://Symbology/Maps/CapitalsParam.MapDefinition");
+ Ptr<MgMap> map = new MgMap();
+ map->Create(m_svcResource, mdfres, L"UnitTestSymbology");
+
+ INT32 pixels = 512;
+
+ Ptr<MgCoordinate> coordNewCenter = new MgCoordinateXY(-88, 48); //about the center of the map
+ Ptr<MgPoint> ptNewCenter = new MgPoint(coordNewCenter);
+ map->SetViewCenter(ptNewCenter);
+ map->SetDisplayDpi(96);
+ map->SetDisplayWidth(pixels*2);
+ map->SetDisplayHeight(pixels);
+
+ // the map is a little silly -- it's in degrees but thinks it's in meters --
+ // hence the 111000 is commented out
+ double mapHeight = 50.0;
+ double scale = mapHeight * /*111000.0 **/ 100.0 / 2.54 * 96.0 / (double)pixels;
+ map->SetViewScale(scale);
+
+ // call the API
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
+
+ rdr->ToFile(L"C:\\SymbologyPointsParam.png");
+ }
+ catch (MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+}
+
+
+void TestRenderingService::TestCase_SymbologyLines()
+{
+ try
+ {
+ // get root
+ Ptr<MgSiteConnection> conn = new MgSiteConnection();
+
+ // make a runtime map
+ Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://Symbology/Maps/Lines.MapDefinition");
+ Ptr<MgMap> map = new MgMap();
+ map->Create(m_svcResource, mdfres, L"UnitTestSymbology");
+
+ INT32 pixels = 512;
+
+ Ptr<MgCoordinate> coordNewCenter = new MgCoordinateXY(6, 4); //about the center of the map
+ Ptr<MgPoint> ptNewCenter = new MgPoint(coordNewCenter);
+ map->SetViewCenter(ptNewCenter);
+ map->SetDisplayDpi(96);
+ map->SetDisplayWidth(2*pixels);
+ map->SetDisplayHeight(pixels);
+
+ // the map is a little silly -- it's in degrees but thinks it's in meters --
+ // hence the 111000 is commented out
+ double mapHeight = 8;
+ double scale = mapHeight /*111000.0 **/ * 100.0 / 2.54 * 96.0 / (double)pixels;
+ map->SetViewScale(scale);
+
+ // call the API
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
+
+ rdr->ToFile(L"C:\\SymbologyLines.png");
+ }
+ catch (MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+}
+
+
+void TestRenderingService::TestCase_SymbologyLinesCrossTick()
+{
+ try
+ {
+ // get root
+ Ptr<MgSiteConnection> conn = new MgSiteConnection();
+
+ // make a runtime map
+ Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://Symbology/Maps/LinesCrossTick.MapDefinition");
+ Ptr<MgMap> map = new MgMap();
+ map->Create(m_svcResource, mdfres, L"UnitTestSymbology");
+
+ INT32 pixels = 512;
+
+ Ptr<MgCoordinate> coordNewCenter = new MgCoordinateXY(6, 4); //about the center of the map
+ Ptr<MgPoint> ptNewCenter = new MgPoint(coordNewCenter);
+ map->SetViewCenter(ptNewCenter);
+ map->SetDisplayDpi(96);
+ map->SetDisplayWidth(2*pixels);
+ map->SetDisplayHeight(pixels);
+
+ double mapHeight = 8;
+ double scale = mapHeight /** 111000.0*/ * 100.0 / 2.54 * 96.0 / (double)pixels;
+
+ map->SetViewScale(scale);
+
+ // call the API
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
+
+ rdr->ToFile(L"C:\\SymbologyLinesCrossTick.png");
+ }
+ catch (MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+}
Modified: trunk/MgDev/Server/src/UnitTesting/TestRenderingService.h
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestRenderingService.h 2007-03-07 00:25:22 UTC (rev 1160)
+++ trunk/MgDev/Server/src/UnitTesting/TestRenderingService.h 2007-03-07 01:05:59 UTC (rev 1161)
@@ -25,6 +25,15 @@
CPPUNIT_TEST_SUITE(TestRenderingService);
CPPUNIT_TEST(TestStart); // This must be the very first unit test
+// TODO - fix these for Linux
+#ifdef WIN32
+ CPPUNIT_TEST(TestCase_SymbologyMdfModel);
+ CPPUNIT_TEST(TestCase_SymbologyPoints);
+ CPPUNIT_TEST(TestCase_SymbologyPointsParam);
+ CPPUNIT_TEST(TestCase_SymbologyLines);
+ CPPUNIT_TEST(TestCase_SymbologyLinesCrossTick);
+#endif
+
CPPUNIT_TEST(TestCase_RenderDynamicOverlay);
CPPUNIT_TEST(TestCase_RenderMap);
CPPUNIT_TEST(TestCase_QueryFeatures);
@@ -45,6 +54,12 @@
void TestCase_RenderMap();
void TestCase_QueryFeatures();
+ void TestCase_SymbologyMdfModel();
+ void TestCase_SymbologyPoints();
+ void TestCase_SymbologyPointsParam();
+ void TestCase_SymbologyLines();
+ void TestCase_SymbologyLinesCrossTick();
+
private:
Ptr<MgResourceService> m_svcResource;
Ptr<MgRenderingService> m_svcRendering;
More information about the mapguide-commits
mailing list