From e045d212d35354d679c2d2e05c6d4689f9f8ac95 Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Mon, 27 Sep 2010 22:56:08 -0400 Subject: STORM-1126 WIP Windlight Estate Settings port from 1.23: first pass at merging in windlight estate settings to viewer-dev codebase. not built, not tested. Probably needs a bunch of fixes to be able to be integrated. (resubmitted by Vadim ProductEngine) --- indra/newview/tests/lldir_stub.cpp | 45 ++++ indra/newview/tests/llfloaterdaycycle_stub.cpp | 20 ++ indra/newview/tests/llfloaterenvsettings_stub.cpp | 20 ++ indra/newview/tests/llfloaterwindlight_stub.cpp | 20 ++ indra/newview/tests/llglslshader_stub.cpp | 22 ++ indra/newview/tests/llpipeline_stub.cpp | 15 ++ indra/newview/tests/llsky_stub.cpp | 20 ++ indra/newview/tests/llviewershadermgr_stub.cpp | 33 +++ indra/newview/tests/llwlanimator_stub.cpp | 12 + indra/newview/tests/llwldaycycle_stub.cpp | 35 +++ indra/newview/tests/llwlparammanager_test.cpp | 257 ++++++++++++++++++++++ indra/newview/tests/llwlparamset_stub.cpp | 24 ++ 12 files changed, 523 insertions(+) create mode 100644 indra/newview/tests/lldir_stub.cpp create mode 100644 indra/newview/tests/llfloaterdaycycle_stub.cpp create mode 100644 indra/newview/tests/llfloaterenvsettings_stub.cpp create mode 100644 indra/newview/tests/llfloaterwindlight_stub.cpp create mode 100644 indra/newview/tests/llglslshader_stub.cpp create mode 100644 indra/newview/tests/llpipeline_stub.cpp create mode 100644 indra/newview/tests/llsky_stub.cpp create mode 100644 indra/newview/tests/llviewershadermgr_stub.cpp create mode 100644 indra/newview/tests/llwlanimator_stub.cpp create mode 100644 indra/newview/tests/llwldaycycle_stub.cpp create mode 100644 indra/newview/tests/llwlparammanager_test.cpp create mode 100644 indra/newview/tests/llwlparamset_stub.cpp (limited to 'indra/newview/tests') diff --git a/indra/newview/tests/lldir_stub.cpp b/indra/newview/tests/lldir_stub.cpp new file mode 100644 index 0000000000..6646860b5e --- /dev/null +++ b/indra/newview/tests/lldir_stub.cpp @@ -0,0 +1,45 @@ +/** + * @file lldir_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Use me only if you need to stub out some helper functions, not if you e.g. need sane numbers from countFilesInDir + +LLDir::LLDir() {} +LLDir::~LLDir() {} +BOOL LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask) { return true; } +void LLDir::setChatLogsDir(const std::string &path) {} +void LLDir::setPerAccountChatLogsDir(const std::string &first, const std::string &last) {} +void LLDir::setLindenUserDir(const std::string &first, const std::string &last) {} +void LLDir::setSkinFolder(const std::string &skin_folder) {} +bool LLDir::setCacheDir(const std::string &path) { return true; } +void LLDir::dumpCurrentDirectories() {} + +class LLDir_stub : public LLDir +{ +public: + LLDir_stub() {} + ~LLDir_stub() {} + + /*virtual*/ void initAppDirs(const std::string &app_name) {} + + /*virtual*/ std::string getCurPath() { return "CUR_PATH_FROM_LLDIR"; } + /*virtual*/ U32 countFilesInDir(const std::string &dirname, const std::string &mask) { return 42; } + /*virtual*/ BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap) { fname = fname + "_NEXT"; return false; } + /*virtual*/ void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) { fname = "RANDOM_FILE"; } + /*virtual*/ BOOL fileExists(const std::string &filename) const { return false; } +}; + +LLDir_stub gDirUtil; + +LLDir* gDirUtilp = &gDirUtil; + +std::string LLDir::getExpandedFilename(ELLPath loc, const std::string& subdir, const std::string& filename) const +{ + return subdir + " --- " + filename + " --- expanded!"; +} + diff --git a/indra/newview/tests/llfloaterdaycycle_stub.cpp b/indra/newview/tests/llfloaterdaycycle_stub.cpp new file mode 100644 index 0000000000..e6b145bcfc --- /dev/null +++ b/indra/newview/tests/llfloaterdaycycle_stub.cpp @@ -0,0 +1,20 @@ +/** + * @file llfloaterdaycycle_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +class LLFloaterDayCycle +{ +public: + static bool isOpen(void); + static LLFloaterDayCycle* instance(void); + static void syncMenu(void); +}; + +bool LLFloaterDayCycle::isOpen() { return true; } +LLFloaterDayCycle* LLFloaterDayCycle::instance() { return NULL; } +void LLFloaterDayCycle::syncMenu(void) {} diff --git a/indra/newview/tests/llfloaterenvsettings_stub.cpp b/indra/newview/tests/llfloaterenvsettings_stub.cpp new file mode 100644 index 0000000000..e9e792521f --- /dev/null +++ b/indra/newview/tests/llfloaterenvsettings_stub.cpp @@ -0,0 +1,20 @@ +/** + * @file llfloaterenvsettings_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +class LLFloaterEnvSettings +{ +public: + static bool isOpen(void); + static LLFloaterEnvSettings* instance(void); + void syncMenu(void); +}; + +bool LLFloaterEnvSettings::isOpen() { return true; } +LLFloaterEnvSettings* LLFloaterEnvSettings::instance() { return NULL; } +void LLFloaterEnvSettings::syncMenu(void) {} diff --git a/indra/newview/tests/llfloaterwindlight_stub.cpp b/indra/newview/tests/llfloaterwindlight_stub.cpp new file mode 100644 index 0000000000..f1891eaf21 --- /dev/null +++ b/indra/newview/tests/llfloaterwindlight_stub.cpp @@ -0,0 +1,20 @@ +/** + * @file llfloaterwindlight_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +class LLFloaterWindLight +{ +public: + static bool isOpen(void); + static LLFloaterWindLight* instance(void); + void syncMenu(void); +}; + +bool LLFloaterWindLight::isOpen() { return true; } +LLFloaterWindLight* LLFloaterWindLight::instance() { return NULL; } +void LLFloaterWindLight::syncMenu(void) {} diff --git a/indra/newview/tests/llglslshader_stub.cpp b/indra/newview/tests/llglslshader_stub.cpp new file mode 100644 index 0000000000..5333c8a361 --- /dev/null +++ b/indra/newview/tests/llglslshader_stub.cpp @@ -0,0 +1,22 @@ +/** + * @file llglslshader_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#include "llglslshader.h" + +void LLGLSLShader::uniform1f(const std::string& uniform, F32 num) +{ +} + +void LLGLSLShader::uniform3fv(const std::string& uniform, U32 count, const GLfloat *v) +{ +} + +void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v) +{ +} diff --git a/indra/newview/tests/llpipeline_stub.cpp b/indra/newview/tests/llpipeline_stub.cpp new file mode 100644 index 0000000000..85bf0ae3fb --- /dev/null +++ b/indra/newview/tests/llpipeline_stub.cpp @@ -0,0 +1,15 @@ +/** + * @file llpipeline_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +class LLPipeline +{ +public: BOOL canUseWindLightShaders() const; +}; +BOOL LLPipeline::canUseWindLightShaders() const {return TRUE;} +LLPipeline gPipeline; diff --git a/indra/newview/tests/llsky_stub.cpp b/indra/newview/tests/llsky_stub.cpp new file mode 100644 index 0000000000..35f4944a95 --- /dev/null +++ b/indra/newview/tests/llsky_stub.cpp @@ -0,0 +1,20 @@ +/** + * @file llsky_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +class LLSky +{ +public: + void setOverrideSun(BOOL override); + void setSunDirection(const LLVector3 &sun_direction, const LLVector3 &sun_ang_velocity); +}; + +void LLSky::setOverrideSun(BOOL override) {} +void LLSky::setSunDirection(const LLVector3 &sun_direction, const LLVector3 &sun_ang_velocity) {} + +LLSky gSky; diff --git a/indra/newview/tests/llviewershadermgr_stub.cpp b/indra/newview/tests/llviewershadermgr_stub.cpp new file mode 100644 index 0000000000..0dae527035 --- /dev/null +++ b/indra/newview/tests/llviewershadermgr_stub.cpp @@ -0,0 +1,33 @@ +/** + * @file llglslshader_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#include "../llviewershadermgr.h" + +LLShaderMgr::LLShaderMgr() {} +LLShaderMgr::~LLShaderMgr() {} + +LLViewerShaderMgr::LLViewerShaderMgr() {} +LLViewerShaderMgr::~LLViewerShaderMgr() {} + +LLViewerShaderMgr* stub_instance = NULL; + +LLViewerShaderMgr* LLViewerShaderMgr::instance() { + if(NULL == stub_instance) + { + stub_instance = new LLViewerShaderMgr(); + } + + return stub_instance; +} +LLViewerShaderMgr::shader_iter fake_iter; +LLViewerShaderMgr::shader_iter LLViewerShaderMgr::beginShaders() const {return fake_iter;} +LLViewerShaderMgr::shader_iter LLViewerShaderMgr::endShaders() const {return fake_iter;} + +void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader* shader) {return;} +std::string LLViewerShaderMgr::getShaderDirPrefix() {return "SHADER_DIR_PREFIX-";} diff --git a/indra/newview/tests/llwlanimator_stub.cpp b/indra/newview/tests/llwlanimator_stub.cpp new file mode 100644 index 0000000000..4d1bb85544 --- /dev/null +++ b/indra/newview/tests/llwlanimator_stub.cpp @@ -0,0 +1,12 @@ +/** + * @file llwlanimator_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +LLWLAnimator::LLWLAnimator(void) {} +void LLWLAnimator::update(LLWLParamSet& set) {} +void LLWLAnimator::setTrack(std::map& track, F32 dayRate, F64 dayTime, bool run) {} diff --git a/indra/newview/tests/llwldaycycle_stub.cpp b/indra/newview/tests/llwldaycycle_stub.cpp new file mode 100644 index 0000000000..d98c9614b4 --- /dev/null +++ b/indra/newview/tests/llwldaycycle_stub.cpp @@ -0,0 +1,35 @@ +/** + * @file llwldaycycle_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +LLWLDayCycle::LLWLDayCycle(void) +{ +} + +LLWLDayCycle::~LLWLDayCycle(void) +{ +} + +bool LLWLDayCycle::getKeytime(LLWLParamKey keyFrame, F32& keyTime) +{ + keyTime = 0.5; + return true; +} + +bool LLWLDayCycle::removeKeyframe(F32 time) +{ + return true; +} + +void LLWLDayCycle::loadDayCycleFromFile(const std::string& fileName) +{ +} + +void LLWLDayCycle::removeReferencesTo(const LLWLParamKey &keyframe) +{ +} diff --git a/indra/newview/tests/llwlparammanager_test.cpp b/indra/newview/tests/llwlparammanager_test.cpp new file mode 100644 index 0000000000..3d31567335 --- /dev/null +++ b/indra/newview/tests/llwlparammanager_test.cpp @@ -0,0 +1,257 @@ +/** + * @file llwlparammanager_test.cpp + * @brief LLWLParamManager tests + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled headers +#include "../llviewerprecompiledheaders.h" + +// Class to test +#include "../llwlparammanager.h" + +// Dependencies +#include "linden_common.h" + +// TUT header +#include "lltut.h" + +// Stubs +#include "llwldaycycle_stub.cpp" +#include "llwlparamset_stub.cpp" +#include "llwlanimator_stub.cpp" +#include "llglslshader_stub.cpp" +#include "lldir_stub.cpp" +#include "llsky_stub.cpp" +#include "llfloaterdaycycle_stub.cpp" +#include "llfloaterenvsettings_stub.cpp" +#include "llfloaterwindlight_stub.cpp" +#include "llpipeline_stub.cpp" +#include "llviewershadermgr_stub.cpp" + +void assert_glerror(void) {} +LLViewerCamera::LLViewerCamera() {} +void LLViewerCamera::setView(F32 vertical_fov_rads) {} +std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args) { return std::string(""); } + +char* curl_unescape(const char* c_str, int length) +{ + char* copy = new char[length+4]; + memcpy(copy, c_str, length); + copy[length+0] = 'E'; + copy[length+1] = 'S'; + copy[length+2] = 'C'; + copy[length+3] = '\0'; + return copy; +} +void curl_free(void* p) {delete[] ((char*)p);} +char* curl_escape(const char* c_str, int length) { + char* copy = new char[length+6]; + memcpy(copy, c_str, length); + copy[length+0] = 'U'; + copy[length+1] = 'N'; + copy[length+2] = 'E'; + copy[length+3] = 'S'; + copy[length+4] = 'C'; + copy[length+5] = '\0'; + return copy; +} + +namespace tut +{ + // Main Setup + struct LLWLParamManagerFixture + { + class LLWLParamManagerTest + { + }; + + LLWLParamManager* mTestManager; + + LLWLParamManagerFixture() + : mTestManager(LLWLParamManager::getInstance()) + { + } + + ~LLWLParamManagerFixture() + { + } + }; + typedef test_group factory; + typedef factory::object object; + factory tf("LLWLParamManager test"); + + // Tests + template<> template<> + void object::test<1>() + { + try + { + std::string preset = + "\ + \ + ambient\ + \ + 1.0499999523162842\ + 1.0499999523162842\ + 1.0499999523162842\ + 0.34999999403953552\ + \ + blue_density\ + \ + 0.2447581488182351\ + 0.44872328639030457\ + 0.75999999046325684\ + 0.38000004053115788\ + \ + blue_horizon\ + \ + 0.49548382097675159\ + 0.49548381382419748\ + 0.63999999284744291\ + 0.31999999642372146\ + \ + cloud_color\ + \ + 0.40999999165535073\ + 0.40999999165535073\ + 0.40999999165535073\ + 0.40999999165535073\ + \ + cloud_pos_density1\ + \ + 1.6884100437164307\ + 0.52609699964523315\ + 0.99999999999999289\ + 1\ + \ + cloud_pos_density2\ + \ + 1.6884100437164307\ + 0.52609699964523315\ + 0.125\ + 1\ + \ + cloud_scale\ + \ + 0.4199999868869746\ + 0\ + 0\ + 1\ + \ + cloud_scroll_rate\ + \ + 10.199999809265137\ + 10.01099967956543\ + \ + cloud_shadow\ + \ + 0.26999998092651367\ + 0\ + 0\ + 1\ + \ + density_multiplier\ + \ + 0.00017999998817685818\ + 0\ + 0\ + 1\ + \ + distance_multiplier\ + \ + 0.80000001192093606\ + 0\ + 0\ + 1\ + \ + east_angle\ + 0\ + enable_cloud_scroll\ + \ + 1\ + 1\ + \ + gamma\ + \ + 1\ + 0\ + 0\ + 1\ + \ + glow\ + \ + 5\ + 0.0010000000474974513\ + -0.47999998927116394\ + 1\ + \ + haze_density\ + \ + 0.69999998807907104\ + 0\ + 0\ + 1\ + \ + haze_horizon\ + \ + 0.18999999761581243\ + 0.19915600121021271\ + 0.19915600121021271\ + 1\ + \ + lightnorm\ + \ + 0\ + 0.70710659027099609\ + -0.70710694789886475\ + 0\ + \ + max_y\ + \ + 1605\ + 0\ + 0\ + 1\ + \ + preset_num\ + 22\ + star_brightness\ + 0\ + sun_angle\ + 2.3561947345733643\ + sunlight_color\ + \ + 0.73421055078505759\ + 0.78157895803450828\ + 0.89999997615813498\ + 0.29999998211860301\ + \ + \ + "; + + std::stringstream preset_stream(preset); + mTestManager->loadPresetFromXML(LLWLParamKey("test1", LLWLParamKey::SCOPE_LOCAL), preset_stream); + LLWLParamSet dummy; + ensure("Couldn't get ParamSet after loading it", mTestManager->getParamSet(LLWLParamKey("test1", LLWLParamKey::SCOPE_LOCAL), dummy)); + } + catch (...) + { + fail("loadPresetFromXML test crashed!"); + } + } + + template<> template<> + void object::test<2>() + { + mTestManager->propagateParameters(); + ensure_equals("Wrong value from getDomeOffset()", mTestManager->getDomeOffset(), 0.96f); + ensure_equals("Wrong value from getDomeRadius()", mTestManager->getDomeRadius(), 15000.f); + ensure_equals("Wrong value from getLightDir()", mTestManager->getLightDir(), LLVector4(-0,0,1,0)); + ensure_equals("Wrong value from getClampedLightDir()", mTestManager->getClampedLightDir(), LLVector4(-0,0,1,0)); + ensure_equals("Wrong value from getRotatedLightDir()", mTestManager->getRotatedLightDir(), LLVector4(0,0,0,1)); + } +} diff --git a/indra/newview/tests/llwlparamset_stub.cpp b/indra/newview/tests/llwlparamset_stub.cpp new file mode 100644 index 0000000000..6ce4b5827d --- /dev/null +++ b/indra/newview/tests/llwlparamset_stub.cpp @@ -0,0 +1,24 @@ +/** + * @file llwlparamset_stub.cpp + * @brief stub class to allow unit testing + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +LLWLParamSet::LLWLParamSet(void) +{ +} + +void LLWLParamSet::updateCloudScrolling() +{ +} + +void LLWLParamSet::set(const std::string& name, const LLVector4& val) +{ +} + +void LLWLParamSet::update(LLGLSLShader *shader) const +{ +} -- cgit v1.2.3