/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. // Precompiled headers
  27. #include "../llviewerprecompiledheaders.h"
  28. // Class to test
  29. #include "../llwlparammanager.h"
  30. // Dependencies
  31. #include "linden_common.h"
  32. // TUT header
  33. #include "lltut.h"
  34. // Stubs
  35. #include "llwldaycycle_stub.cpp"
  36. #include "llwlparamset_stub.cpp"
  37. #include "llwlanimator_stub.cpp"
  38. #include "llglslshader_stub.cpp"
  39. #include "lldir_stub.cpp"
  40. #include "llsky_stub.cpp"
  41. #include "llpipeline_stub.cpp"
  42. #include "llviewershadermgr_stub.cpp"
  43. void assert_glerror(void) {}
  44. LLViewerCamera::LLViewerCamera() {}
  45. void LLViewerCamera::setView(F32 vertical_fov_rads) {}
  46. std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args) { return std::string(""); }
  47. char* curl_unescape(const char* c_str, int length)
  48. {
  49. char* copy = new char[length+4];
  50. memcpy(copy, c_str, length);
  51. copy[length+0] = 'E';
  52. copy[length+1] = 'S';
  53. copy[length+2] = 'C';
  54. copy[length+3] = '\0';
  55. return copy;
  56. }
  57. void curl_free(void* p) {delete[] ((char*)p);}
  58. char* curl_escape(const char* c_str, int length) {
  59. char* copy = new char[length+6];
  60. memcpy(copy, c_str, length);
  61. copy[length+0] = 'U';
  62. copy[length+1] = 'N';
  63. copy[length+2] = 'E';
  64. copy[length+3] = 'S';
  65. copy[length+4] = 'C';
  66. copy[length+5] = '\0';
  67. return copy;
  68. }
  69. namespace tut
  70. {
  71. // Main Setup
  72. struct LLWLParamManagerFixture
  73. {
  74. class LLWLParamManagerTest
  75. {
  76. };
  77. LLWLParamManager* mTestManager;
  78. LLWLParamManagerFixture()
  79. : mTestManager(LLWLParamManager::getInstance())
  80. {
  81. }
  82. ~LLWLParamManagerFixture()
  83. {
  84. }
  85. };
  86. typedef test_group<LLWLParamManagerFixture> factory;
  87. typedef factory::object object;
  88. factory tf("LLWLParamManager test");
  89. // Tests
  90. template<> template<>
  91. void object::test<1>()
  92. {
  93. try
  94. {
  95. std::string preset =
  96. "<llsd>\
  97. <map>\
  98. <key>ambient</key>\
  99. <array>\
  100. <real>1.0499999523162842</real>\
  101. <real>1.0499999523162842</real>\
  102. <real>1.0499999523162842</real>\
  103. <real>0.34999999403953552</real>\
  104. </array>\
  105. <key>blue_density</key>\
  106. <array>\
  107. <real>0.2447581488182351</real>\
  108. <real>0.44872328639030457</real>\
  109. <real>0.75999999046325684</real>\
  110. <real>0.38000004053115788</real>\
  111. </array>\
  112. <key>blue_horizon</key>\
  113. <array>\
  114. <real>0.49548382097675159</real>\
  115. <real>0.49548381382419748</real>\
  116. <real>0.63999999284744291</real>\
  117. <real>0.31999999642372146</real>\
  118. </array>\
  119. <key>cloud_color</key>\
  120. <array>\
  121. <real>0.40999999165535073</real>\
  122. <real>0.40999999165535073</real>\
  123. <real>0.40999999165535073</real>\
  124. <real>0.40999999165535073</real>\
  125. </array>\
  126. <key>cloud_pos_density1</key>\
  127. <array>\
  128. <real>1.6884100437164307</real>\
  129. <real>0.52609699964523315</real>\
  130. <real>0.99999999999999289</real>\
  131. <real>1</real>\
  132. </array>\
  133. <key>cloud_pos_density2</key>\
  134. <array>\
  135. <real>1.6884100437164307</real>\
  136. <real>0.52609699964523315</real>\
  137. <real>0.125</real>\
  138. <real>1</real>\
  139. </array>\
  140. <key>cloud_scale</key>\
  141. <array>\
  142. <real>0.4199999868869746</real>\
  143. <real>0</real>\
  144. <real>0</real>\
  145. <real>1</real>\
  146. </array>\
  147. <key>cloud_scroll_rate</key>\
  148. <array>\
  149. <real>10.199999809265137</real>\
  150. <real>10.01099967956543</real>\
  151. </array>\
  152. <key>cloud_shadow</key>\
  153. <array>\
  154. <real>0.26999998092651367</real>\
  155. <real>0</real>\
  156. <real>0</real>\
  157. <real>1</real>\
  158. </array>\
  159. <key>density_multiplier</key>\
  160. <array>\
  161. <real>0.00017999998817685818</real>\
  162. <real>0</real>\
  163. <real>0</real>\
  164. <real>1</real>\
  165. </array>\
  166. <key>distance_multiplier</key>\
  167. <array>\
  168. <real>0.80000001192093606</real>\
  169. <real>0</real>\
  170. <real>0</real>\
  171. <real>1</real>\
  172. </array>\
  173. <key>east_angle</key>\
  174. <real>0</real>\
  175. <key>enable_cloud_scroll</key>\
  176. <array>\
  177. <boolean>1</boolean>\
  178. <boolean>1</boolean>\
  179. </array>\
  180. <key>gamma</key>\
  181. <array>\
  182. <real>1</real>\
  183. <real>0</real>\
  184. <real>0</real>\
  185. <real>1</real>\
  186. </array>\
  187. <key>glow</key>\
  188. <array>\
  189. <real>5</real>\
  190. <real>0.0010000000474974513</real>\
  191. <real>-0.47999998927116394</real>\
  192. <real>1</real>\
  193. </array>\
  194. <key>haze_density</key>\
  195. <array>\
  196. <real>0.69999998807907104</real>\
  197. <real>0</real>\
  198. <real>0</real>\
  199. <real>1</real>\
  200. </array>\
  201. <key>haze_horizon</key>\
  202. <array>\
  203. <real>0.18999999761581243</real>\
  204. <real>0.19915600121021271</real>\
  205. <real>0.19915600121021271</real>\
  206. <real>1</real>\
  207. </array>\
  208. <key>lightnorm</key>\
  209. <array>\
  210. <real>0</real>\
  211. <real>0.70710659027099609</real>\
  212. <real>-0.70710694789886475</real>\
  213. <real>0</real>\
  214. </array>\
  215. <key>max_y</key>\
  216. <array>\
  217. <real>1605</real>\
  218. <real>0</real>\
  219. <real>0</real>\
  220. <real>1</real>\
  221. </array>\
  222. <key>preset_num</key>\
  223. <integer>22</integer>\
  224. <key>star_brightness</key>\
  225. <real>0</real>\
  226. <key>sun_angle</key>\
  227. <real>2.3561947345733643</real>\
  228. <key>sunlight_color</key>\
  229. <array>\
  230. <real>0.73421055078505759</real>\
  231. <real>0.78157895803450828</real>\
  232. <real>0.89999997615813498</real>\
  233. <real>0.29999998211860301</real>\
  234. </array>\
  235. </map>\
  236. </llsd>";
  237. std::stringstream preset_stream(preset);
  238. mTestManager->loadPresetFromXML(LLWLParamKey("test1", LLWLParamKey::SCOPE_LOCAL), preset_stream);
  239. LLWLParamSet dummy;
  240. ensure("Couldn't get ParamSet after loading it", mTestManager->getParamSet(LLWLParamKey("test1", LLWLParamKey::SCOPE_LOCAL), dummy));
  241. }
  242. catch (...)
  243. {
  244. fail("loadPresetFromXML test crashed!");
  245. }
  246. }
  247. template<> template<>
  248. void object::test<2>()
  249. {
  250. mTestManager->propagateParameters();
  251. ensure_equals("Wrong value from getDomeOffset()", mTestManager->getDomeOffset(), 0.96f);
  252. ensure_equals("Wrong value from getDomeRadius()", mTestManager->getDomeRadius(), 15000.f);
  253. ensure_equals("Wrong value from getLightDir()", mTestManager->getLightDir(), LLVector4(-0,0,1,0));
  254. ensure_equals("Wrong value from getClampedLightDir()", mTestManager->getClampedLightDir(), LLVector4(-0,0,1,0));
  255. ensure_equals("Wrong value from getRotatedLightDir()", mTestManager->getRotatedLightDir(), LLVector4(0,0,0,1));
  256. }
  257. }