00001 #include <gtest/gtest.h>
00002 #include "tptoolbox.h"
00003
00004 #if defined MSWIN
00005 #pragma warning(disable: 4800)
00006 #pragma warning(disable: 4996)
00007 #endif
00008
00009
00010
00011
00012
00013 class MockManager
00014 {
00015 public:
00016 static bool startup()
00017 {
00018 int argc = 5;
00019 char* tecSdkHomeEnv = getenv("TECSDKHOME");
00020 assert(tecSdkHomeEnv != NULL);
00021 char* argv[5] = {(char*)"some path",
00022 (char*)"-h",
00023 tecSdkHomeEnv,
00024 (char*)"-nostdaddons",
00025 (char*)"-quiet"};
00026
00027
00028
00029 TecEngInitReturnCode_e ret;
00030 if (tecSdkHomeEnv != NULL)
00031 {
00032 ret = TecEngInit(argc, argv, "Tecplot 112 NONE 0 4200723358", StateModernizationLevel_2006);
00033 assert(ret == TecEngInitReturnCode_Ok);
00034 }
00035 else
00036 ret = TecEngInitReturnCode_InternalInitializationError;
00037
00038 if (ret == TecEngInitReturnCode_Ok)
00039 {
00040 installCallbacks();
00041 if (!TecEngStartup())
00042 ret = TecEngInitReturnCode_InternalInitializationError;
00043 }
00044
00045
00046 return ret == TecEngInitReturnCode_Ok;
00047 }
00048 static bool shutdown()
00049 {
00050 TecEngInitiateShutdown(TRUE);
00051 TecEngFinalizeShutdown();
00052 return true;
00053 }
00054 private:
00055 static Boolean_t staticPageCreateCallback(StringList_pa PageConstructionHints,
00056 ArbParam_t RegistrationClientData)
00057 {
00058 return TecEngPageCreateNew((ArbParam_t)1, PageConstructionHints);
00059 }
00060 static void staticPageDestroyCallback(ArbParam_t PageClientData,
00061 ArbParam_t RegistrationClientData)
00062 {
00063 }
00064 static void staticPageNewCurrentCallback(ArbParam_t PageClientData,
00065 ArbParam_t RegistrationClientData)
00066 {
00067 }
00068 static Boolean_t staticRenderQueryCallback(ArbParam_t PageClientData,
00069 ArbParam_t RegistrationClientData)
00070 {
00071 return FALSE;
00072 }
00073 static Boolean_t staticRenderDestCallback(PageRenderDest_e RenderDest,
00074 ArbParam_t PageClientData,
00075 ArbParam_t RegistrationClientData)
00076 {
00077 return FALSE;
00078 }
00079
00080
00081 static void staticScreenSizeCallback(ArbParam_t RegistrationClientData,
00082 int *WidthInPixels,
00083 int *HeightInPixels)
00084 {
00085 *WidthInPixels = 1024;
00086 *HeightInPixels = 768;
00087 }
00088
00089 static void staticRenderDestSizeCallback(ArbParam_t PageClientData,
00090 ArbParam_t RegistrationClientData,
00091 LgIndex_t * Width,
00092 LgIndex_t * Height)
00093 {
00094 *Width = 50;
00095 *Height = 50;
00096 }
00097 static void staticDotPitchCallback(ArbParam_t RegistrationClientData,
00098 double *IDotsPerCm,
00099 double *JDotsPerCm)
00100 {
00101 *IDotsPerCm = 50;
00102 *JDotsPerCm = 50;
00103 }
00104 static void staticSwapBuffersCallback(ArbParam_t RegistrationClientData)
00105 {
00106 }
00107
00108 static void staticKeyStateCallback(ArbParam_t ClientData,
00109 Boolean_t *IsShiftKeyDown,
00110 Boolean_t *IsAltKeyDown,
00111 Boolean_t *IsCntrlKeyDown)
00112 {
00113 *IsShiftKeyDown = FALSE;
00114 *IsAltKeyDown = FALSE;
00115 *IsCntrlKeyDown = FALSE;
00116 }
00117 static Boolean_t staticMouseButtonStateCallback(int button,
00118 ArbParam_t ClientData)
00119 {
00120 return FALSE;
00121 }
00122 static void staticProcessBusyEventsCallback(ArbParam_t RegistrationClientData)
00123 {
00124 }
00125 static void installCallbacks()
00126 {
00127
00128 TecEngPageCreateRegisterCallback(staticPageCreateCallback, 0);
00129
00130
00131
00132 TecEngRenderQueryRegisterCallback(staticRenderQueryCallback, 0);
00133 TecEngRenderDestRegisterCallback(staticRenderDestCallback, 0);
00134 TecEngRenderDestSizeRegisterCallback(staticRenderDestSizeCallback, 0);
00135 TecEngScreenSizeRegisterCallback(staticScreenSizeCallback, 0);
00136 TecEngDotPitchRegisterCallback(staticDotPitchCallback, 0);
00137 TecEngSwapBuffersRegisterCallback(staticSwapBuffersCallback, 0);
00138 TecEngKeyStateRegisterCallback(staticKeyStateCallback, 0);
00139 TecEngMouseButtonStateRegisterCallback(staticMouseButtonStateCallback, 0);
00140 TecEngProcessBusyEventsRegisterCallback(staticProcessBusyEventsCallback, 0);
00141 }
00142 };
00143
00144
00145 class GlobalSetup : public testing::Environment
00146 {
00147 public:
00148 virtual void SetUp()
00149 {
00150 MockManager::startup();
00151 }
00152 virtual void TearDown()
00153 {
00154 MockManager::shutdown();
00155 }
00156 };