Merge "Remove BAD_NATIVE error checks from negative EGL tests."
diff --git a/framework/common/tcuMaybe.hpp b/framework/common/tcuMaybe.hpp
index 29f39f8..e1dd994 100644
--- a/framework/common/tcuMaybe.hpp
+++ b/framework/common/tcuMaybe.hpp
@@ -47,7 +47,7 @@
 	const T&	operator*		(void) const { return get(); }
 
 	const T*	operator->		(void) const;
-				operator bool	(void) const { return m_ptr; }
+				operator bool	(void) const { return !!m_ptr; }
 
 private:
 	T*				m_ptr;
diff --git a/framework/egl/egluGLContextFactory.cpp b/framework/egl/egluGLContextFactory.cpp
index 5885381..29cc642 100644
--- a/framework/egl/egluGLContextFactory.cpp
+++ b/framework/egl/egluGLContextFactory.cpp
@@ -557,18 +557,30 @@
 
 glu::RenderContext* GLContextFactory::createContext (const glu::RenderConfig& config, const tcu::CommandLine& cmdLine) const
 {
-	const NativeDisplayFactory* displayFactory = selectNativeDisplayFactory(m_displayFactoryRegistry, cmdLine);
+	const NativeDisplayFactory& displayFactory = selectNativeDisplayFactory(m_displayFactoryRegistry, cmdLine);
 
-	if (displayFactory)
+	const NativeWindowFactory*	windowFactory;
+	const NativePixmapFactory*	pixmapFactory;
+
+	try
 	{
-		// \note windowFactory & pixmapFactory are not mandatory
-		const NativeWindowFactory*	windowFactory	= selectNativeWindowFactory(*displayFactory, cmdLine);
-		const NativePixmapFactory*	pixmapFactory	= selectNativePixmapFactory(*displayFactory, cmdLine);
-
-		return new RenderContext(displayFactory, windowFactory, pixmapFactory, config);
+		windowFactory = &selectNativeWindowFactory(displayFactory, cmdLine);
 	}
-	else
-		TCU_THROW(NotSupportedError, "No EGL displays available");
+	catch (const tcu::NotSupportedError&)
+	{
+		windowFactory = DE_NULL;
+	}
+
+	try
+	{
+		pixmapFactory = &selectNativePixmapFactory(displayFactory, cmdLine);
+	}
+	catch (const tcu::NotSupportedError&)
+	{
+		pixmapFactory = DE_NULL;
+	}
+
+	return new RenderContext(&displayFactory, windowFactory, pixmapFactory, config);
 }
 
 } // eglu
diff --git a/framework/egl/egluUtil.cpp b/framework/egl/egluUtil.cpp
index d1cb1be..da126cc 100644
--- a/framework/egl/egluUtil.cpp
+++ b/framework/egl/egluUtil.cpp
@@ -438,14 +438,14 @@
 }
 
 template<typename Factory>
-static const Factory* selectFactory (const tcu::FactoryRegistry<Factory>& registry, const char* objectTypeName, const char* cmdLineArg)
+static const Factory& selectFactory (const tcu::FactoryRegistry<Factory>& registry, const char* objectTypeName, const char* cmdLineArg)
 {
 	if (cmdLineArg)
 	{
 		const Factory* factory = registry.getFactoryByName(cmdLineArg);
 
 		if (factory)
-			return factory;
+			return *factory;
 		else
 		{
 			tcu::print("ERROR: Unknown or unsupported EGL %s type '%s'", objectTypeName, cmdLineArg);
@@ -457,22 +457,22 @@
 		}
 	}
 	else if (!registry.empty())
-		return registry.getDefaultFactory();
+		return *registry.getDefaultFactory();
 	else
-		return DE_NULL;
+		TCU_THROW(NotSupportedError, (string("No factory supporting EGL '") + objectTypeName + "' type").c_str());
 }
 
-const NativeDisplayFactory* selectNativeDisplayFactory (const NativeDisplayFactoryRegistry& registry, const tcu::CommandLine& cmdLine)
+const NativeDisplayFactory& selectNativeDisplayFactory (const NativeDisplayFactoryRegistry& registry, const tcu::CommandLine& cmdLine)
 {
 	return selectFactory(registry, "display", cmdLine.getEGLDisplayType());
 }
 
-const NativeWindowFactory* selectNativeWindowFactory (const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine)
+const NativeWindowFactory& selectNativeWindowFactory (const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine)
 {
 	return selectFactory(factory.getNativeWindowRegistry(), "window", cmdLine.getEGLWindowType());
 }
 
-const NativePixmapFactory* selectNativePixmapFactory (const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine)
+const NativePixmapFactory& selectNativePixmapFactory (const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine)
 {
 	return selectFactory(factory.getNativePixmapRegistry(), "pixmap", cmdLine.getEGLPixmapType());
 }
diff --git a/framework/egl/egluUtil.hpp b/framework/egl/egluUtil.hpp
index 3d56c77..8c5dd3d 100644
--- a/framework/egl/egluUtil.hpp
+++ b/framework/egl/egluUtil.hpp
@@ -80,9 +80,9 @@
 eglw::EGLSurface				createWindowSurface			(NativeDisplay& nativeDisplay, NativeWindow& window, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList);
 eglw::EGLSurface				createPixmapSurface			(NativeDisplay& nativeDisplay, NativePixmap& pixmap, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList);
 
-const NativeDisplayFactory*		selectNativeDisplayFactory	(const NativeDisplayFactoryRegistry& registry, const tcu::CommandLine& cmdLine);
-const NativeWindowFactory*		selectNativeWindowFactory	(const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine);
-const NativePixmapFactory*		selectNativePixmapFactory	(const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine);
+const NativeDisplayFactory&		selectNativeDisplayFactory	(const NativeDisplayFactoryRegistry& registry, const tcu::CommandLine& cmdLine);
+const NativeWindowFactory&		selectNativeWindowFactory	(const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine);
+const NativePixmapFactory&		selectNativePixmapFactory	(const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine);
 
 WindowParams::Visibility		parseWindowVisibility		(const tcu::CommandLine& commandLine);
 eglw::EGLenum					parseClientAPI				(const std::string& api);
diff --git a/modules/egl/teglCreateContextExtTests.cpp b/modules/egl/teglCreateContextExtTests.cpp
index fdd6f09..31cceaa 100644
--- a/modules/egl/teglCreateContextExtTests.cpp
+++ b/modules/egl/teglCreateContextExtTests.cpp
@@ -920,24 +920,18 @@
 		}
 		else if ((surfaceTypes & EGL_WINDOW_BIT) != 0)
 		{
-			const eglu::NativeWindowFactory*	factory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+			const eglu::NativeWindowFactory&	factory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
-			if (!factory)
-				TCU_THROW(NotSupportedError, "Windows not supported");
-
-			de::UniquePtr<eglu::NativeWindow>	window	(factory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
+			de::UniquePtr<eglu::NativeWindow>	window	(factory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
 			eglu::UniqueSurface					surface	(egl, m_display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, config, DE_NULL));
 
 			executeForSurface(config, *surface);
 		}
 		else if ((surfaceTypes & EGL_PIXMAP_BIT) != 0)
 		{
-			const eglu::NativePixmapFactory*	factory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+			const eglu::NativePixmapFactory&	factory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
-			if (!factory)
-				TCU_THROW(NotSupportedError, "Pixmaps not supported");
-
-			de::UniquePtr<eglu::NativePixmap>	pixmap	(factory->createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, config, DE_NULL, 256, 256));
+			de::UniquePtr<eglu::NativePixmap>	pixmap	(factory.createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, config, DE_NULL, 256, 256));
 			eglu::UniqueSurface					surface	(egl, m_display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_display, config, DE_NULL));
 
 			executeForSurface(config, *surface);
diff --git a/modules/egl/teglCreateSurfaceTests.cpp b/modules/egl/teglCreateSurfaceTests.cpp
index 1cbac4e..49c2381 100644
--- a/modules/egl/teglCreateSurfaceTests.cpp
+++ b/modules/egl/teglCreateSurfaceTests.cpp
@@ -118,21 +118,18 @@
 		const Library&						egl				= m_eglTestCtx.getLibrary();
 		TestLog&							log				= m_testCtx.getLog();
 		EGLint								id				= eglu::getConfigID(egl, display, config);
-		const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
-
-		if (!windowFactory)
-			TCU_THROW(NotSupportedError, "Windows not supported");
+		const eglu::NativeWindowFactory&	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
 		// \todo [2011-03-23 pyry] Iterate thru all possible combinations of EGL_RENDER_BUFFER, EGL_VG_COLORSPACE and EGL_VG_ALPHA_FORMAT
 
 		if (m_useLegacyCreate)
 		{
-			if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
+			if ((windowFactory.getCapabilities() & eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
 				TCU_THROW(NotSupportedError, "Native window doesn't support legacy eglCreateWindowSurface()");
 		}
 		else
 		{
-			if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_PLATFORM) == 0)
+			if ((windowFactory.getCapabilities() & eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_PLATFORM) == 0)
 				TCU_THROW(NotSupportedError, "Native window doesn't support eglCreatePlatformWindowSurfaceEXT()");
 		}
 
@@ -142,7 +139,7 @@
 		{
 			const int							width			= 64;
 			const int							height			= 64;
-			de::UniquePtr<eglu::NativeWindow>	window			(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
+			de::UniquePtr<eglu::NativeWindow>	window			(windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
 			eglu::UniqueSurface					surface			(egl, display, createWindowSurface(display, config, m_eglTestCtx.getNativeDisplay(), *window, m_useLegacyCreate));
 
 			EGLint								windowWidth		= 0;
@@ -179,21 +176,18 @@
 		const Library&						egl				= m_eglTestCtx.getLibrary();
 		TestLog&							log				= m_testCtx.getLog();
 		EGLint								id				= eglu::getConfigID(egl, display, config);
-		const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
-
-		if (!pixmapFactory)
-			TCU_THROW(NotSupportedError, "Pixmaps not supported");
+		const eglu::NativePixmapFactory&	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
 		// \todo [2011-03-23 pyry] Iterate thru all possible combinations of EGL_RENDER_BUFFER, EGL_VG_COLORSPACE and EGL_VG_ALPHA_FORMAT
 
 		if (m_useLegacyCreate)
 		{
-			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
+			if ((pixmapFactory.getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
 				TCU_THROW(NotSupportedError, "Native pixmap doesn't support legacy eglCreatePixmapSurface()");
 		}
 		else
 		{
-			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_PLATFORM) == 0)
+			if ((pixmapFactory.getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_PLATFORM) == 0)
 				TCU_THROW(NotSupportedError, "Native pixmap doesn't support eglCreatePlatformPixmapSurfaceEXT()");
 		}
 
@@ -203,7 +197,7 @@
 		{
 			const int							width			= 64;
 			const int							height			= 64;
-			de::UniquePtr<eglu::NativePixmap>	pixmap			(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
+			de::UniquePtr<eglu::NativePixmap>	pixmap			(pixmapFactory.createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
 			eglu::UniqueSurface					surface			(egl, display, createPixmapSurface(display, config, m_eglTestCtx.getNativeDisplay(), *pixmap, m_useLegacyCreate));
 			EGLint								pixmapWidth		= 0;
 			EGLint								pixmapHeight	= 0;
diff --git a/modules/egl/teglGLES2SharingTests.cpp b/modules/egl/teglGLES2SharingTests.cpp
index e073410..cde391d 100644
--- a/modules/egl/teglGLES2SharingTests.cpp
+++ b/modules/egl/teglGLES2SharingTests.cpp
@@ -149,15 +149,12 @@
 	const Library&						egl				= m_eglTestCtx.getLibrary();
 	tcu::TestLog&						log				= m_testCtx.getLog();
 	eglu::UniqueDisplay					display			(egl, eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay()));
-	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	const eglu::NativeWindowFactory&	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 	EGLConfig							config;
 	bool								isOk			= true;
 	EGLContext							contextA		= EGL_NO_CONTEXT;
 	EGLContext							contextB		= EGL_NO_CONTEXT;
 
-	if (!windowFactory)
-		TCU_THROW(NotSupportedError, "Windows not supported");
-
 	{
 		const EGLint attribList[] =
 		{
@@ -172,7 +169,7 @@
 
 	try
 	{
-		de::UniquePtr<eglu::NativeWindow>	window	(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), *display, config, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
+		de::UniquePtr<eglu::NativeWindow>	window	(windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), *display, config, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
 		eglu::UniqueSurface					surface	(egl, *display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, *display, config, DE_NULL));
 
 		m_log << tcu::TestLog::Message << "Create context A (share_context = EGL_NO_CONTEXT)" << tcu::TestLog::EndMessage;
diff --git a/modules/egl/teglImageFormatTests.cpp b/modules/egl/teglImageFormatTests.cpp
index 0a5b423..62df0ce 100644
--- a/modules/egl/teglImageFormatTests.cpp
+++ b/modules/egl/teglImageFormatTests.cpp
@@ -801,16 +801,13 @@
 void ImageFormatCase::init (void)
 {
 	const Library&						egl				= m_eglTestCtx.getLibrary();
-	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
-
-	if (!windowFactory)
-		TCU_THROW(NotSupportedError, "Windows not supported");
+	const eglu::NativeWindowFactory&	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
 	try
 	{
 		m_display	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
 		m_config	= getConfig();
-		m_window	= windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
+		m_window	= windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
 		m_surface	= eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_window, m_display, m_config, DE_NULL);
 
 		{
diff --git a/modules/egl/teglImageUtil.cpp b/modules/egl/teglImageUtil.cpp
index d47b3ba..f4b5dbf 100644
--- a/modules/egl/teglImageUtil.cpp
+++ b/modules/egl/teglImageUtil.cpp
@@ -112,31 +112,21 @@
 	}
 	else if (surfaceTypeBits & EGL_WINDOW_BIT)
 	{
-		const NativeWindowFactory*	windowFactory	= selectNativeWindowFactory(displayFactory, eglTestCtx.getTestContext().getCommandLine());
+		const NativeWindowFactory&	windowFactory	= selectNativeWindowFactory(displayFactory, eglTestCtx.getTestContext().getCommandLine());
 
-		if (windowFactory)
-		{
-			MovePtr<NativeWindow>	window	(windowFactory->createWindow(&nativeDisplay, dpy, config, DE_NULL, WindowParams(width, height, WindowParams::VISIBILITY_DONT_CARE)));
-			const EGLSurface		surface	= eglu::createWindowSurface(nativeDisplay, *window, dpy, config, DE_NULL);
+		MovePtr<NativeWindow>		window	(windowFactory.createWindow(&nativeDisplay, dpy, config, DE_NULL, WindowParams(width, height, WindowParams::VISIBILITY_DONT_CARE)));
+		const EGLSurface			surface	= eglu::createWindowSurface(nativeDisplay, *window, dpy, config, DE_NULL);
 
-			return MovePtr<ManagedSurface>(new NativeWindowSurface(MovePtr<UniqueSurface>(new UniqueSurface(egl, dpy, surface)), window));
-		}
-		else
-			TCU_THROW(NotSupportedError, "Windows not supported");
+		return MovePtr<ManagedSurface>(new NativeWindowSurface(MovePtr<UniqueSurface>(new UniqueSurface(egl, dpy, surface)), window));
 	}
 	else if (surfaceTypeBits & EGL_PIXMAP_BIT)
 	{
-		const NativePixmapFactory*	pixmapFactory	= selectNativePixmapFactory(displayFactory, eglTestCtx.getTestContext().getCommandLine());
+		const NativePixmapFactory&	pixmapFactory	= selectNativePixmapFactory(displayFactory, eglTestCtx.getTestContext().getCommandLine());
 
-		if (pixmapFactory)
-		{
-			MovePtr<NativePixmap>	pixmap	(pixmapFactory->createPixmap(&nativeDisplay, dpy, config, DE_NULL, width, height));
-			const EGLSurface		surface	= eglu::createPixmapSurface(eglTestCtx.getNativeDisplay(), *pixmap, dpy, config, DE_NULL);
+		MovePtr<NativePixmap>	pixmap	(pixmapFactory.createPixmap(&nativeDisplay, dpy, config, DE_NULL, width, height));
+		const EGLSurface		surface	= eglu::createPixmapSurface(eglTestCtx.getNativeDisplay(), *pixmap, dpy, config, DE_NULL);
 
-			return MovePtr<ManagedSurface>(new NativePixmapSurface(MovePtr<UniqueSurface>(new UniqueSurface(egl, dpy, surface)), pixmap));
-		}
-		else
-			TCU_THROW(NotSupportedError, "Pixmaps not supported");
+		return MovePtr<ManagedSurface>(new NativePixmapSurface(MovePtr<UniqueSurface>(new UniqueSurface(egl, dpy, surface)), pixmap));
 	}
 	else
 		TCU_FAIL("No valid surface types supported in config");
diff --git a/modules/egl/teglMakeCurrentPerfTests.cpp b/modules/egl/teglMakeCurrentPerfTests.cpp
index 161069e..dd822f3 100644
--- a/modules/egl/teglMakeCurrentPerfTests.cpp
+++ b/modules/egl/teglMakeCurrentPerfTests.cpp
@@ -272,17 +272,14 @@
 	const EGLint						width			= 256;
 	const EGLint						height			= 256;
 
-	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	const eglu::NativeWindowFactory&	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
 	eglu::NativeWindow* 				window			= DE_NULL;
 	EGLSurface							surface			= EGL_NO_SURFACE;
 
-	if (!windowFactory)
-		TCU_THROW(NotSupportedError, "Windows not supported");
-
 	try
 	{
-		window	= windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_eglTestCtx.getTestContext().getCommandLine())));
+		window	= windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_eglTestCtx.getTestContext().getCommandLine())));
 		surface	= eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, m_config, DE_NULL);
 	}
 	catch (...)
@@ -304,17 +301,14 @@
 	const EGLint						width			= 256;
 	const EGLint						height			= 256;
 
-	const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	const eglu::NativePixmapFactory&	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
 	eglu::NativePixmap* 				pixmap			= DE_NULL;
 	EGLSurface							surface			= EGL_NO_SURFACE;
 
-	if (!pixmapFactory)
-		TCU_THROW(NotSupportedError, "Pixmaps not supported");
-
 	try
 	{
-		pixmap	= pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, width, height);
+		pixmap	= pixmapFactory.createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, width, height);
 		surface	= eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_display, m_config, DE_NULL);
 	}
 	catch (...)
diff --git a/modules/egl/teglMultiThreadTests.cpp b/modules/egl/teglMultiThreadTests.cpp
index 19201c7..e73e3d6 100644
--- a/modules/egl/teglMultiThreadTests.cpp
+++ b/modules/egl/teglMultiThreadTests.cpp
@@ -1093,10 +1093,7 @@
 
 				case TYPE_WINDOW:
 				{
-					const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
-
-					if (!windowFactory)
-						TCU_THROW(NotSupportedError, "Windows not supported");
+					const eglu::NativeWindowFactory&	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
 					if ((m_types & TYPE_SINGLE_WINDOW) != 0)
 					{
@@ -1107,7 +1104,7 @@
 
 							try
 							{
-								window = windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
+								window = windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
 								surface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, m_config, DE_NULL);
 
 								thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreateWindowSurface()" << ThreadLog::EndMessage;
@@ -1134,7 +1131,7 @@
 
 						try
 						{
-							window	= windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
+							window	= windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
 							surface	= eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, m_config, DE_NULL);
 
 							thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreateWindowSurface()" << ThreadLog::EndMessage;
@@ -1153,13 +1150,13 @@
 
 				case TYPE_PIXMAP:
 				{
-					const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+					const eglu::NativePixmapFactory&	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 					eglu::NativePixmap* 				pixmap			= DE_NULL;
 					EGLSurface							surface			= EGL_NO_SURFACE;
 
 					try
 					{
-						pixmap	= pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, 64, 64);
+						pixmap	= pixmapFactory.createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, 64, 64);
 						surface	= eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_display, m_config, DE_NULL);
 
 						thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreatePixmapSurface()" << ThreadLog::EndMessage;
diff --git a/modules/egl/teglNativeColorMappingTests.cpp b/modules/egl/teglNativeColorMappingTests.cpp
index 8d625a0..415a732 100644
--- a/modules/egl/teglNativeColorMappingTests.cpp
+++ b/modules/egl/teglNativeColorMappingTests.cpp
@@ -445,49 +445,6 @@
 	return isOk;
 }
 
-void checkSupport (NativeColorMappingCase::NativeType nativeType, const eglu::NativeWindowFactory* windowFactory, const eglu::NativePixmapFactory* pixmapFactory)
-{
-	switch (nativeType)
-	{
-		case NativeColorMappingCase::NATIVETYPE_WINDOW:
-		{
-			if (!windowFactory)
-				TCU_THROW(NotSupportedError, "Windows not supported");
-
-			if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
-				TCU_THROW(NotSupportedError, "Native window doesn't support readPixels()");
-
-			break;
-		}
-
-		case NativeColorMappingCase::NATIVETYPE_PIXMAP:
-		{
-			if (!pixmapFactory)
-				TCU_THROW(NotSupportedError, "Pixmaps not supported");
-
-			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0)
-				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels()");
-
-			break;
-		}
-
-		case NativeColorMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP:
-		{
-			if (!pixmapFactory)
-				TCU_THROW(NotSupportedError, "Pixmaps not supported");
-
-			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0 ||
-				(pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
-				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels() or legacy create surface");
-
-			break;
-		}
-
-		default:
-			DE_ASSERT(DE_FALSE);
-	}
-}
-
 void NativeColorMappingCase::executeForConfig (EGLDisplay display, EGLConfig config)
 {
 	const int width		= 128;
@@ -518,12 +475,52 @@
 	const string						configIdStr		(de::toString(eglu::getConfigAttribInt(egl, display, config, EGL_CONFIG_ID)));
 	tcu::ScopedLogSection				logSection		(m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str());
 	const int							waitFrames		= 5;
-	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
-	const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	const eglu::NativeWindowFactory*	windowFactory;
+	const eglu::NativePixmapFactory*	pixmapFactory;
 
 	logConfigInfo(m_testCtx.getLog(), egl, display, config, m_nativeType, waitFrames);
 
-	checkSupport(m_nativeType, windowFactory, pixmapFactory);
+	try
+	{
+		windowFactory = &eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+		if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
+			TCU_THROW(NotSupportedError, "Native window doesn't support readPixels()");
+	}
+	catch (const tcu::NotSupportedError&)
+	{
+		if (m_nativeType == NATIVETYPE_WINDOW)
+			throw;
+		else
+			windowFactory = DE_NULL;
+	}
+
+	try
+	{
+		pixmapFactory = &eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+		if (m_nativeType == NATIVETYPE_PIXMAP)
+		{
+			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0)
+				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels()");
+		}
+		else if (m_nativeType == NATIVETYPE_PBUFFER_COPY_TO_PIXMAP)
+		{
+			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0 ||
+				(pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
+				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels() or legacy create surface");
+		}
+	}
+	catch (const tcu::NotSupportedError&)
+	{
+		if (m_nativeType == NATIVETYPE_PIXMAP || m_nativeType == NATIVETYPE_PBUFFER_COPY_TO_PIXMAP)
+			throw;
+		else
+			pixmapFactory = DE_NULL;
+	}
+
+	DE_ASSERT(m_nativeType != NATIVETYPE_WINDOW || windowFactory);
+	DE_ASSERT((m_nativeType != NATIVETYPE_PIXMAP && m_nativeType != NATIVETYPE_PBUFFER_COPY_TO_PIXMAP) || pixmapFactory);
 
 	eglu::UniqueContext 	context		(egl, display, createGLES2Context(egl, display, config));
 	glw::Functions			gl;
diff --git a/modules/egl/teglNativeCoordMappingTests.cpp b/modules/egl/teglNativeCoordMappingTests.cpp
index 90b38d4..c704665 100644
--- a/modules/egl/teglNativeCoordMappingTests.cpp
+++ b/modules/egl/teglNativeCoordMappingTests.cpp
@@ -500,49 +500,6 @@
 	return isOk;
 }
 
-void checkSupport (NativeCoordMappingCase::NativeType nativeType, const eglu::NativeWindowFactory* windowFactory, const eglu::NativePixmapFactory* pixmapFactory)
-{
-	switch (nativeType)
-	{
-		case NativeCoordMappingCase::NATIVETYPE_WINDOW:
-		{
-			if (!windowFactory)
-				TCU_THROW(NotSupportedError, "Windows not supported");
-
-			if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
-				TCU_THROW(NotSupportedError, "Native window doesn't support readPixels()");
-
-			break;
-		}
-
-		case NativeCoordMappingCase::NATIVETYPE_PIXMAP:
-		{
-			if (!pixmapFactory)
-				TCU_THROW(NotSupportedError, "Pixmaps not supported");
-
-			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0)
-				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels()");
-
-			break;
-		}
-
-		case NativeCoordMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP:
-		{
-			if (!pixmapFactory)
-				TCU_THROW(NotSupportedError, "Pixmaps not supported");
-
-			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0 ||
-				(pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
-				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels() or legacy create surface");
-
-			break;
-		}
-
-		default:
-			DE_ASSERT(DE_FALSE);
-	}
-}
-
 void NativeCoordMappingCase::executeForConfig (EGLDisplay display, EGLConfig config)
 {
 	const Library&						egl				= m_eglTestCtx.getLibrary();
@@ -551,12 +508,52 @@
 	const int							waitFrames		= 5;
 	const int							width			= 128;
 	const int							height			= 128;
-	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
-	const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	const eglu::NativeWindowFactory*	windowFactory;
+	const eglu::NativePixmapFactory*	pixmapFactory;
 
 	logConfigInfo(m_testCtx.getLog(), egl, display, config, m_nativeType, waitFrames);
 
-	checkSupport(m_nativeType, windowFactory, pixmapFactory);
+	try
+	{
+		windowFactory = &eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+		if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
+			TCU_THROW(NotSupportedError, "Native window doesn't support readPixels()");
+	}
+	catch (const tcu::NotSupportedError&)
+	{
+		if (m_nativeType == NATIVETYPE_WINDOW)
+			throw;
+		else
+			windowFactory = DE_NULL;
+	}
+
+	try
+	{
+		pixmapFactory = &eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+		if (m_nativeType == NATIVETYPE_PIXMAP)
+		{
+			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0)
+				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels()");
+		}
+		else if (m_nativeType == NATIVETYPE_PBUFFER_COPY_TO_PIXMAP)
+		{
+			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0 ||
+				(pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
+				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels() or legacy create surface");
+		}
+	}
+	catch (const tcu::NotSupportedError&)
+	{
+		if (m_nativeType == NATIVETYPE_PIXMAP || m_nativeType == NATIVETYPE_PBUFFER_COPY_TO_PIXMAP)
+			throw;
+		else
+			pixmapFactory = DE_NULL;
+	}
+
+	DE_ASSERT(m_nativeType != NATIVETYPE_WINDOW || windowFactory);
+	DE_ASSERT((m_nativeType != NATIVETYPE_PIXMAP && m_nativeType != NATIVETYPE_PBUFFER_COPY_TO_PIXMAP) || pixmapFactory);
 
 	eglu::UniqueContext 	context		(egl, display, createGLES2Context(egl, display, config));
 	glw::Functions			gl;
diff --git a/modules/egl/teglPreservingSwapTests.cpp b/modules/egl/teglPreservingSwapTests.cpp
index 11a377b..4e3e384 100644
--- a/modules/egl/teglPreservingSwapTests.cpp
+++ b/modules/egl/teglPreservingSwapTests.cpp
@@ -328,12 +328,9 @@
 
 void PreservingSwapTest::initEGLSurface (EGLConfig config)
 {
-	const eglu::NativeWindowFactory*	factory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	const eglu::NativeWindowFactory&	factory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
-	if (!factory)
-		TCU_THROW(NotSupportedError, "Windows not supported");
-
-	m_window		= factory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_eglDisplay, config, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
+	m_window		= factory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_eglDisplay, config, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
 	m_eglSurface	= eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_window, m_eglDisplay, config, DE_NULL);
 }
 
diff --git a/modules/egl/teglQuerySurfaceTests.cpp b/modules/egl/teglQuerySurfaceTests.cpp
index 3db27f5..be44395 100644
--- a/modules/egl/teglQuerySurfaceTests.cpp
+++ b/modules/egl/teglQuerySurfaceTests.cpp
@@ -306,18 +306,15 @@
 		tcu::TestLog&						log				= m_testCtx.getLog();
 		const int							width			= 64;
 		const int							height			= 64;
-		const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+		const eglu::NativeWindowFactory&	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 		ConfigInfo							info;
 
-		if (!windowFactory)
-			TCU_THROW(NotSupportedError, "Windows not supported");
-
 		eglu::queryConfigInfo(egl, display, config, &info);
 
 		log << TestLog::Message << "Creating window surface with config ID " << info.configId << TestLog::EndMessage;
 		EGLU_CHECK_MSG(egl, "before queries");
 
-		de::UniquePtr<eglu::NativeWindow>	window	(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
+		de::UniquePtr<eglu::NativeWindow>	window	(windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
 		eglu::UniqueSurface					surface	(egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
 
 		logCommonSurfaceAttributes	(log, egl, display, *surface);
@@ -340,18 +337,15 @@
 		tcu::TestLog&						log				= m_testCtx.getLog();
 		const int							width			= 64;
 		const int							height			= 64;
-		const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+		const eglu::NativePixmapFactory&	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 		ConfigInfo							info;
 
-		if (!pixmapFactory)
-			TCU_THROW(NotSupportedError, "Pixmaps not supported");
-
 		eglu::queryConfigInfo(egl, display, config, &info);
 
 		log << TestLog::Message << "Creating pixmap surface with config ID " << info.configId << TestLog::EndMessage;
 		EGLU_CHECK_MSG(egl, "before queries");
 
-		de::UniquePtr<eglu::NativePixmap>	pixmap	(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
+		de::UniquePtr<eglu::NativePixmap>	pixmap	(pixmapFactory.createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
 		eglu::UniqueSurface					surface	(egl, display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, display, config, DE_NULL));
 
 		logCommonSurfaceAttributes	(log, egl, display, *surface);
@@ -585,18 +579,15 @@
 		tcu::TestLog&						log				= m_testCtx.getLog();
 		const int							width			= 64;
 		const int							height			= 64;
-		const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+		const eglu::NativeWindowFactory&	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 		ConfigInfo							info;
 
-		if (!windowFactory)
-			TCU_THROW(NotSupportedError, "Windows not supported");
-
 		eglu::queryConfigInfo(egl, display, config, &info);
 
 		log << TestLog::Message << "Creating window surface with config ID " << info.configId << TestLog::EndMessage;
 		EGLU_CHECK_MSG(egl, "before queries");
 
-		de::UniquePtr<eglu::NativeWindow>	window	(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
+		de::UniquePtr<eglu::NativeWindow>	window	(windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
 		eglu::UniqueSurface					surface	(egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
 
 		testAttributes(display, *surface, EGL_WINDOW_BIT, info);
@@ -617,18 +608,15 @@
 		tcu::TestLog&						log				= m_testCtx.getLog();
 		const int							width			= 64;
 		const int							height			= 64;
-		const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+		const eglu::NativePixmapFactory&	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 		ConfigInfo							info;
 
-		if (!pixmapFactory)
-			TCU_THROW(NotSupportedError, "Pixmaps not supported");
-
 		eglu::queryConfigInfo(egl, display, config, &info);
 
 		log << TestLog::Message << "Creating pixmap surface with config ID " << info.configId << TestLog::EndMessage;
 		EGLU_CHECK_MSG(egl, "before queries");
 
-		de::UniquePtr<eglu::NativePixmap>	pixmap	(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
+		de::UniquePtr<eglu::NativePixmap>	pixmap	(pixmapFactory.createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
 		eglu::UniqueSurface					surface	(egl, display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, display, config, DE_NULL));
 
 		testAttributes(display, *surface, EGL_PIXMAP_BIT, info);
diff --git a/modules/egl/teglRenderCase.cpp b/modules/egl/teglRenderCase.cpp
index 01fd576..b2c81a0 100644
--- a/modules/egl/teglRenderCase.cpp
+++ b/modules/egl/teglRenderCase.cpp
@@ -130,15 +130,12 @@
 							  string("Config") + de::toString(configId) + "-Window",
 							  string("Config ID ") + de::toString(configId) + ", window surface");
 
-		const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(displayFactory, m_testCtx.getCommandLine());
-
-		if (!windowFactory)
-			TCU_THROW(NotSupportedError, "Windows not supported");
+		const eglu::NativeWindowFactory&	windowFactory	= eglu::selectNativeWindowFactory(displayFactory, m_testCtx.getCommandLine());
 
 		try
 		{
 			const eglu::WindowParams			params		(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()));
-			de::UniquePtr<eglu::NativeWindow>	window		(windowFactory->createWindow(&nativeDisplay, display, config, DE_NULL, params));
+			de::UniquePtr<eglu::NativeWindow>	window		(windowFactory.createWindow(&nativeDisplay, display, config, DE_NULL, params));
 			EGLSurface							eglSurface	= createWindowSurface(nativeDisplay, *window, display, config, DE_NULL);
 			eglu::UniqueSurface					surface		(egl, display, eglSurface);
 
@@ -158,14 +155,11 @@
 							  string("Config") + de::toString(configId) + "-Pixmap",
 							  string("Config ID ") + de::toString(configId) + ", pixmap surface");
 
-		const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(displayFactory, m_testCtx.getCommandLine());
-
-		if (!pixmapFactory)
-			TCU_THROW(NotSupportedError, "Windows not supported");
+		const eglu::NativePixmapFactory&	pixmapFactory	= eglu::selectNativePixmapFactory(displayFactory, m_testCtx.getCommandLine());
 
 		try
 		{
-			std::auto_ptr<eglu::NativePixmap>	pixmap		(pixmapFactory->createPixmap(&nativeDisplay, display, config, DE_NULL, width, height));
+			std::auto_ptr<eglu::NativePixmap>	pixmap		(pixmapFactory.createPixmap(&nativeDisplay, display, config, DE_NULL, width, height));
 			EGLSurface							eglSurface	= createPixmapSurface(nativeDisplay, *pixmap, display, config, DE_NULL);
 			eglu::UniqueSurface					surface		(egl, display, eglSurface);
 
diff --git a/modules/egl/teglResizeTests.cpp b/modules/egl/teglResizeTests.cpp
index 4e829a6..fd250e4 100644
--- a/modules/egl/teglResizeTests.cpp
+++ b/modules/egl/teglResizeTests.cpp
@@ -163,14 +163,11 @@
 																		   EGL_CONFIG_ID);
 	const Visibility			visibility		= eglu::parseWindowVisibility(cmdLine);
 	NativeDisplay&				nativeDisplay	= m_eglTestCtx.getNativeDisplay();
-	const NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(),
+	const NativeWindowFactory&	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(),
 																				  cmdLine);
 
-	if (!windowFactory)
-		TCU_THROW(NotSupportedError, "Windows not supported");
-
 	const WindowParams			windowParams	(m_oldSize.x(), m_oldSize.y(), visibility);
-	MovePtr<NativeWindow>		nativeWindow	(windowFactory->createWindow(&nativeDisplay,
+	MovePtr<NativeWindow>		nativeWindow	(windowFactory.createWindow(&nativeDisplay,
 																			 eglDisplay,
 																			 eglConfig,
 																			 DE_NULL,
diff --git a/modules/egl/teglSwapBuffersTests.cpp b/modules/egl/teglSwapBuffersTests.cpp
index 52243f4..525ce52 100644
--- a/modules/egl/teglSwapBuffersTests.cpp
+++ b/modules/egl/teglSwapBuffersTests.cpp
@@ -270,12 +270,9 @@
 	const string						configIdStr	(getConfigIdString(egl, display, config));
 	tcu::ScopedLogSection				logSection	(m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str());
 	const int							waitFrames	= 5;
-	const eglu::NativeWindowFactory*	factory		= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	const eglu::NativeWindowFactory&	factory		= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
-	if (!factory)
-		TCU_THROW(NotSupportedError, "Windows not supported");
-
-	if ((factory->getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
+	if ((factory.getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
 		TCU_THROW(NotSupportedError, "eglu::NativeWindow doesn't support readScreenPixels()");
 
 	{
@@ -292,7 +289,7 @@
 		log << TestLog::Message << "Waiting " << waitFrames * 16 << "ms after eglSwapBuffers() and glFinish() for frame to become visible" << TestLog::EndMessage;
 	}
 
-	de::UniquePtr<eglu::NativeWindow>	window	(factory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(128, 128, eglu::WindowParams::VISIBILITY_VISIBLE)));
+	de::UniquePtr<eglu::NativeWindow>	window	(factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(128, 128, eglu::WindowParams::VISIBILITY_VISIBLE)));
 
 	eglu::UniqueSurface					surface	(egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
 	eglu::UniqueContext					context	(egl, display, createGLES2Context(egl, display, config));
diff --git a/modules/egl/teglSyncTests.cpp b/modules/egl/teglSyncTests.cpp
index f3b24fc..d2df358 100644
--- a/modules/egl/teglSyncTests.cpp
+++ b/modules/egl/teglSyncTests.cpp
@@ -184,7 +184,7 @@
 void SyncTest::init (void)
 {
 	const Library&						egl				= m_eglTestCtx.getLibrary();
-	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	const eglu::NativeWindowFactory&	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
 	const EGLint displayAttribList[] =
 	{
@@ -200,9 +200,6 @@
 		EGL_NONE
 	};
 
-	if (!windowFactory)
-		TCU_THROW(NotSupportedError, "Windows not supported");
-
 	m_eglDisplay	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
 	m_eglConfig 	= eglu::chooseSingleConfig(egl, m_eglDisplay, displayAttribList);
 
@@ -217,7 +214,7 @@
 	EGLU_CHECK_MSG(egl, "Failed to create GLES2 context");
 
 	// Create surface
-	m_nativeWindow = windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_eglDisplay, m_eglConfig, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
+	m_nativeWindow = windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_eglDisplay, m_eglConfig, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
 	m_eglSurface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_nativeWindow, m_eglDisplay, m_eglConfig, DE_NULL);
 
 	EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
diff --git a/modules/egl/teglTestPackage.cpp b/modules/egl/teglTestPackage.cpp
index 461c137..1602778 100644
--- a/modules/egl/teglTestPackage.cpp
+++ b/modules/egl/teglTestPackage.cpp
@@ -153,12 +153,9 @@
 
 static const eglu::NativeDisplayFactory& getDefaultDisplayFactory (tcu::TestContext& testCtx)
 {
-	const eglu::NativeDisplayFactory* factory = eglu::selectNativeDisplayFactory(testCtx.getPlatform().getEGLPlatform().getNativeDisplayFactoryRegistry(), testCtx.getCommandLine());
+	const eglu::NativeDisplayFactory& factory = eglu::selectNativeDisplayFactory(testCtx.getPlatform().getEGLPlatform().getNativeDisplayFactoryRegistry(), testCtx.getCommandLine());
 
-	if (!factory)
-		TCU_THROW(InternalError, "No native display factories available");
-
-	return *factory;
+	return factory;
 }
 
 PackageContext::PackageContext (tcu::TestContext& testCtx)
diff --git a/modules/gles31/functional/es31fDrawBuffersIndexedTests.cpp b/modules/gles31/functional/es31fDrawBuffersIndexedTests.cpp
index f851c70..aecbe46 100644
--- a/modules/gles31/functional/es31fDrawBuffersIndexedTests.cpp
+++ b/modules/gles31/functional/es31fDrawBuffersIndexedTests.cpp
@@ -413,7 +413,7 @@
 		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to create renderbuffer.");
 	}
 
-	gl.drawBuffers(bufs.size(), &(bufs[0]));
+	gl.drawBuffers((glw::GLsizei)bufs.size(), &(bufs[0]));
 
 	for (int renderbufferNdx = 0; renderbufferNdx < (int)drawBuffers.size(); renderbufferNdx++)
 	{
@@ -995,7 +995,7 @@
 
 	setCommonBlendState(gl, postCommonBlendState);
 
-	gl.drawBuffers(bufs.size(), &(bufs[0]));
+	gl.drawBuffers((glw::GLsizei)bufs.size(), &(bufs[0]));
 
 	if (requiresBlendBarriers)
 		gl.blendBarrierKHR();
diff --git a/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.cpp b/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.cpp
index c77a4c5..e0efa0e 100644
--- a/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.cpp
+++ b/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.cpp
@@ -1414,8 +1414,8 @@
 				else if (shaderType == glu::SHADERTYPE_TESSELLATION_CONTROL)
 				{
 					resources.push_back("gl_PerVertex.gl_Position");
-					resources.push_back("gl_TessLevelOuter");
-					resources.push_back("gl_TessLevelInner");
+					resources.push_back("gl_TessLevelOuter[0]");
+					resources.push_back("gl_TessLevelInner[0]");
 				}
 				else if (shaderType == glu::SHADERTYPE_TESSELLATION_EVALUATION)
 					resources.push_back("gl_Position");
diff --git a/modules/gles31/functional/es31fProgramInterfaceQueryTestCase.cpp b/modules/gles31/functional/es31fProgramInterfaceQueryTestCase.cpp
index 604a94a..15c6431 100644
--- a/modules/gles31/functional/es31fProgramInterfaceQueryTestCase.cpp
+++ b/modules/gles31/functional/es31fProgramInterfaceQueryTestCase.cpp
@@ -410,8 +410,8 @@
 		{ "gl_InvocationID",			glu::TYPE_INT			},
 		{ "gl_NumWorkGroups",			glu::TYPE_UINT_VEC3		},
 		{ "gl_FragDepth",				glu::TYPE_FLOAT			},
-		{ "gl_TessLevelOuter",			glu::TYPE_FLOAT			},
-		{ "gl_TessLevelInner",			glu::TYPE_FLOAT			},
+		{ "gl_TessLevelOuter[0]",		glu::TYPE_FLOAT			},
+		{ "gl_TessLevelInner[0]",		glu::TYPE_FLOAT			},
 	};
 
 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(builtins); ++ndx)
@@ -489,8 +489,8 @@
 		{ "gl_InvocationID",			1	},
 		{ "gl_NumWorkGroups",			1	},
 		{ "gl_FragDepth",				1	},
-		{ "gl_TessLevelOuter",			4	},
-		{ "gl_TessLevelInner",			2	},
+		{ "gl_TessLevelOuter[0]",		4	},
+		{ "gl_TessLevelInner[0]",		2	},
 	};
 
 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(builtins); ++ndx)
@@ -1689,8 +1689,8 @@
 		{ "gl_Position",				0	},
 		{ "gl_PerVertex.gl_Position",	0	},
 		{ "gl_InvocationID",			0	},
-		{ "gl_TessLevelOuter",			1	},
-		{ "gl_TessLevelInner",			1	},
+		{ "gl_TessLevelOuter[0]",		1	},
+		{ "gl_TessLevelInner[0]",		1	},
 	};
 
 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(builtins); ++ndx)
diff --git a/modules/gles31/functional/es31fTextureGatherTests.cpp b/modules/gles31/functional/es31fTextureGatherTests.cpp
index 42316ac..f5a5540 100644
--- a/modules/gles31/functional/es31fTextureGatherTests.cpp
+++ b/modules/gles31/functional/es31fTextureGatherTests.cpp
@@ -2267,7 +2267,9 @@
 							}
 						}
 
-						if (!isDepthFormat(format)) // What shadow textures should return for incomplete textures is unclear.
+						// What shadow textures should return for incomplete textures is unclear.
+						// Integer and unsigned integer lookups from incomplete textures return undefined values.
+						if (!isDepthFormat(format) && !isSIntFormatType(format.type) && !isUIntFormatType(format.type))
 						{
 							TestCaseGroup* const incompleteGroup = new TestCaseGroup(m_context, "incomplete", "Test that textureGather* takes components from (0,0,0,1) for incomplete textures");
 							formatGroup->addChild(incompleteGroup);