Files
angle/util/testfixturetypes.h
T
Nico Weber ce8bb2fa58 Improve standards conformance of ANGLE's testing code.
ANGLE's testing code recently got enabled in Chromium's builds. While it
builds fine with cl.exe, it isn't quite standards-conformant and doesn't
build with clang. Fix this.

There were three issues:

1. ANGLE_TYPED_TEST_CASE() is a variadic macro that tries to use
   __VA_ARGS__ as argument to a variadic template and then pass
   that template to another macro. However, [cpp.replace] describes
   that ANGLE_TYPED_TEST_CASE(Test, int, float) should be expanded
   to TYPED_TEST_CASE(Test, ::testing::Types<int, float>) which
   should be interpreted as a "call" of TYPED_TEST_CASE with the
   3 macro arguments `Test`, `::testing::Types<int`, and `float>`.
   As a fix, use a typedef for the variadic template and refer to
   it through the typedef in the macro call.

2. `#version` was used on its own line in a substitution of the
   SHADER_SOURCE macro. [cpp]p1 says that every line starting with
   a `#` is a preprocessing directive, and [cpp.replace]p11 says
   "If there are sequences of preprocessing tokens within the list
   of arguments that would otherwise act as preprocessing directives,
   the behavior is undefined" (with a footnote that this includes
   non-directives -- # followed by unknown text). As a fix, merge the
   `#version` line with the previous line. Now the line doesn't start
   with `#` and things are fine.

3. Unqualified lookup usually doesn't look into dependent bases. If
   this is desired, one usually has to make the call qualified, a
   good explanation for this is at
   http://eli.thegreenplace.net/2012/02/06/dependent-name-lookup-for-c-templates
   cl.exe doesn't implement this rule, and clang tries to emulate
   cl.exe's behavior to a certain extend when in Microsoft mode.
   However, that seems to not work for member templates with explicit
   types (filed http://llvm.org/PR22066 for this, but since it's not
   needed to parse Microsoft headers and not standards-conformant,
   I'm not sure if we'll fix that). As a fix, don't provide an explicit
   type, the inferred type is the same. This is also consistent with
   all the other tests in this file. (We might clean up -Wmicrosoft
   warnings in the future; if so I'll add the explicit this->s that
   are missing in this file when we do.)

BUG=chromium:445406

Change-Id: I77a2f3ab9601a1f0f39b56ed3d05217f123155b8
Reviewed-on: https://chromium-review.googlesource.com/238090
Reviewed-by: Jamie Madill <[email protected]>
Reviewed-by: Brandon Jones <[email protected]>
Tested-by: Geoff Lang <[email protected]>
2015-01-05 16:11:43 +00:00

89 lines
3.8 KiB
C++

//
// 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.
//
#ifndef UTIL_TEST_FIXTURE_TYPES_H
#define UTIL_TEST_FIXTURE_TYPES_H
#include "EGLWindow.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
template<EGLint platform, EGLint platformMajorVersion, EGLint platformMinorVersion, EGLint warp>
struct Platform
{
static EGLPlatformParameters GetPlatform()
{
return EGLPlatformParameters(platform, platformMajorVersion, platformMinorVersion, warp);
}
};
// Typedefs of common platform types
#define DEFINE_ANGLE_TEST_PLATFORM(name, platform, majorVersion, minorVersion, useWarp) \
struct name : public Platform<platform, majorVersion, minorVersion, useWarp> { }
DEFINE_ANGLE_TEST_PLATFORM(D3D9, EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, EGL_DONT_CARE, EGL_DONT_CARE, EGL_FALSE);
DEFINE_ANGLE_TEST_PLATFORM(D3D11, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_DONT_CARE, EGL_DONT_CARE, EGL_FALSE);
DEFINE_ANGLE_TEST_PLATFORM(D3D11_FL11_0, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 11, 0, EGL_FALSE);
DEFINE_ANGLE_TEST_PLATFORM(D3D11_FL10_1, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 10, 1, EGL_FALSE);
DEFINE_ANGLE_TEST_PLATFORM(D3D11_FL10_0, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 10, 0, EGL_FALSE);
DEFINE_ANGLE_TEST_PLATFORM(D3D11_FL9_3, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 9, 3, EGL_FALSE);
DEFINE_ANGLE_TEST_PLATFORM(D3D11_WARP, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_DONT_CARE, EGL_DONT_CARE, EGL_TRUE);
DEFINE_ANGLE_TEST_PLATFORM(D3D11_FL11_0_WARP, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 11, 0, EGL_TRUE);
DEFINE_ANGLE_TEST_PLATFORM(D3D11_FL10_1_WARP, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 10, 1, EGL_TRUE);
DEFINE_ANGLE_TEST_PLATFORM(D3D11_FL10_0_WARP, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 10, 0, EGL_TRUE);
DEFINE_ANGLE_TEST_PLATFORM(D3D11_FL9_3_WARP, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 9, 3, EGL_TRUE);
#undef DEFINE_ANGLE_TEST_PLATFORM
// Test Fixture Type
template<GLint GLESMajorVersion, typename platformT>
struct TestFixture
{
static EGLint GetGlesMajorVersion()
{
return GLESMajorVersion;
}
static EGLPlatformParameters GetPlatform()
{
return platformT::GetPlatform();
}
};
// Typedefs of common fixture types
typedef TestFixture<2, D3D9> ES2_D3D9;
typedef TestFixture<2, D3D11> ES2_D3D11;
typedef TestFixture<2, D3D11_FL11_0> ES2_D3D11_FL11_0;
typedef TestFixture<2, D3D11_FL10_1> ES2_D3D11_FL10_1;
typedef TestFixture<2, D3D11_FL10_0> ES2_D3D11_FL10_0;
typedef TestFixture<2, D3D11_FL9_3> ES2_D3D11_FL9_3;
typedef TestFixture<2, D3D11_WARP> ES2_D3D11_WARP;
typedef TestFixture<2, D3D11_FL11_0_WARP> ES2_D3D11_FL11_0_WARP;
typedef TestFixture<2, D3D11_FL10_1_WARP> ES2_D3D11_FL10_1_WARP;
typedef TestFixture<2, D3D11_FL10_0_WARP> ES2_D3D11_FL10_0_WARP;
typedef TestFixture<2, D3D11_FL9_3_WARP> ES2_D3D11_FL9_3_WARP;
typedef TestFixture<3, D3D11> ES3_D3D11;
typedef TestFixture<3, D3D11_FL11_0> ES3_D3D11_FL11_0;
typedef TestFixture<3, D3D11_FL10_1> ES3_D3D11_FL10_1;
typedef TestFixture<3, D3D11_FL10_0> ES3_D3D11_FL10_0;
typedef TestFixture<3, D3D11_WARP> ES3_D3D11_WARP;
typedef TestFixture<3, D3D11_FL11_0_WARP> ES3_D3D11_FL11_0_WARP;
typedef TestFixture<3, D3D11_FL10_1_WARP> ES3_D3D11_FL10_1_WARP;
typedef TestFixture<3, D3D11_FL10_0_WARP> ES3_D3D11_FL10_0_WARP;
#define ANGLE_TYPED_TEST_CASE(testName, ...) \
typedef ::testing::Types<__VA_ARGS__> Helper##testName; \
TYPED_TEST_CASE(testName, Helper##testName);
#endif // UTIL_TEST_FIXTURE_TYPES_H