#include "teglInfoTests.hpp"
#include "teglConfigList.hpp"
#include "tcuTestLog.hpp"
+#include "deStringUtil.hpp"
+#include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
#include <vector>
#include <string>
#include <sstream>
-#include <EGL/egl.h>
-
-using std::vector;
-using std::string;
-
-using tcu::TestLog;
-
namespace deqp
{
namespace egl
{
-static std::vector<std::string> split(const std::string& str, const std::string& delim = " ")
-{
- std::vector<std::string> out;
- if (str.length() == 0) return out;
-
- size_t start = 0;
- size_t end = string::npos;
-
- while ((end = str.find(delim, start)) != string::npos)
- {
- out.push_back(str.substr(start, end-start));
- start = end + delim.length();
- }
-
- if (start < end)
- out.push_back(str.substr(start, end-start));
-
- return out;
-}
+using std::vector;
+using std::string;
+using tcu::TestLog;
+using namespace eglw;
-static int toInt(std::string str)
+static int toInt (std::string str)
{
std::istringstream strStream(str);
return out;
}
-class QueryStringCase : public TestCase
+class InfoCase : public TestCase
{
public:
- QueryStringCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint query)
+ InfoCase (EglTestContext& eglTestCtx, const char* name, const char* description)
: TestCase (eglTestCtx, name, description)
+ , m_display (EGL_NO_DISPLAY)
+ , m_version (0, 0)
+ {
+ }
+
+ void init (void)
+ {
+ DE_ASSERT(m_display == EGL_NO_DISPLAY);
+ m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay(), &m_version);
+ }
+
+ void deinit (void)
+ {
+ m_eglTestCtx.getLibrary().terminate(m_display);
+ m_display = EGL_NO_DISPLAY;
+ }
+
+protected:
+ EGLDisplay m_display;
+ eglu::Version m_version;
+};
+
+class QueryStringCase : public InfoCase
+{
+public:
+ QueryStringCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint query)
+ : InfoCase (eglTestCtx, name, description)
, m_query (query)
{
}
void validateString (const std::string& result)
{
tcu::TestLog& log = m_testCtx.getLog();
- std::vector<std::string> tokens = split(result);
+ std::vector<std::string> tokens = de::splitString(result, ' ');
if (m_query == EGL_VERSION)
{
- const tcu::egl::Display& display = m_eglTestCtx.getDisplay();
- const int dispMajor = display.getEGLMajorVersion();
- const int dispMinor = display.getEGLMinorVersion();
+ const int dispMajor = m_version.getMajor();
+ const int dispMinor = m_version.getMinor();
- const std::vector<std::string> versionTokens = split(tokens[0], ".");
+ const std::vector<std::string> versionTokens = de::splitString(tokens[0], '.');
if (versionTokens.size() < 2)
{
IterateResult iterate (void)
{
- const char* result = eglQueryString(m_eglTestCtx.getDisplay().getEGLDisplay(), m_query);
- TCU_CHECK_EGL_MSG("eglQueryString() failed");
+ const Library& egl = m_eglTestCtx.getLibrary();
+ const char* result = egl.queryString(m_display, m_query);
+ EGLU_CHECK_MSG(egl, "eglQueryString() failed");
m_testCtx.getLog() << tcu::TestLog::Message << result << tcu::TestLog::EndMessage;
m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
EGLint m_query;
};
-class QueryExtensionsCase : public TestCase
+class QueryExtensionsCase : public InfoCase
{
public:
QueryExtensionsCase (EglTestContext& eglTestCtx)
- : TestCase (eglTestCtx, "extensions", "Supported Extensions")
+ : InfoCase (eglTestCtx, "extensions", "Supported Extensions")
{
}
IterateResult iterate (void)
{
- vector<string> extensions;
- m_eglTestCtx.getDisplay().getExtensions(extensions);
+ const Library& egl = m_eglTestCtx.getLibrary();
+ vector<string> extensions = eglu::getDisplayExtensions(egl, m_display);
for (vector<string>::const_iterator i = extensions.begin(); i != extensions.end(); i++)
m_testCtx.getLog() << tcu::TestLog::Message << *i << tcu::TestLog::EndMessage;