Edit

kc3-lang/angle/src/tests/test_utils/angle_test_instantiate.h

Branch :

  • Show log

    Commit

  • Author : Corentin Wallez
    Date : 2015-09-03 14:41:23
    Hash : 33585c71
    Message : Use named value-parameterized tests for angle_end2end_tests This replace the non-descriptive digit at the end of the test name by the name of the configuration being tested. Reland with a fix for gtest initialization on Windows caused by ProgramBinaryTest having the same parameter name twice. BUG=angleproject:1153 Change-Id: I9b0f661a535b760793d9d87ef0c8298f6b83830d Reviewed-on: https://chromium-review.googlesource.com/297701 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>

  • src/tests/test_utils/angle_test_instantiate.h
  • //
    // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    
    // angle_test_instantiate.h: Adds support for filtering parameterized
    // tests by platform, so we skip unsupported configs.
    
    #ifndef ANGLE_TEST_INSTANTIATE_H_
    #define ANGLE_TEST_INSTANTIATE_H_
    
    #include <gtest/gtest.h>
    
    #include "common/debug.h"
    
    namespace angle
    {
    
    struct PlatformParameters;
    
    bool IsPlatformAvailable(const PlatformParameters &param);
    
    // This functions is used to filter which tests should be registered,
    // T must be or inherit from angle::PlatformParameters.
    template <typename T>
    std::vector<T> FilterTestParams(const T *params, size_t numParams)
    {
        std::vector<T> filtered;
    
        for (size_t i = 0; i < numParams; i++)
        {
            if (IsPlatformAvailable(params[i]))
            {
                filtered.push_back(params[i]);
            }
        }
    
        return filtered;
    }
    
    // Instantiate the test once for each extra argument. The types of all the
    // arguments must match, and getRenderer must be implemented for that type.
    #define ANGLE_INSTANTIATE_TEST(testName, firstParam, ...) \
        const decltype(firstParam) testName##params[] = { firstParam, ##__VA_ARGS__ }; \
        INSTANTIATE_TEST_CASE_P(, testName, \
                                  testing::ValuesIn(::angle::FilterTestParams(testName##params, ArraySize(testName##params))), \
                                  testing::PrintToStringParamName());
    
    } // namespace angle
    
    #endif // ANGLE_TEST_INSTANTIATE_H_