PageRenderTime 46ms CodeModel.GetById 10ms app.highlight 30ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/tests/llwlparammanager_test.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 271 lines | 225 code | 14 blank | 32 comment | 0 complexity | 2ec1e1a7d68a873ed857a9a3db8cfc4d MD5 | raw file
  1/** 
  2 * @file llwlparammanager_test.cpp
  3 * @brief LLWLParamManager tests
  4 *
  5 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2011, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27// Precompiled headers
 28#include "../llviewerprecompiledheaders.h"
 29
 30// Class to test
 31#include "../llwlparammanager.h"
 32
 33// Dependencies
 34#include "linden_common.h"
 35
 36// TUT header
 37#include "lltut.h"
 38
 39// Stubs
 40#include "llwldaycycle_stub.cpp"
 41#include "llwlparamset_stub.cpp"
 42#include "llwlanimator_stub.cpp"
 43#include "llglslshader_stub.cpp"
 44#include "lldir_stub.cpp"
 45#include "llsky_stub.cpp"
 46#include "llpipeline_stub.cpp"
 47#include "llviewershadermgr_stub.cpp"
 48
 49void assert_glerror(void) {}
 50LLViewerCamera::LLViewerCamera() {}
 51void LLViewerCamera::setView(F32 vertical_fov_rads) {}
 52std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args) { return std::string(""); }
 53
 54char* curl_unescape(const char* c_str, int length)
 55{
 56	char* copy = new char[length+4];
 57	memcpy(copy, c_str, length);
 58	copy[length+0] = 'E';
 59	copy[length+1] = 'S';
 60	copy[length+2] = 'C';
 61	copy[length+3] = '\0';
 62	return copy;
 63}
 64void curl_free(void* p) {delete[] ((char*)p);}
 65char* curl_escape(const char* c_str, int length) {
 66	char* copy = new char[length+6];
 67	memcpy(copy, c_str, length);
 68	copy[length+0] = 'U';
 69	copy[length+1] = 'N';
 70	copy[length+2] = 'E';
 71	copy[length+3] = 'S';
 72	copy[length+4] = 'C';
 73	copy[length+5] = '\0';
 74	return copy;
 75}
 76
 77namespace tut
 78{
 79	// Main Setup
 80	struct LLWLParamManagerFixture
 81	{
 82		class LLWLParamManagerTest
 83		{
 84		};
 85
 86		LLWLParamManager* mTestManager;
 87
 88		LLWLParamManagerFixture()
 89			: mTestManager(LLWLParamManager::getInstance())
 90		{
 91		}
 92
 93		~LLWLParamManagerFixture()
 94		{
 95		}
 96	};
 97	typedef test_group<LLWLParamManagerFixture> factory;
 98	typedef factory::object object;
 99	factory tf("LLWLParamManager test");
100
101	// Tests
102	template<> template<>
103	void object::test<1>()
104	{
105		try
106		{
107			std::string preset =
108			"<llsd>\
109				<map>\
110				<key>ambient</key>\
111					<array>\
112						<real>1.0499999523162842</real>\
113						<real>1.0499999523162842</real>\
114						<real>1.0499999523162842</real>\
115						<real>0.34999999403953552</real>\
116					</array>\
117				<key>blue_density</key>\
118					<array>\
119						<real>0.2447581488182351</real>\
120						<real>0.44872328639030457</real>\
121						<real>0.75999999046325684</real>\
122						<real>0.38000004053115788</real>\
123					</array>\
124				<key>blue_horizon</key>\
125					<array>\
126						<real>0.49548382097675159</real>\
127						<real>0.49548381382419748</real>\
128						<real>0.63999999284744291</real>\
129						<real>0.31999999642372146</real>\
130					</array>\
131				<key>cloud_color</key>\
132					<array>\
133						<real>0.40999999165535073</real>\
134						<real>0.40999999165535073</real>\
135						<real>0.40999999165535073</real>\
136						<real>0.40999999165535073</real>\
137					</array>\
138				<key>cloud_pos_density1</key>\
139					<array>\
140						<real>1.6884100437164307</real>\
141						<real>0.52609699964523315</real>\
142						<real>0.99999999999999289</real>\
143						<real>1</real>\
144					</array>\
145				<key>cloud_pos_density2</key>\
146					<array>\
147						<real>1.6884100437164307</real>\
148						<real>0.52609699964523315</real>\
149						<real>0.125</real>\
150						<real>1</real>\
151					</array>\
152				<key>cloud_scale</key>\
153					<array>\
154						<real>0.4199999868869746</real>\
155						<real>0</real>\
156						<real>0</real>\
157						<real>1</real>\
158					</array>\
159				<key>cloud_scroll_rate</key>\
160					<array>\
161						<real>10.199999809265137</real>\
162						<real>10.01099967956543</real>\
163					</array>\
164				<key>cloud_shadow</key>\
165					<array>\
166						<real>0.26999998092651367</real>\
167						<real>0</real>\
168						<real>0</real>\
169						<real>1</real>\
170					</array>\
171				<key>density_multiplier</key>\
172					<array>\
173						<real>0.00017999998817685818</real>\
174						<real>0</real>\
175						<real>0</real>\
176						<real>1</real>\
177					</array>\
178				<key>distance_multiplier</key>\
179					<array>\
180						<real>0.80000001192093606</real>\
181						<real>0</real>\
182						<real>0</real>\
183						<real>1</real>\
184					</array>\
185				<key>east_angle</key>\
186					<real>0</real>\
187				<key>enable_cloud_scroll</key>\
188					<array>\
189						<boolean>1</boolean>\
190						<boolean>1</boolean>\
191					</array>\
192				<key>gamma</key>\
193					<array>\
194						<real>1</real>\
195						<real>0</real>\
196						<real>0</real>\
197						<real>1</real>\
198					</array>\
199				<key>glow</key>\
200					<array>\
201						<real>5</real>\
202						<real>0.0010000000474974513</real>\
203						<real>-0.47999998927116394</real>\
204						<real>1</real>\
205					</array>\
206				<key>haze_density</key>\
207					<array>\
208						<real>0.69999998807907104</real>\
209						<real>0</real>\
210						<real>0</real>\
211						<real>1</real>\
212					</array>\
213				<key>haze_horizon</key>\
214					<array>\
215						<real>0.18999999761581243</real>\
216						<real>0.19915600121021271</real>\
217						<real>0.19915600121021271</real>\
218						<real>1</real>\
219					</array>\
220				<key>lightnorm</key>\
221					<array>\
222						<real>0</real>\
223						<real>0.70710659027099609</real>\
224						<real>-0.70710694789886475</real>\
225						<real>0</real>\
226					</array>\
227				<key>max_y</key>\
228					<array>\
229						<real>1605</real>\
230						<real>0</real>\
231						<real>0</real>\
232						<real>1</real>\
233					</array>\
234				<key>preset_num</key>\
235					<integer>22</integer>\
236				<key>star_brightness</key>\
237					<real>0</real>\
238				<key>sun_angle</key>\
239					<real>2.3561947345733643</real>\
240				<key>sunlight_color</key>\
241					<array>\
242						<real>0.73421055078505759</real>\
243						<real>0.78157895803450828</real>\
244						<real>0.89999997615813498</real>\
245						<real>0.29999998211860301</real>\
246					</array>\
247				</map>\
248			</llsd>";
249
250			std::stringstream preset_stream(preset);
251			mTestManager->loadPresetFromXML(LLWLParamKey("test1", LLWLParamKey::SCOPE_LOCAL), preset_stream);
252			LLWLParamSet dummy;
253			ensure("Couldn't get ParamSet after loading it", mTestManager->getParamSet(LLWLParamKey("test1", LLWLParamKey::SCOPE_LOCAL), dummy));
254		}
255		catch (...)
256		{
257			fail("loadPresetFromXML test crashed!");
258		}
259	}
260
261	template<> template<>
262	void object::test<2>()
263	{
264		mTestManager->propagateParameters();
265		ensure_equals("Wrong value from getDomeOffset()", mTestManager->getDomeOffset(), 0.96f);
266		ensure_equals("Wrong value from getDomeRadius()", mTestManager->getDomeRadius(), 15000.f);
267		ensure_equals("Wrong value from getLightDir()", mTestManager->getLightDir(), LLVector4(-0,0,1,0));
268		ensure_equals("Wrong value from getClampedLightDir()", mTestManager->getClampedLightDir(), LLVector4(-0,0,1,0));
269		ensure_equals("Wrong value from getRotatedLightDir()", mTestManager->getRotatedLightDir(), LLVector4(0,0,0,1));
270	}
271}