Hash :
b45a80db
Author :
Date :
2015-05-21T10:39:43
Make perftests use ANGLE_INSTANTIATE_TEST This also moves ANGLE_INSTANTIATE_TEST to its own header and makes it generic over the type of test parameter. BUG=angleproject:892 Change-Id: Id4e3929d7ad06964b3259015915be84a8ee414f9 Reviewed-on: https://chromium-review.googlesource.com/272553 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
//
// 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 "common/debug.h"
namespace angle
{
// This functions is used to filter which tests should be registered,
// internally it T::getRenderer() const that should be implemented for test
// parameter types.
template <typename T>
inline std::vector<T> FilterTestParams(const T *params, size_t numParams)
{
std::vector<T> filtered;
for (size_t i = 0; i < numParams; i++)
{
switch (params[i].getRenderer())
{
case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
filtered.push_back(params[i]);
break;
case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
#if defined(ANGLE_ENABLE_D3D9)
filtered.push_back(params[i]);
#endif
break;
case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
#if defined(ANGLE_ENABLE_D3D11)
filtered.push_back(params[i]);
#endif
break;
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
#if defined(ANGLE_ENABLE_OPENGL)
filtered.push_back(params[i]);
#endif
break;
default:
UNREACHABLE();
break;
}
}
return filtered;
}
namespace detail {
// Used with decltype to get the type of the first argument.
template <typename T, typename ... Args>
T ReturnFirst(T first, Args...)
{
return first;
}
} // namespace detail
// 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, ...) \
const decltype(::angle::detail::ReturnFirst(__VA_ARGS__)) testName##params[] = {__VA_ARGS__}; \
INSTANTIATE_TEST_CASE_P(, testName, testing::ValuesIn(::angle::FilterTestParams(testName##params, ArraySize(testName##params))));
} // namespace angle
#endif // ANGLE_TEST_INSTANTIATE_H_