1/*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Choose config tests.
22 *//*--------------------------------------------------------------------*/
23
24#include "teglChooseConfigTests.hpp"
25#include "teglChooseConfigReference.hpp"
26#include "tcuTestLog.hpp"
27#include "egluStrUtil.hpp"
28#include "egluUtil.hpp"
29#include "eglwLibrary.hpp"
30#include "eglwEnums.hpp"
31#include "deRandom.hpp"
32#include "deStringUtil.hpp"
33
34#include <vector>
35#include <algorithm>
36#include <string>
37#include <set>
38#include <map>
39
40namespace deqp
41{
42namespace egl
43{
44
45using std::set;
46using std::vector;
47using std::pair;
48using std::string;
49using tcu::TestLog;
50using eglu::ConfigInfo;
51using namespace eglw;
52
53namespace
54{
55
56string configListToString (const Library& egl, const EGLDisplay& display, const vector<EGLConfig>& configs)
57{
58	string str = "";
59	for (vector<EGLConfig>::const_iterator cfgIter = configs.begin(); cfgIter != configs.end(); cfgIter++)
60	{
61		EGLConfig	config		= *cfgIter;
62		EGLint		configId	= eglu::getConfigID(egl, display, config);
63
64		if (str.length() != 0)
65			str += " ";
66
67		str += de::toString(configId);
68	}
69	return str;
70}
71
72void logConfigAttrib (TestLog& log, EGLenum attrib, EGLint value)
73{
74	const std::string	attribStr	= eglu::getConfigAttribName(attrib);
75
76	if (value == EGL_DONT_CARE)
77	{
78		log << TestLog::Message << "  " << attribStr << ": EGL_DONT_CARE" << TestLog::EndMessage;
79		return;
80	}
81
82	log << TestLog::Message << "  " << attribStr << ": " << eglu::getConfigAttribValueStr(attrib, value) << TestLog::EndMessage;
83}
84
85bool configListEqual (const Library& egl, const EGLDisplay& display, const vector<EGLConfig>& as, const vector<EGLConfig>& bs)
86{
87	if (as.size() != bs.size())
88		return false;
89
90	for (int configNdx = 0; configNdx < (int)as.size(); configNdx++)
91	{
92		if (as[configNdx] != bs[configNdx])
93		{
94			// Allow lists to differ if both configs are non-conformant
95			const EGLint aCaveat = eglu::getConfigAttribInt(egl, display, as[configNdx], EGL_CONFIG_CAVEAT);
96			const EGLint bCaveat = eglu::getConfigAttribInt(egl, display, bs[configNdx], EGL_CONFIG_CAVEAT);
97
98			if (aCaveat != EGL_NON_CONFORMANT_CONFIG || bCaveat != EGL_NON_CONFORMANT_CONFIG)
99				return false;
100		}
101	}
102
103	return true;
104}
105
106} // anonymous
107
108class ChooseConfigCase : public TestCase
109{
110public:
111	ChooseConfigCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder, const EGLint* attributes)
112		: TestCase		(eglTestCtx, name, description)
113		, m_checkOrder	(checkOrder)
114		, m_display		(EGL_NO_DISPLAY)
115	{
116		// Parse attributes
117		while (attributes[0] != EGL_NONE)
118		{
119			m_attributes.push_back(std::make_pair((EGLenum)attributes[0], (EGLint)attributes[1]));
120			attributes += 2;
121		}
122	}
123
124	ChooseConfigCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder, const std::vector<std::pair<EGLenum, EGLint> >& attributes)
125		: TestCase		(eglTestCtx, name, description)
126		, m_checkOrder	(checkOrder)
127		, m_attributes	(attributes)
128		, m_display		(EGL_NO_DISPLAY)
129	{
130	}
131
132	void init (void)
133	{
134		DE_ASSERT(m_display == EGL_NO_DISPLAY);
135		m_display	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
136	}
137
138	void deinit (void)
139	{
140		m_eglTestCtx.getLibrary().terminate(m_display);
141		m_display = EGL_NO_DISPLAY;
142	}
143
144	IterateResult iterate (void)
145	{
146		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
147		executeTest(m_attributes, m_checkOrder);
148		return STOP;
149	}
150
151protected:
152	ChooseConfigCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder)
153		: TestCase		(eglTestCtx, name, description)
154		, m_checkOrder	(checkOrder)
155		, m_display		(EGL_NO_DISPLAY)
156	{
157	}
158
159	void executeTest (const std::vector<std::pair<EGLenum, EGLint> >& attributes, bool checkOrder)
160	{
161		const Library&	egl	= m_eglTestCtx.getLibrary();
162		TestLog&		log	= m_testCtx.getLog();
163
164		// Build attributes for EGL
165		vector<EGLint> attribList;
166		for (vector<pair<EGLenum, EGLint> >::const_iterator i = attributes.begin(); i != attributes.end(); i++)
167		{
168			attribList.push_back(i->first);
169			attribList.push_back(i->second);
170		}
171		attribList.push_back(EGL_NONE);
172
173		// Print attribList to log
174		log << TestLog::Message << "Attributes:" << TestLog::EndMessage;
175		for (vector<pair<EGLenum, EGLint> >::const_iterator i = attributes.begin(); i != attributes.end(); i++)
176			logConfigAttrib(log, i->first, i->second);
177
178		std::vector<EGLConfig>	resultConfigs;
179		std::vector<EGLConfig>	referenceConfigs;
180
181		// Query from EGL implementation
182		{
183			EGLint numConfigs = 0;
184			EGLU_CHECK_CALL(egl, chooseConfig(m_display, &attribList[0], DE_NULL, 0, &numConfigs));
185			resultConfigs.resize(numConfigs);
186
187			if (numConfigs > 0)
188				EGLU_CHECK_CALL(egl, chooseConfig(m_display, &attribList[0], &resultConfigs[0], (EGLint)resultConfigs.size(), &numConfigs));
189		}
190
191		// Build reference
192		chooseConfigReference(egl, m_display, referenceConfigs, attributes);
193
194		log << TestLog::Message << "Expected:\n  " << configListToString(egl, m_display, referenceConfigs) << TestLog::EndMessage;
195		log << TestLog::Message << "Got:\n  " << configListToString(egl, m_display, resultConfigs) << TestLog::EndMessage;
196
197		bool isSetMatch		= (set<EGLConfig>(resultConfigs.begin(), resultConfigs.end()) == set<EGLConfig>(referenceConfigs.begin(), referenceConfigs.end()));
198		bool isExactMatch	= configListEqual(egl, m_display, resultConfigs, referenceConfigs);
199		bool isMatch		= isSetMatch && (checkOrder ? isExactMatch : true);
200
201		if (isMatch)
202			log << TestLog::Message << "Pass" << TestLog::EndMessage;
203		else if (!isSetMatch)
204			log << TestLog::Message << "Fail, configs don't match" << TestLog::EndMessage;
205		else if (!isExactMatch)
206			log << TestLog::Message << "Fail, got correct configs but in invalid order" << TestLog::EndMessage;
207
208		if (!isMatch)
209			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
210	}
211
212	void fillDontCare (std::vector<std::pair<EGLenum, EGLint> >& attributes)
213	{
214		static const EGLenum dontCareAttributes[] =
215		{
216			EGL_TRANSPARENT_TYPE,
217			EGL_COLOR_BUFFER_TYPE,
218			EGL_RENDERABLE_TYPE,
219			EGL_SURFACE_TYPE
220		};
221
222		// Fill appropriate unused attributes with EGL_DONT_CARE
223		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(dontCareAttributes); ndx++)
224		{
225			bool found = false;
226			for (size_t findNdx = 0; findNdx < attributes.size(); findNdx++)
227				if (attributes[findNdx].first == dontCareAttributes[ndx]) found = true;
228
229			if (!found) attributes.push_back(std::make_pair(dontCareAttributes[ndx], EGL_DONT_CARE));
230		}
231	}
232
233	const bool						m_checkOrder;
234	vector<pair<EGLenum, EGLint> >	m_attributes;
235
236	EGLDisplay						m_display;
237};
238
239class ChooseConfigSimpleCase : public ChooseConfigCase
240{
241protected:
242	EGLint getValue (EGLenum name)
243	{
244		static const struct
245		{
246			EGLenum		name;
247			EGLint		value;
248		} attributes[] =
249		{
250			{ EGL_BUFFER_SIZE,				0					},
251			{ EGL_RED_SIZE,					0					},
252			{ EGL_GREEN_SIZE,				0					},
253			{ EGL_BLUE_SIZE,				0					},
254			{ EGL_LUMINANCE_SIZE,			0					},
255			{ EGL_ALPHA_SIZE,				0					},
256			{ EGL_ALPHA_MASK_SIZE,			0					},
257			{ EGL_BIND_TO_TEXTURE_RGB,		EGL_DONT_CARE		},
258			{ EGL_BIND_TO_TEXTURE_RGBA,		EGL_DONT_CARE		},
259			{ EGL_COLOR_BUFFER_TYPE,		EGL_DONT_CARE		},
260			{ EGL_CONFIG_CAVEAT,			EGL_DONT_CARE		},
261			//{ EGL_CONFIG_ID,				EGL_DONT_CARE		},
262			{ EGL_DEPTH_SIZE,				0					},
263			{ EGL_LEVEL,					0					},
264			{ EGL_MAX_SWAP_INTERVAL,		EGL_DONT_CARE		},
265			{ EGL_MIN_SWAP_INTERVAL,		EGL_DONT_CARE		},
266			{ EGL_NATIVE_RENDERABLE,		EGL_DONT_CARE		},
267			{ EGL_NATIVE_VISUAL_TYPE,		EGL_DONT_CARE		},
268			{ EGL_SAMPLE_BUFFERS,			0					},
269			{ EGL_SAMPLES,					0					},
270			{ EGL_STENCIL_SIZE,				0					},
271			{ EGL_TRANSPARENT_TYPE,			EGL_TRANSPARENT_RGB	},
272			{ EGL_TRANSPARENT_RED_VALUE,	0					},
273			{ EGL_TRANSPARENT_GREEN_VALUE,	0					},
274			{ EGL_TRANSPARENT_BLUE_VALUE,	0					},
275			{ EGL_CONFORMANT,				EGL_OPENGL_ES_BIT	},
276			{ EGL_RENDERABLE_TYPE,			EGL_OPENGL_ES_BIT	},
277			{ EGL_SURFACE_TYPE,				EGL_WINDOW_BIT		}
278			//{ EGL_CONFORMANT,				EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENVG_BIT	},
279			//{ EGL_RENDERABLE_TYPE,			EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENVG_BIT	},
280			//{ EGL_SURFACE_TYPE,				EGL_WINDOW_BIT
281			//								| EGL_PIXMAP_BIT
282			//								| EGL_PBUFFER_BIT
283			//								| EGL_MULTISAMPLE_RESOLVE_BOX_BIT
284			//								| EGL_VG_ALPHA_FORMAT_PRE_BIT
285			//								| EGL_SWAP_BEHAVIOR_PRESERVED_BIT
286			//								| EGL_VG_COLORSPACE_LINEAR_BIT
287			//								}
288		};
289
290		if (name == EGL_CONFIG_ID)
291		{
292			de::Random rnd(0);
293			vector<EGLConfig> configs = eglu::getConfigs(m_eglTestCtx.getLibrary(), m_display);
294			return eglu::getConfigID(m_eglTestCtx.getLibrary(), m_display, configs[rnd.getInt(0, (int)configs.size()-1)]);
295		}
296		else
297		{
298			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(attributes); ndx++)
299			{
300				if (attributes[ndx].name == name)
301					return attributes[ndx].value;
302			}
303		}
304
305		DE_ASSERT(DE_FALSE);
306		return EGL_NONE;
307	}
308public:
309	ChooseConfigSimpleCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLenum attribute, bool checkOrder)
310		: ChooseConfigCase(eglTestCtx, name, description, checkOrder)
311		, m_attribute(attribute)
312	{
313	}
314
315	TestCase::IterateResult iterate (void)
316	{
317		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
318
319		std::vector<std::pair<EGLenum, EGLint> > attributes;
320		attributes.push_back(std::pair<EGLenum, EGLint>(m_attribute, getValue(m_attribute)));
321
322		fillDontCare(attributes);
323		executeTest(attributes, m_checkOrder);
324
325		return STOP;
326	}
327private:
328	EGLenum	m_attribute;
329};
330
331class ChooseConfigRandomCase : public ChooseConfigCase
332{
333public:
334	ChooseConfigRandomCase (EglTestContext& eglTestCtx, const char* name, const char* description, const set<EGLenum>& attribSet)
335		: ChooseConfigCase	(eglTestCtx, name, description, true)
336		, m_attribSet		(attribSet)
337		, m_numIters		(10)
338		, m_iterNdx			(0)
339	{
340	}
341
342	void init (void)
343	{
344		ChooseConfigCase::init();
345		m_iterNdx = 0;
346		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
347	}
348
349	TestCase::IterateResult iterate (void)
350	{
351		m_testCtx.getLog() << TestLog::Message << "Iteration :" << m_iterNdx << TestLog::EndMessage;
352		m_iterNdx += 1;
353
354		// Build random list of attributes
355		de::Random									rnd(m_iterNdx);
356		const int									numAttribs	= rnd.getInt(0, (int)m_attribSet.size()*2);
357
358		std::vector<std::pair<EGLenum, EGLint> >	attributes	= genRandomAttributes(m_attribSet, numAttribs, rnd);
359
360		fillDontCare(attributes);
361		executeTest(attributes, m_checkOrder);
362
363		return m_iterNdx < m_numIters ? CONTINUE : STOP;
364	}
365
366	template <int MinVal, int MaxVal> static EGLint getInt (de::Random& rnd)
367	{
368		return rnd.getInt(MinVal, MaxVal);
369	}
370
371	static EGLint getBool (de::Random& rnd)
372	{
373		return rnd.getBool() ? EGL_TRUE : EGL_FALSE;
374	}
375
376	static EGLint getBufferType (de::Random& rnd)
377	{
378		static const EGLint types[] = { EGL_RGB_BUFFER, EGL_LUMINANCE_BUFFER };
379		return rnd.choose<EGLint>(types, types+DE_LENGTH_OF_ARRAY(types));
380	}
381
382	static EGLint getConfigCaveat (de::Random& rnd)
383	{
384		static const EGLint caveats[] = { EGL_SLOW_CONFIG, EGL_NON_CONFORMANT_CONFIG };
385		return rnd.choose<EGLint>(caveats, caveats+DE_LENGTH_OF_ARRAY(caveats));
386	}
387
388	static EGLint getApiBits (de::Random& rnd)
389	{
390		EGLint api = 0;
391		api |= rnd.getBool() ? EGL_OPENGL_BIT		: 0;
392		api |= rnd.getBool() ? EGL_OPENGL_ES_BIT	: 0;
393		api |= rnd.getBool() ? EGL_OPENGL_ES2_BIT	: 0;
394		api |= rnd.getBool() ? EGL_OPENVG_BIT		: 0;
395		return api;
396	}
397
398	static EGLint getSurfaceType (de::Random& rnd)
399	{
400		EGLint bits = 0;
401		bits |= rnd.getBool() ? EGL_WINDOW_BIT	: 0;
402		bits |= rnd.getBool() ? EGL_PIXMAP_BIT	: 0;
403		bits |= rnd.getBool() ? EGL_PBUFFER_BIT	: 0;
404		return bits;
405	}
406
407	struct AttribSpec
408	{
409		EGLenum			attribute;
410		EGLint			(*getValue)(de::Random& rnd);
411	};
412
413	std::vector<std::pair<EGLenum, EGLint> > genRandomAttributes (const std::set<EGLenum>& attribSet, int numAttribs, de::Random& rnd)
414	{
415		static const struct AttribSpec attributes[] =
416		{
417			{ EGL_BUFFER_SIZE,				ChooseConfigRandomCase::getInt<0, 32>,		},
418			{ EGL_RED_SIZE,					ChooseConfigRandomCase::getInt<0, 8>,		},
419			{ EGL_GREEN_SIZE,				ChooseConfigRandomCase::getInt<0, 8>,		},
420			{ EGL_BLUE_SIZE,				ChooseConfigRandomCase::getInt<0, 8>,		},
421			{ EGL_LUMINANCE_SIZE,			ChooseConfigRandomCase::getInt<0, 1>,		},
422			{ EGL_ALPHA_SIZE,				ChooseConfigRandomCase::getInt<0, 8>,		},
423			{ EGL_ALPHA_MASK_SIZE,			ChooseConfigRandomCase::getInt<0, 1>,		},
424			{ EGL_BIND_TO_TEXTURE_RGB,		ChooseConfigRandomCase::getBool,			},
425			{ EGL_BIND_TO_TEXTURE_RGBA,		ChooseConfigRandomCase::getBool,			},
426			{ EGL_COLOR_BUFFER_TYPE,		ChooseConfigRandomCase::getBufferType,		},
427			{ EGL_CONFIG_CAVEAT,			ChooseConfigRandomCase::getConfigCaveat,	},
428//			{ EGL_CONFIG_ID,				0/*special*/,		},
429			{ EGL_CONFORMANT,				ChooseConfigRandomCase::getApiBits,			},
430			{ EGL_DEPTH_SIZE,				ChooseConfigRandomCase::getInt<0, 32>,		},
431			{ EGL_LEVEL,					ChooseConfigRandomCase::getInt<0, 1>,		},
432//			{ EGL_MATCH_NATIVE_PIXMAP,		EGL_NONE,			},
433			{ EGL_MAX_SWAP_INTERVAL,		ChooseConfigRandomCase::getInt<0, 2>,		},
434			{ EGL_MIN_SWAP_INTERVAL,		ChooseConfigRandomCase::getInt<0, 1>,		},
435			{ EGL_NATIVE_RENDERABLE,		ChooseConfigRandomCase::getBool,			},
436//			{ EGL_NATIVE_VISUAL_TYPE,		EGL_DONT_CARE,		},
437			{ EGL_RENDERABLE_TYPE,			ChooseConfigRandomCase::getApiBits,			},
438			{ EGL_SAMPLE_BUFFERS,			ChooseConfigRandomCase::getInt<0, 1>,		},
439			{ EGL_SAMPLES,					ChooseConfigRandomCase::getInt<0, 1>,		},
440			{ EGL_STENCIL_SIZE,				ChooseConfigRandomCase::getInt<0, 1>,		},
441			{ EGL_SURFACE_TYPE,				ChooseConfigRandomCase::getSurfaceType,		},
442//			{ EGL_TRANSPARENT_TYPE,			EGL_TRANSPARENT_RGB,},
443//			{ EGL_TRANSPARENT_RED_VALUE,	ChooseConfigRandomCase::getInt<0, 255>,		},
444//			{ EGL_TRANSPARENT_GREEN_VALUE,	ChooseConfigRandomCase::getInt<0, 255>,		},
445//			{ EGL_TRANSPARENT_BLUE_VALUE,	ChooseConfigRandomCase::getInt<0, 255>,		}
446		};
447
448		std::vector<std::pair<EGLenum, EGLint> > out;
449
450		// Build list to select from
451		std::vector<AttribSpec> candidates;
452		for (int ndx = 0; ndx < (int)DE_LENGTH_OF_ARRAY(attributes); ndx++)
453		{
454			if (attribSet.find(attributes[ndx].attribute) != attribSet.end())
455				candidates.push_back(attributes[ndx]);
456		}
457
458		for (int attribNdx = 0; attribNdx < numAttribs; attribNdx++)
459		{
460			AttribSpec spec = rnd.choose<AttribSpec>(candidates.begin(), candidates.end());
461			out.push_back(std::make_pair(spec.attribute, spec.getValue(rnd)));
462		}
463
464		return out;
465	}
466private:
467	std::set<EGLenum>	m_attribSet;
468	int					m_numIters;
469	int					m_iterNdx;
470};
471
472ChooseConfigTests::ChooseConfigTests (EglTestContext& eglTestCtx)
473	: TestCaseGroup(eglTestCtx, "choose_config", "eglChooseConfig() tests")
474{
475}
476
477ChooseConfigTests::~ChooseConfigTests (void)
478{
479}
480
481namespace
482{
483
484template <typename T, size_t N>
485std::set<T> toSet (const T (&arr)[N])
486{
487	std::set<T> set;
488	for (size_t i = 0; i < N; i++)
489		set.insert(arr[i]);
490	return set;
491}
492
493} // anonymous
494
495void ChooseConfigTests::init (void)
496{
497	// Single attributes
498	{
499		static const struct
500		{
501			EGLenum			attribute;
502			const char*		testName;
503		} attributes[] =
504		{
505			{ EGL_BUFFER_SIZE,				"buffer_size"				},
506			{ EGL_RED_SIZE,					"red_size"					},
507			{ EGL_GREEN_SIZE,				"green_size"				},
508			{ EGL_BLUE_SIZE,				"blue_size"					},
509			{ EGL_LUMINANCE_SIZE,			"luminance_size"			},
510			{ EGL_ALPHA_SIZE,				"alpha_size"				},
511			{ EGL_ALPHA_MASK_SIZE,			"alpha_mask_size"			},
512			{ EGL_BIND_TO_TEXTURE_RGB,		"bind_to_texture_rgb"		},
513			{ EGL_BIND_TO_TEXTURE_RGBA,		"bind_to_texture_rgba"		},
514			{ EGL_COLOR_BUFFER_TYPE,		"color_buffer_type"			},
515			{ EGL_CONFIG_CAVEAT,			"config_caveat"				},
516			{ EGL_CONFIG_ID,				"config_id"					},
517			{ EGL_CONFORMANT,				"conformant"				},
518			{ EGL_DEPTH_SIZE,				"depth_size"				},
519			{ EGL_LEVEL,					"level"						},
520			{ EGL_MAX_SWAP_INTERVAL,		"max_swap_interval"			},
521			{ EGL_MIN_SWAP_INTERVAL,		"min_swap_interval"			},
522			{ EGL_NATIVE_RENDERABLE,		"native_renderable"			},
523			{ EGL_NATIVE_VISUAL_TYPE,		"native_visual_type"		},
524			{ EGL_RENDERABLE_TYPE,			"renderable_type"			},
525			{ EGL_SAMPLE_BUFFERS,			"sample_buffers"			},
526			{ EGL_SAMPLES,					"samples"					},
527			{ EGL_STENCIL_SIZE,				"stencil_size"				},
528			{ EGL_SURFACE_TYPE,				"surface_type"				},
529			{ EGL_TRANSPARENT_TYPE,			"transparent_type"			},
530			{ EGL_TRANSPARENT_RED_VALUE,	"transparent_red_value"		},
531			{ EGL_TRANSPARENT_GREEN_VALUE,	"transparent_green_value"	},
532			{ EGL_TRANSPARENT_BLUE_VALUE,	"transparent_blue_value"	}
533		};
534
535		tcu::TestCaseGroup* simpleGroup = new tcu::TestCaseGroup(m_testCtx, "simple", "Simple tests");
536		addChild(simpleGroup);
537
538		tcu::TestCaseGroup* selectionGroup = new tcu::TestCaseGroup(m_testCtx, "selection_only", "Selection tests, order ignored");
539		simpleGroup->addChild(selectionGroup);
540
541		tcu::TestCaseGroup* sortGroup = new tcu::TestCaseGroup(m_testCtx, "selection_and_sort", "Selection and ordering tests");
542		simpleGroup->addChild(sortGroup);
543
544		for (int ndx = 0; ndx < (int)DE_LENGTH_OF_ARRAY(attributes); ndx++)
545		{
546			selectionGroup->addChild(new ChooseConfigSimpleCase(m_eglTestCtx, attributes[ndx].testName, "Simple config selection case", attributes[ndx].attribute, false));
547			sortGroup->addChild(new ChooseConfigSimpleCase(m_eglTestCtx, attributes[ndx].testName, "Simple config selection and sort case", attributes[ndx].attribute, true));
548		}
549	}
550
551	// Random
552	{
553		tcu::TestCaseGroup* randomGroup = new tcu::TestCaseGroup(m_testCtx, "random", "Random eglChooseConfig() usage");
554		addChild(randomGroup);
555
556		static const EGLenum rgbaSizes[] =
557		{
558			EGL_RED_SIZE,
559			EGL_GREEN_SIZE,
560			EGL_BLUE_SIZE,
561			EGL_ALPHA_SIZE
562		};
563		randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "color_sizes", "Random color size rules", toSet(rgbaSizes)));
564
565		static const EGLenum colorDepthStencilSizes[] =
566		{
567			EGL_RED_SIZE,
568			EGL_GREEN_SIZE,
569			EGL_BLUE_SIZE,
570			EGL_ALPHA_SIZE,
571			EGL_DEPTH_SIZE,
572			EGL_STENCIL_SIZE
573		};
574		randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "color_depth_stencil_sizes", "Random color, depth and stencil size rules", toSet(colorDepthStencilSizes)));
575
576		static const EGLenum bufferSizes[] =
577		{
578			EGL_BUFFER_SIZE,
579			EGL_LUMINANCE_SIZE,
580			EGL_ALPHA_MASK_SIZE,
581			EGL_DEPTH_SIZE,
582			EGL_STENCIL_SIZE
583		};
584		randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "buffer_sizes", "Various buffer size rules", toSet(bufferSizes)));
585
586		static const EGLenum surfaceType[] =
587		{
588			EGL_NATIVE_RENDERABLE,
589			EGL_SURFACE_TYPE
590		};
591		randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "surface_type", "Surface type rules", toSet(surfaceType)));
592
593		static const EGLenum sampleBuffers[] =
594		{
595			EGL_SAMPLE_BUFFERS,
596			EGL_SAMPLES
597		};
598		randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "sample_buffers", "Sample buffer rules", toSet(sampleBuffers)));
599
600		// \note Not every attribute is supported at the moment
601		static const EGLenum allAttribs[] =
602		{
603			EGL_BUFFER_SIZE,
604			EGL_RED_SIZE,
605			EGL_GREEN_SIZE,
606			EGL_BLUE_SIZE,
607			EGL_ALPHA_SIZE,
608			EGL_ALPHA_MASK_SIZE,
609			EGL_BIND_TO_TEXTURE_RGB,
610			EGL_BIND_TO_TEXTURE_RGBA,
611			EGL_COLOR_BUFFER_TYPE,
612			EGL_CONFIG_CAVEAT,
613			EGL_CONFIG_ID,
614			EGL_CONFORMANT,
615			EGL_DEPTH_SIZE,
616			EGL_LEVEL,
617//			EGL_MATCH_NATIVE_PIXMAP,
618			EGL_MAX_SWAP_INTERVAL,
619			EGL_MIN_SWAP_INTERVAL,
620			EGL_NATIVE_RENDERABLE,
621			EGL_NATIVE_VISUAL_TYPE,
622			EGL_RENDERABLE_TYPE,
623			EGL_SAMPLE_BUFFERS,
624			EGL_SAMPLES,
625			EGL_STENCIL_SIZE,
626			EGL_SURFACE_TYPE,
627			EGL_TRANSPARENT_TYPE,
628//			EGL_TRANSPARENT_RED_VALUE,
629//			EGL_TRANSPARENT_GREEN_VALUE,
630//			EGL_TRANSPARENT_BLUE_VALUE
631		};
632		randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "all", "All attributes", toSet(allAttribs)));
633	}
634}
635
636} // egl
637} // deqp
638