PageRenderTime 71ms CodeModel.GetById 13ms app.highlight 54ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/tests/llurlmatch_test.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 313 lines | 197 code | 59 blank | 57 comment | 0 complexity | c3b94445c574eb4bf541d3272fefc279 MD5 | raw file
  1/**
  2 * @file llurlmatch_test.cpp
  3 * @author Martin Reddy
  4 * @brief Unit tests for LLUrlMatch
  5 *
  6 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28#include "linden_common.h"
 29
 30#include "../llurlmatch.h"
 31#include "../lluiimage.h"
 32#include "lltut.h"
 33
 34// link seams
 35
 36LLUIColor::LLUIColor()
 37	: mColorPtr(NULL)
 38{}
 39
 40LLStyle::Params::Params()
 41{
 42}
 43
 44LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image)
 45{
 46}
 47
 48LLUIImage::~LLUIImage()
 49{
 50}
 51
 52//virtual
 53S32 LLUIImage::getWidth() const
 54{
 55	return 0;
 56}
 57
 58//virtual
 59S32 LLUIImage::getHeight() const
 60{
 61	return 0;
 62}
 63
 64namespace LLInitParam
 65{
 66	BlockDescriptor::BlockDescriptor() {}
 67	ParamDescriptor::ParamDescriptor(param_handle_t p, 
 68						merge_func_t merge_func, 
 69						deserialize_func_t deserialize_func, 
 70						serialize_func_t serialize_func,
 71						validation_func_t validation_func,
 72						inspect_func_t inspect_func,
 73						S32 min_count,
 74						S32 max_count){}
 75	ParamDescriptor::~ParamDescriptor() {}
 76
 77	void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name){}
 78	param_handle_t BaseBlock::getHandleFromParam(const Param* param) const {return 0;}
 79	void BaseBlock::addSynonym(Param& param, const std::string& synonym) {}
 80
 81	void BaseBlock::init(BlockDescriptor& descriptor, BlockDescriptor& base_descriptor, size_t block_size)
 82	{
 83		descriptor.mCurrentBlockPtr = this;
 84	}
 85
 86	Param::Param(BaseBlock* enclosing_block)
 87	:	mIsProvided(false)
 88	{
 89		const U8* my_addr = reinterpret_cast<const U8*>(this);
 90		const U8* block_addr = reinterpret_cast<const U8*>(enclosing_block);
 91		mEnclosingBlockOffset = 0x7FFFffff & ((U32)(my_addr - block_addr));
 92	}
 93
 94	bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name){ return true; }
 95	void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const LLInitParam::BaseBlock* diff_block) const {}
 96	bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_count, S32 max_count) const { return true; }
 97	bool BaseBlock::mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; }
 98	bool BaseBlock::validateBlock(bool emit_errors) const { return true; }
 99
100	ParamValue<LLUIColor, TypeValues<LLUIColor> >::ParamValue(const LLUIColor& color)
101	:	super_t(color)
102	{}
103
104	void ParamValue<LLUIColor, TypeValues<LLUIColor> >::updateValueFromBlock()
105	{}
106	
107	void ParamValue<LLUIColor, TypeValues<LLUIColor> >::updateBlockFromValue(bool)
108	{}
109
110	bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
111	{
112		return false;
113	}
114
115
116	ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::ParamValue(const LLFontGL* fontp)
117	:	super_t(fontp)
118	{}
119
120	void ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::updateValueFromBlock()
121	{}
122	
123	void ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::updateBlockFromValue(bool)
124	{}
125
126	void TypeValues<LLFontGL::HAlign>::declareValues()
127	{}
128
129	void TypeValues<LLFontGL::VAlign>::declareValues()
130	{}
131
132	void TypeValues<LLFontGL::ShadowType>::declareValues()
133	{}
134
135	void ParamValue<LLUIImage*, TypeValues<LLUIImage*> >::updateValueFromBlock()
136	{}
137	
138	void ParamValue<LLUIImage*, TypeValues<LLUIImage*> >::updateBlockFromValue(bool)
139	{}
140	
141	bool ParamCompare<LLUIImage*, false>::equals(
142		LLUIImage* const &a,
143		LLUIImage* const &b)
144	{
145		return false;
146	}
147
148	bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
149	{
150		return false;
151	}
152
153}
154
155//static
156LLFontGL* LLFontGL::getFontDefault()
157{
158	return NULL; 
159}
160
161
162namespace tut
163{
164	struct LLUrlMatchData
165	{
166	};
167
168	typedef test_group<LLUrlMatchData> factory;
169	typedef factory::object object;
170}
171
172namespace
173{
174	tut::factory tf("LLUrlMatch");
175}
176
177namespace tut
178{
179	template<> template<>
180	void object::test<1>()
181	{
182		//
183		// test the empty() method
184		//
185		LLUrlMatch match;
186		ensure("empty()", match.empty());
187
188		match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLStyle::Params(), "", "", LLUUID::null);
189		ensure("! empty()", ! match.empty());
190	}
191
192	template<> template<>
193	void object::test<2>()
194	{
195		//
196		// test the getStart() method
197		//
198		LLUrlMatch match;
199		ensure_equals("getStart() == 0", match.getStart(), 0);
200
201		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
202		ensure_equals("getStart() == 10", match.getStart(), 10);
203	}
204
205	template<> template<>
206	void object::test<3>()
207	{
208		//
209		// test the getEnd() method
210		//
211		LLUrlMatch match;
212		ensure_equals("getEnd() == 0", match.getEnd(), 0);
213
214		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
215		ensure_equals("getEnd() == 20", match.getEnd(), 20);
216	}
217
218	template<> template<>
219	void object::test<4>()
220	{
221		//
222		// test the getUrl() method
223		//
224		LLUrlMatch match;
225		ensure_equals("getUrl() == ''", match.getUrl(), "");
226
227		match.setValues(10, 20, "http://slurl.com/", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
228		ensure_equals("getUrl() == 'http://slurl.com/'", match.getUrl(), "http://slurl.com/");
229
230		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
231		ensure_equals("getUrl() == '' (2)", match.getUrl(), "");
232	}
233
234	template<> template<>
235	void object::test<5>()
236	{
237		//
238		// test the getLabel() method
239		//
240		LLUrlMatch match;
241		ensure_equals("getLabel() == ''", match.getLabel(), "");
242
243		match.setValues(10, 20, "", "Label", "", "", LLStyle::Params(), "", "", LLUUID::null);
244		ensure_equals("getLabel() == 'Label'", match.getLabel(), "Label");
245
246		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
247		ensure_equals("getLabel() == '' (2)", match.getLabel(), "");
248	}
249
250	template<> template<>
251	void object::test<6>()
252	{
253		//
254		// test the getTooltip() method
255		//
256		LLUrlMatch match;
257		ensure_equals("getTooltip() == ''", match.getTooltip(), "");
258
259		match.setValues(10, 20, "", "", "Info", "", LLStyle::Params(), "", "", LLUUID::null);
260		ensure_equals("getTooltip() == 'Info'", match.getTooltip(), "Info");
261
262		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
263		ensure_equals("getTooltip() == '' (2)", match.getTooltip(), "");
264	}
265
266	template<> template<>
267	void object::test<7>()
268	{
269		//
270		// test the getIcon() method
271		//
272		LLUrlMatch match;
273		ensure_equals("getIcon() == ''", match.getIcon(), "");
274
275		match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "", "", LLUUID::null);
276		ensure_equals("getIcon() == 'Icon'", match.getIcon(), "Icon");
277
278		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
279		ensure_equals("getIcon() == '' (2)", match.getIcon(), "");
280	}
281
282	template<> template<>
283	void object::test<8>()
284	{
285		//
286		// test the getMenuName() method
287		//
288		LLUrlMatch match;
289		ensure("getMenuName() empty", match.getMenuName().empty());
290
291		match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "", LLUUID::null);
292		ensure_equals("getMenuName() == \"xui_file.xml\"", match.getMenuName(), "xui_file.xml");
293
294		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
295		ensure("getMenuName() empty (2)", match.getMenuName().empty());
296	}
297
298	template<> template<>
299	void object::test<9>()
300	{
301		//
302		// test the getLocation() method
303		//
304		LLUrlMatch match;
305		ensure("getLocation() empty", match.getLocation().empty());
306
307		match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris", LLUUID::null);
308		ensure_equals("getLocation() == \"Paris\"", match.getLocation(), "Paris");
309
310		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
311		ensure("getLocation() empty (2)", match.getLocation().empty());
312	}
313}