/** * @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)); } }