home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 June
/
PCWorld_1998-06_cd.bin
/
software
/
sharware
/
grafika
/
EROICA32
/
_SETUP.3
/
Group2
/
TESTCASE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1998-01-15
|
26KB
|
924 lines
/*-------------------------- Parallax Standard C_File ----------------------------
C_File: testcase.c
Purpose: This file contains the source code for the individual
unit tests for the Eroica unit test program.
--------------------------------------------------------------------------------
Copyright (c)1996 Parallax Software , All rights reserved.
------------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dde_test.h"
#include "utdde.h"
#include "utfile.h"
#define NAMELEN 256
/* ========================================= Parallax C Function ==================
@Name: UT_TestLoad
@Desc:
============================================================================== */
#define MAXDOCLOAD 8
int UT_TestLoad(HCONV ghConv)
{
int ret = TRUE;
int n,i;
DOCWINID docWinID = 0;
char tmpdocname[NAMELEN];
/* list of files to read */
char doclist[MAXDOCLOAD][NAMELEN];
for (n=0; n<MAXDOCLOAD; n++)
{
char tag[15];
wsprintf(tag, "File%d", n+1);
lstrcpy( doclist[n], "" );
GetPrivateProfileString("LoadTest", tag, "", doclist[n], NAMELEN, ".\\dde_test.ini");
}
_MSG("Load Test");
_MSG("=========");
IMG_SetFocus(ghConv);
for (n=0; n<MAXDOCLOAD; n++)
{
if (doclist[n][0] == 0) continue;
UT_GetTmpVersion(doclist[n], tmpdocname);
/* load this doc */
ret = IMG_OpenDocWin(ghConv, 0, TYPE_UNKNOWN, tmpdocname, NULL, 0, 0, 0, &docWinID);
if (!ret) goto cleanup;
/* zoom to fit */
ret = IMG_SetZoom(ghConv, docWinID, ZOOM_FIT, 0, 0, 0);
if (!ret) goto cleanup;
/* zoom way in */
for (i=0; i<3; i++)
{
ret = IMG_SetZoom(ghConv, docWinID, ZOOM_IN, 0, 0, 0);
if (!ret) goto cleanup;
} /* for (i=0; i<3; i++) */
/* scroll corners */
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_CENTER);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_BOTTOMLEFT);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_BOTTOMRIGHT);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_TOPLEFT);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_TOPRIGHT);
if (!ret) goto cleanup;
/* zoom 1:1 */
ret = IMG_SetZoom(ghConv, docWinID, ZOOM_1TO1, 0, 0, 0);
if (!ret) goto cleanup;
/* scroll pages */
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_CENTER);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_UPPAGE);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_LEFTPAGE);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_DOWNPAGE);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_RIGHTPAGE);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_LEFTUPPAGE);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_RIGHTUPPAGE);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_RIGHTDOWNPAGE);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_LEFTDOWNPAGE);
if (!ret) goto cleanup;
/* zoom way out */
for (i=0; i<3; i++)
{
ret = IMG_SetZoom(ghConv, docWinID, ZOOM_OUT, 0, 0, 0);
if (!ret) goto cleanup;
} /* for (i=0; i<3; i++) */
/* zoom to fit */
ret = IMG_SetZoom(ghConv, docWinID, ZOOM_ACTUAL, 0, 0, 0);
if (!ret) goto cleanup;
ret = IMG_SetZoom(ghConv, docWinID, ZOOM_HFIT, 0, 0, 0);
if (!ret) goto cleanup;
ret = IMG_SetZoom(ghConv, docWinID, ZOOM_VFIT, 0, 0, 0);
if (!ret) goto cleanup;
/* zoom 1:1 */
ret = IMG_SetZoom(ghConv, docWinID, ZOOM_1TO1, 0, 0, 0);
if (!ret) goto cleanup;
for (i=0; i<6; i++)
{
/* set the scroll step */
ret = IMG_SetScrollStep(ghConv, docWinID, (float)(i+1)/6);
if (!ret) goto cleanup;
/* scroll steps */
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_CENTER);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_UPSTEP);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_LEFTSTEP);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_DOWNSTEP);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_RIGHTSTEP);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_LEFTUPSTEP);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_RIGHTUPSTEP);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_RIGHTDOWNSTEP);
if (!ret) goto cleanup;
ret = IMG_SetScrollView(ghConv, docWinID, SCROLLVIEW_LEFTDOWNSTEP);
if (!ret) goto cleanup;
} /* for (i=0; i<6; i++) */
/* remove the window */
ret = IMG_CloseDocWin(ghConv, docWinID, FALSE);
if (!ret) goto cleanup;
UT_DeleteFile(tmpdocname);
} /* for (n=0; n<MAXDOCLOAD; n++) */
cleanup:
if (ret)
{
/* delete the temp file */
_MSG("..........SUCCESSFUL");
} else { /* if (ret) ... error occured */
UT_DeleteFile(tmpdocname);
_MSG("..........FAILED");
} /* if (ret) */
return (ret);
} /* UT_TestLoad() */
/* ========================================= Parallax C Function ==================
@Name: UT_TestSave
@Desc:
============================================================================== */
#define MAXDOCSAVE 8
int UT_TestSave(HCONV ghConv)
{
int ret = TRUE;
int count0, count1;
int n;
DOCWINID docWinID = 0;
/* window labels */
char docwinlabel0[NAMELEN];
char docwinlabel1[NAMELEN];
char docsavename[NAMELEN]; /* temporary file name for save */
char doctmplist[MAXDOCSAVE][NAMELEN]; /* temporary file names for read */
/* list of files to read */
char doclist[MAXDOCSAVE][NAMELEN];
for (n=0; n<MAXDOCSAVE; n++)
{
char tag[15];
wsprintf(tag, "File%d", n+1);
lstrcpy( doclist[n], "" );
GetPrivateProfileString("SaveTest", tag, "", doclist[n], NAMELEN, ".\\dde_test.ini");
} /* for (n=0; n<MAXDOCSAVE; n++) */
_MSG("=========");
_MSG("Save Test");
_MSG("=========");
UT_GetTmpFileName(docsavename);
for (n=0; n<MAXDOCSAVE; n++)
{
if (doclist[n][0] == 0) continue;
UT_GetTmpVersion(doclist[n], doctmplist[n]);
if (docWinID == 0)
{
/* load this doc as a document */
ret = IMG_OpenDocWin(ghConv, 0, TYPE_UNKNOWN, doctmplist[n], NULL, 0, 0, 0, &docWinID);
if (!ret) goto cleanup;
} else /* docWinID == 0 */
{
char explayerfile[NAMELEN];
LAYERID layerID;
DOCWINID docWinIDTmp;
/* import this doc as a layer */
ret = IMG_ImportLayer(ghConv, docWinID, doctmplist[n], NULL, TYPE_UNKNOWN, &layerID);
if (!ret) goto cleanup;
/* export this layer to a tmp file */
UT_GetTmpFileName(explayerfile);
ret = IMG_ExportLayer(ghConv, docWinID, layerID, TRUE, explayerfile, NULL, FALSE);
if (!ret) goto cleanup;
UT_Sleep(3);
/* load the file back in */
ret = IMG_OpenDocWin(ghConv, 0, TYPE_UNKNOWN, explayerfile, NULL, 0, 0, 0, &docWinIDTmp);
if (!ret) goto cleanup;
/* destroy this docwin */
ret = IMG_CloseDocWin(ghConv, docWinIDTmp, FALSE);
if (!ret) goto cleanup;
/* delete the tmp file */
UT_DeleteFile(explayerfile);
/* save this layer to a tmp file */
UT_GetTmpFileName(explayerfile);
ret = IMG_SaveLayer(ghConv, docWinID, layerID, TRUE, explayerfile, NULL, TRUE, 1, 0);
if (!ret) goto cleanup;
UT_Sleep(3);
/* load the file back in */
ret = IMG_OpenDocWin(ghConv, 0, TYPE_UNKNOWN, explayerfile, NULL, 0, 0, 0, &docWinIDTmp);
if (!ret) goto cleanup;
/* destroy this docwin */
ret = IMG_CloseDocWin(ghConv, docWinIDTmp, FALSE);
if (!ret) goto cleanup;
/* delete the tmp file */
UT_DeleteFile(explayerfile);
} /* docWinID == 0 */
/* set the document title */
UT_ConstructUniqueLabel(1, docwinlabel0);
ret = IMG_SetDocumentTitle(ghConv, docWinID, docwinlabel0);
if (!ret) goto cleanup;
/* count the layers in this document */
ret = IMG_GetNumberLayers(ghConv, docWinID, &count0);
if (!ret) goto cleanup;
/* save all layers out into a document */
ret = IMG_Save(ghConv, docWinID, TRUE, docsavename, "TEST", TRUE);
if (!ret) goto cleanup;
UT_Sleep(3*(n+1));
/* close all current windows */
ret = IMG_CloseAllDocWin(ghConv, FALSE);
if (!ret) goto cleanup;
/* open the saved file */
ret = IMG_OpenDocWin(ghConv, 0, TYPE_UNKNOWN, docsavename, NULL, 0, 0, 0, &docWinID);
if (!ret) goto cleanup;
/* check that the title was saved with the doc */
ret = IMG_GetDocumentTitle(ghConv, docWinID, docwinlabel1);
if (!ret) goto cleanup;
#if 0
if (strcmp(docwinlabel0, docwinlabel1) != 0)
{
ret = FALSE;
_MSG("Document labels don't match!!!");
goto cleanup;
} /* if (strcmp(docwinlabel0, docwinlabel1) != 0) */
#endif
/* check that all layers are present */
ret = IMG_GetNumberLayers(ghConv, docWinID, &count1);
if (!ret) goto cleanup;
if (count0 != count1)
{
ret = FALSE;
_MSG("Count wrong. Test failed!!!");
goto cleanup;
} /* if (count0 != count1) */
UT_DeleteFile(doctmplist[n]);
} /* for (n=0; n<MAXDOCSAVE; n++) */
cleanup:
/* delete the document file */
UT_DeleteFile(docsavename);
if (ret) {
_MSG("..........SUCCESSFUL");
} else { /* if (ret) */
/* delete all temp copies */
for (n=0; n<MAXDOCSAVE; n++) {
UT_DeleteFile(doctmplist[n]);
} /* for (n=0; n<MAXDOCSAVE; n++) */
_MSG("..........FAILED");
} /* if (ret) */
return (ret);
} /* UT_TestSave() */
/* ========================================= Parallax C Function ==================
@Name: UT_TestMerge
@Desc:
============================================================================== */
#define MAXDOCMERGE 8
int UT_TestMerge(HCONV ghConv)
{
int ret = TRUE;
int n;
int count;
int mergecalls = 0;
DOCWINID docWinID = 0;
DOCWINID mergeID;
LAYERID layerID;
char doctmplist[MAXDOCMERGE][NAMELEN]; /* temporary file names for read */
int layeridlist[MAXDOCSAVE]; /* temporary layer ids to activate */
/* list of files to read */
char doclist[MAXDOCMERGE][NAMELEN];
for (n=0; n<MAXDOCMERGE; n++)
{
char tag[15];
wsprintf(tag, "File%d", n+1);
lstrcpy( doclist[n], "" );
lstrcpy( doctmplist[n], "" );
GetPrivateProfileString("MergeTest", tag, "", doclist[n], NAMELEN, ".\\dde_test.ini");
} /* for (n=0; n<MAXDOCMERGE; n++) */
_MSG("==========");
_MSG("Merge Test");
_MSG("==========");
/* close all docwind to count windows correctly */
ret = IMG_CloseAllDocWin( ghConv, FALSE );
if (!ret) goto cleanup;
count = 0;
for (n=0; n<MAXDOCMERGE; n++)
{
if (doclist[n][0] == 0) continue;
UT_GetTmpVersion(doclist[n], doctmplist[n]);
if (docWinID==0)
{
/* load this doc as a document */
ret = IMG_OpenDocWin(ghConv, 0, TYPE_UNKNOWN, doctmplist[n], NULL, 0, 0, 0, &docWinID);
if (!ret) goto cleanup;
} else /* if (docWinID == 0) */
{
/* import this doc as a layer and save its id */
ret = IMG_ImportLayer(ghConv, docWinID, doctmplist[n], NULL, TYPE_UNKNOWN, layeridlist+n);
if (!ret) goto cleanup;
} /* if (docWinID == 0) */
count++;
} /* for (n=0; n<MAXDOCMERGE; n++) */
/* set the window title */
ret = IMG_SetWindowTitle(ghConv, docWinID, "Original");
if (!ret) goto cleanup;
/* set active raster layer */
ret = IMG_GetActiveRasterLayer(ghConv, docWinID, &layerID);
if (!ret) goto cleanup;
ret = IMG_SetActiveLayer(ghConv, docWinID, layerID, TRUE);
if (!ret) goto cleanup;
/* set active edit layer */
ret = IMG_GetActiveEditLayer(ghConv, docWinID, &layerID);
if (!ret) goto cleanup;
ret = IMG_SetActiveLayer(ghConv, docWinID, layerID, TRUE);
if (!ret) goto cleanup;
/* turn some layers off */
ret = IMG_SetDisplayLayer(ghConv, docWinID, layeridlist[2], FALSE);
if (!ret) goto cleanup;
/* turn some layers off */
ret = IMG_SetDisplayLayer(ghConv, docWinID, layeridlist[4], FALSE);
if (!ret) goto cleanup;
/* merge all layers into a single raster layer */
ret = IMG_Merge(ghConv, docWinID, MERGE_WHOLEDOC, &mergeID);
if (!ret) goto cleanup;
if (mergeID != 0)
{
ret = IMG_SetWindowTitle(ghConv, mergeID, "MERGE WholeDoc (ABCDEFGHabcdefgh)");
if (!ret) goto cleanup;
mergecalls++;
} /* if (mergeID != 0) */
/* merge displayed layers into a single raster layer */
ret = IMG_Merge(ghConv, docWinID, MERGE_DISPLAYEDLAYERS, &mergeID);
if (!ret) goto cleanup;
if (mergeID != 0)
{
ret = IMG_SetWindowTitle(ghConv, mergeID, "MERGE Displayed Layers (AFGDabgh)");
if (!ret) goto cleanup;
mergecalls++;
} /* if (mergeID != 0)*/
/* merge as displayed into a single raster layer */
ret = IMG_Merge(ghConv, docWinID, MERGE_ASDISPLAYED, &mergeID);
if (!ret) goto cleanup;
if (mergeID != 0)
{
ret = IMG_SetWindowTitle(ghConv, mergeID, "MERGE As Displayed (AFGDabgh)");
if (!ret) goto cleanup;
mergecalls++;
} /* if (mergeID != 0) */
/* merge displayed rasters into a single raster layer */
ret = IMG_Merge(ghConv, docWinID, MERGE_DISPLAYEDRASTERS, &mergeID);
if (!ret) goto cleanup;
if (mergeID != 0)
{
ret = IMG_SetWindowTitle(ghConv, mergeID, "MERGE Displayed Rasters (AFGD)");
if (!ret) goto cleanup;
mergecalls++;
} /* if (mergeID != 0) */
/* merge displayed edits into a single raster layer */
ret = IMG_Merge(ghConv, docWinID, MERGE_DISPLAYEDEDITS, &mergeID);
if (!ret) goto cleanup;
if (mergeID != 0)
{
ret = IMG_SetWindowTitle(ghConv, mergeID, "MERGE displayed edits (abgh)");
if (!ret) goto cleanup;
mergecalls++;
} /* if (mergeID != 0) */
/* merge active raster into a single raster layer - activate raster */
ret = IMG_SetActiveLayer(ghConv, docWinID, layeridlist[1], TRUE);
if (!ret) goto cleanup;
ret = IMG_Merge(ghConv, docWinID, MERGE_ACTIVERASTER, &mergeID);
if (!ret) goto cleanup;
if (mergeID != 0)
{
ret = IMG_SetWindowTitle(ghConv, mergeID, "MERGE Active Raster (F)");
if (!ret) goto cleanup;
mergecalls++;
} /* if (mergeID != 0) */
/* merge active edit into a single raster layer - activate edit */
ret = IMG_SetActiveLayer(ghConv, docWinID, layeridlist[3], TRUE);
if (!ret) goto cleanup;
ret = IMG_Merge(ghConv, docWinID, MERGE_ACTIVEEDIT, &mergeID);
if (!ret) goto cleanup;
if (mergeID != 0)
{
ret = IMG_SetWindowTitle(ghConv, mergeID, "MERGE Active Edit (g)");
if (!ret) goto cleanup;
mergecalls++;
} /* if (mergeID != 0) */
/* set active raster layer off */
ret = IMG_GetActiveRasterLayer(ghConv, docWinID, &layerID);
if (!ret) goto cleanup;
ret = IMG_SetActiveLayer(ghConv, docWinID, layerID, FALSE);
if (!ret) goto cleanup;
ret = IMG_GetActiveRasterLayer(ghConv, docWinID, &layerID);
if (!ret) goto cleanup;
if (layerID != 0)
{
ret = FALSE;
_MSG("Could not reset active raster layer.");
goto cleanup;
} /* if (mergeID != 0) */
/* set active edit layer off */
ret = IMG_GetActiveEditLayer(ghConv, docWinID, &layerID);
if (!ret) goto cleanup;
ret = IMG_SetActiveLayer(ghConv, docWinID, layerID, FALSE);
if (!ret) goto cleanup;
ret = IMG_GetActiveEditLayer(ghConv, docWinID, &layerID);
if (!ret) goto cleanup;
if (layerID != 0)
{
ret = FALSE;
_MSG("Could not reset active edit layer.");
goto cleanup;
} /* if (mergeID != 0) */
/* check the number of docwins */
ret = IMG_GetNumberDocWins(ghConv, &count);
if (!ret) goto cleanup;
if (count != mergecalls+1)
{
ret = FALSE;
_MSG("Docwin count failed.");
goto cleanup;
} /* if (mergeID != 0) */
cleanup:
IMG_ArrangeDocWins(ghConv, ARRANGE_TILE);
for (n=0; n<MAXDOCSAVE; n++)
{
UT_DeleteFile(doctmplist[n]);
} /* for (n=0; n<MAXDOCSAVE; n++) */
if (ret)
{
/* delete all temp copies */
_MSG("..........SUCCESSFUL");
} else { /* if (ret) */
_MSG("..........FAILED");
} /* if (ret) */
return (ret);
} /* UT_TestMerge() */
/* ========================================= Parallax C Function ==================
@Name: UT_TestDisplayLayer
@Desc:
============================================================================== */
int UT_TestDisplayLayer(HCONV ghConv)
{
int ret = TRUE;
int i,count;
BOOL bDisp;
LAYERID list[20];
DOCWINID docWinID;
char docname[NAMELEN];
char tmpdocname[NAMELEN] = "";
_MSG("==================");
_MSG("Display Layer Test");
_MSG("==================");
lstrcpy( docname, "" );
GetPrivateProfileString("DisplayTest", "8LayerCLF", "", docname, NAMELEN, ".\\dde_test.ini");
UT_GetTmpVersion(docname, tmpdocname);
ret = IMG_OpenDocWin(ghConv, 0, TYPE_UNKNOWN, tmpdocname, NULL, 0, 0, 0, &docWinID);
if (!ret) goto cleanup;
ret = IMG_GetLayerIDs(ghConv, docWinID, list, 20, &count);
if (!ret) goto cleanup;
for (i=0; i<count; i++)
{
ret = IMG_GetDisplayLayer(ghConv, docWinID, list[i], &bDisp);
if (!ret) goto cleanup;
if (bDisp != TRUE)
{
_MSG("Loaded layer should be displayed.");
ret = FALSE;
goto cleanup;
} /* if (bDisp != TRUE) */
ret = IMG_SetDisplayLayer(ghConv, docWinID, list[i], FALSE);
if (!ret) goto cleanup;
UT_Sleep(1);
} /* for (i=0; i<count; i++) */
for (i=0; i<count; i++)
{
ret = IMG_GetDisplayLayer(ghConv, docWinID, list[i], &bDisp);
if (!ret) goto cleanup;
if (bDisp != FALSE)
{
_MSG("Loaded layer should NOT be displayed.");
ret = FALSE;
goto cleanup;
}
ret = IMG_SetDisplayLayer(ghConv, docWinID, list[i], TRUE);
if (!ret) goto cleanup;
UT_Sleep(1);
} /* for (i=0; i<count; i++) */
/* remove the window */
ret = IMG_CloseDocWin(ghConv, docWinID, FALSE);
if (!ret) goto cleanup;
cleanup:
UT_DeleteFile(tmpdocname);
if (ret) {
_MSG("..........SUCCESSFUL");
} else /* if (ret) */
{
_MSG("..........FAILED");
} /* if (ret) */
return (ret);
} /* UT_TestDisplayLayer() */
/* ========================================= Parallax C Function ==================
@Name: UT_TestToolSet
@Desc:
============================================================================== */
int UT_TestToolSet(HCONV ghConv)
{
int ret = FALSE;
DOCWINID docWinID;
LAYERID layerID;
char pTmpName[256];
int tool, maxtoolset;
int i,j;
int toolIDs[] = {
TOOL_NONE ,
TOOL_CUT ,
TOOL_COPY ,
/* TOOL_PASTE , */
TOOL_LINE ,
TOOL_BOX ,
TOOL_CIRCLE ,
TOOL_ELLIPSE ,
TOOL_ARROW ,
TOOL_SKETCH ,
TOOL_POLYLINE ,
TOOL_POLYGON ,
TOOL_TEXT ,
TOOL_ANNOTATION ,
TOOL_DIMENSION ,
/* TOOL_SYMBOL , */
TOOL_HOTSPOT ,
TOOL_RUBOUT ,
TOOL_ERASER ,
TOOL_SELECT ,
/* TOOL_CHANGETEXT , */
/* TOOL_ARC , */
/* TOOL_MOVERESIZE , */
/* TOOL_ROTATE */ };
_MSG("=============");
_MSG("Tool Set Test");
_MSG("=============");
maxtoolset = sizeof(toolIDs)/sizeof(toolIDs[0]);
/* create blank document */
UT_GetTmpFileName(pTmpName);
ret = IMG_NewDocument(ghConv, "Tool Test A", pTmpName, &docWinID);
if (!ret) goto cleanup;
/* get rid of this one */
ret = IMG_CloseDocWin(ghConv, docWinID, FALSE);
if (!ret) goto cleanup;
/* create blank document */
ret = IMG_CreateDocWin(ghConv, "Tool Test B", &docWinID);
if (!ret) goto cleanup;
/* create edit layer on blank doc */
ret = IMG_NewLayer(ghConv, docWinID, ETYPE_FULLEDIT, &layerID);
if (!ret) goto cleanup;
/* make the edit layer active */
ret = IMG_SetActiveLayer(ghConv, docWinID, layerID, 1);
if (!ret) goto cleanup;
/* loop through all combinations */
for (i=1; i<maxtoolset-1; i++)
{
_FMTMSG2("===Stage %d of %d.", i+1, maxtoolset-1);
for (j=i; j<maxtoolset; j++)
{
ret = IMG_SetTool(ghConv, docWinID, toolIDs[i]);
if (!ret) goto cleanup;
ret = IMG_GetTool(ghConv, docWinID, &tool);
if (!ret) goto cleanup;
if (tool != toolIDs[i])
{
_MSG("Tool setting failed!!!");
ret = FALSE;
goto cleanup;
} /* if (tool != toolIDs[i]) */
ret = IMG_SetTool(ghConv, docWinID, toolIDs[j]);
if (!ret) goto cleanup;
ret = IMG_GetTool(ghConv, docWinID, &tool);
if (!ret) goto cleanup;
if (tool != toolIDs[j])
{
ret = FALSE;
_MSG("Tool setting failed!!!");
goto cleanup;
} /* if (tool != toolIDs[j]) */
} /* for (j=i; j<maxtoolset; j++) */
} /* for (i=1; i<maxtoolset-1; i++) */
cleanup:
if (ret)
{
IMG_CloseDocWin(ghConv, docWinID, FALSE);
_MSG("..........SUCCESSFUL");
} else { /* if (ret) */
_MSG("..........FAILED");
} /* if (ret) */
return (ret);
} /* UT_TestToolSet() */
/* ========================================= Parallax C Function ==================
@Name: UT_TestDeskew
@Desc:
============================================================================== */
int UT_TestDeskew(HCONV ghConv)
{
DOCWINID docWinID;
int i;
int ret = TRUE;
int mod = 10;
float start_angle = (float)0.0;
float end_angle = (float)90.0;
float angle = (float)1.0;
char doc[NAMELEN + 1] = "";
char sangle[5] = "";
char eangle[5] = "";
char tangle[5] = "";
char ptr[5];
char ptr2[5];
char ptr3[5];
char ptr4[5];
int num_iters = 0;
double max_angle;
char tmpdocname[NAMELEN] = "";
IMG_SetShowStatusDialogs(ghConv, 0);
GetPrivateProfileString("DeskewTest", "File", "", doc, NAMELEN, ".\\dde_test.ini");
GetPrivateProfileString("DeskewTest", "Start Angle", "", sangle, 5, ".\\dde_test.ini");
GetPrivateProfileString("DeskewTest", "End Angle", "", eangle, 5, ".\\dde_test.ini");
GetPrivateProfileString("DeskewTest", "Angle", "", tangle, 5, ".\\dde_test.ini");
mod = GetPrivateProfileInt("DeskewTest", "Keep", 10, ".\\dde_test.ini");
if (lstrlen(sangle)) start_angle = img_ATOF(sangle);
if (lstrlen(eangle)) end_angle = img_ATOF(eangle);
if (lstrlen(tangle)) angle = img_ATOF(tangle);
if (lstrlen(doc))
{
UT_GetTmpVersion(doc, tmpdocname);
ret = IMG_OpenDocWin(ghConv, 0, TYPE_UNKNOWN, tmpdocname, NULL, 0, 0, 0, &docWinID);
if (!ret) goto cleanup;
gcvt((double)start_angle, 5, ptr);
gcvt((double)end_angle, 5, ptr2);
gcvt((double)angle, 5, ptr3);
/* N.B. the following function is ONLY applicable to Eroica 3.6 and */
/* above */
ret = IMG_GetDeskewLimit(ghConv, docWinID, 0, &max_angle);
if (!ret) goto cleanup;
if (!max_angle) max_angle = 2.0;
if (max_angle >= angle)
{
_FMTMSG4("Deskewing %s from %s to %s", doc, ptr, ptr2, ptr3);
num_iters = (int)((end_angle - start_angle) / angle) + 1;
for (i=0; i < num_iters; i++)
{
_FMTMSG2("Deskewing %d of %d", i + 1, num_iters);
ret = IMG_Deskew(ghConv, (HWND)docWinID, angle);
if (!ret) goto cleanup;
if (i % mod)
{
ret = IMG_CloseDocWin(ghConv, docWinID, FALSE);
if (!ret) goto cleanup;
} /* if (i % mod) */
ret = IMG_GetDocWin(ghConv, &docWinID);
if (!ret) goto cleanup;
} /* for (i=0; i < num_iters; i++) */
if (!GetPrivateProfileInt("DeskewTest", "Keep Last", 0, ".\\dde_test.ini")) {
IMG_CloseDocWin(ghConv, docWinID, FALSE);
}
/*
ret = IMG_CloseAllDocWin(ghConv, FALSE);
if (!ret) goto cleanup;
*/
} else {/* if (max_angle >= angle) */
gcvt((double)max_angle, 5, ptr4);
_FMTMSG2("Deskew Angle of %s greater than maximum angle %s.", ptr3, ptr4);
} /* if (max_angle >= angle) */
} /* if (lstrlen(doc)) */
cleanup:
UT_DeleteFile(tmpdocname);
if (ret)
{
_MSG("..........SUCCESSFUL");
} else /* if (ret) */
{
_MSG("..........FAILED");
} /* if (ret) */
return (ret);
} /* UT_TestDeskew() */
/* TESTCASE.C */
/* end of file */