13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program EGL Module 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * --------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief API test case. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglApiCase.hpp" 253c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos#include "egluUtil.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluStrUtil.hpp" 273c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos#include "eglwLibrary.hpp" 283c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos#include "eglwEnums.hpp" 293c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos#include "deSTLUtil.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace egl 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosusing tcu::TestLog; 373c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosusing std::vector; 383c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosusing namespace eglw; 393c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos 403c827367444ee418f129b2c238299f49d3264554Jarkko PoyryApiCase::ApiCase (EglTestContext& eglTestCtx, const char* name, const char* description) 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (eglTestCtx, name, description) 423c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos , CallLogWrapper(eglTestCtx.getLibrary(), eglTestCtx.getTestContext().getLog()) 433c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos , m_display (EGL_NO_DISPLAY) 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 473c827367444ee418f129b2c238299f49d3264554Jarkko PoyryApiCase::~ApiCase (void) 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 513c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosvoid ApiCase::init (void) 523c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos{ 533c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay()); 543c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos m_supportedClientAPIs = eglu::getClientAPIs(m_eglTestCtx.getLibrary(), m_display); 553c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos} 563c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos 573c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosvoid ApiCase::deinit (void) 583c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos{ 593c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos const Library& egl = m_eglTestCtx.getLibrary(); 603c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos egl.terminate(m_display); 613c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos 623c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos m_display = EGL_NO_DISPLAY; 633c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos m_supportedClientAPIs.clear(); 643c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos} 653c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos 663c827367444ee418f129b2c238299f49d3264554Jarkko PoyryApiCase::IterateResult ApiCase::iterate (void) 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Initialize result to pass. 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Enable call logging. 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enableLogging(true); 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Run test. 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test(); 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 803c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosbool ApiCase::isAPISupported (eglw::EGLenum api) const 813c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos{ 823c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos return de::contains(m_supportedClientAPIs.begin(), m_supportedClientAPIs.end(), api); 833c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos} 843c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ApiCase::expectError (EGLenum expected) 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 873c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos EGLenum err = m_eglTestCtx.getLibrary().getError(); 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (err != expected) 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 90deac154a024140d8c681dcc182cacb6191f95544Mika Isojärvi m_testCtx.getLog() << TestLog::Message << "// ERROR expected: " << eglu::getErrorStr(expected) << ", Got: " << eglu::getErrorStr(err) << TestLog::EndMessage; 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error"); 931ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvi } 941ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvi} 951ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvi 961ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvivoid ApiCase::expectEitherError (EGLenum expectedA, EGLenum expectedB) 971ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvi{ 981ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvi EGLenum err = m_eglTestCtx.getLibrary().getError(); 991ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvi if (err != expectedA && err != expectedB) 1001ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvi { 1011ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvi m_testCtx.getLog() << TestLog::Message << "// ERROR expected: " << eglu::getErrorStr(expectedA) << " or " << eglu::getErrorStr(expectedB) << ", Got: " << eglu::getErrorStr(err) << TestLog::EndMessage; 1021ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvi if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) 1031ae4692b96de13b1bdcfe20d67d4edc226091169Mika Isojärvi m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error"); 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ApiCase::expectBoolean (EGLBoolean expected, EGLBoolean got) 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (expected != got) 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 111deac154a024140d8c681dcc182cacb6191f95544Mika Isojärvi m_testCtx.getLog() << TestLog::Message << "// ERROR expected: " << eglu::getBooleanStr(expected) << ", Got: " << eglu::getBooleanStr(got) << TestLog::EndMessage; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ApiCase::expectNoContext (EGLContext got) 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (got != EGL_NO_CONTEXT) 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 121deac154a024140d8c681dcc182cacb6191f95544Mika Isojärvi m_testCtx.getLog() << TestLog::Message << "// ERROR expected: EGL_NO_CONTEXT" << TestLog::EndMessage; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglDestroyContext(getDisplay(), got); 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ApiCase::expectNoSurface (EGLSurface got) 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1304f10e8d7716308f34ed084cb8e896f7b967e9206Kalle Raita if (got != EGL_NO_SURFACE) 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 132deac154a024140d8c681dcc182cacb6191f95544Mika Isojärvi m_testCtx.getLog() << TestLog::Message << "// ERROR expected: EGL_NO_SURFACE" << TestLog::EndMessage; 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglDestroySurface(getDisplay(), got); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ApiCase::expectNoDisplay (EGLDisplay got) 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1414f10e8d7716308f34ed084cb8e896f7b967e9206Kalle Raita if (got != EGL_NO_DISPLAY) 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 143deac154a024140d8c681dcc182cacb6191f95544Mika Isojärvi m_testCtx.getLog() << TestLog::Message << "// ERROR expected: EGL_NO_DISPLAY" << TestLog::EndMessage; 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ApiCase::expectNull (const void* got) 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1514f10e8d7716308f34ed084cb8e896f7b967e9206Kalle Raita if (got != DE_NULL) 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 153deac154a024140d8c681dcc182cacb6191f95544Mika Isojärvi m_testCtx.getLog() << TestLog::Message << "// ERROR expected: NULL" << TestLog::EndMessage; 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1593c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosbool ApiCase::getConfig (EGLConfig* config, const eglu::FilterList& filters) 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1613c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos try 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1633c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos *config = eglu::chooseSingleConfig(m_eglTestCtx.getLibrary(), m_display, filters); 1643c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos return true; 1653c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos } 1663c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos catch (const tcu::NotSupportedError&) 1673c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos { 1683c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos return false; 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // egl 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 174