webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
angle_test_instantiate.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // angle_test_instantiate.h: Adds support for filtering parameterized
8 // tests by platform, so we skip unsupported configs.
9 
10 #ifndef ANGLE_TEST_INSTANTIATE_H_
11 #define ANGLE_TEST_INSTANTIATE_H_
12 
13 #include <gtest/gtest.h>
14 
15 #include "common/debug.h"
16 
17 namespace angle
18 {
19 
20 struct PlatformParameters;
21 
22 bool IsPlatformAvailable(const PlatformParameters &param);
23 
24 // This functions is used to filter which tests should be registered,
25 // T must be or inherit from angle::PlatformParameters.
26 template <typename T>
27 std::vector<T> FilterTestParams(const T *params, size_t numParams)
28 {
29  std::vector<T> filtered;
30 
31  for (size_t i = 0; i < numParams; i++)
32  {
33  if (IsPlatformAvailable(params[i]))
34  {
35  filtered.push_back(params[i]);
36  }
37  }
38 
39  return filtered;
40 }
41 
42 // Instantiate the test once for each extra argument. The types of all the
43 // arguments must match, and getRenderer must be implemented for that type.
44 #define ANGLE_INSTANTIATE_TEST(testName, firstParam, ...) \
45  const decltype(firstParam) testName##params[] = { firstParam, ##__VA_ARGS__ }; \
46  INSTANTIATE_TEST_CASE_P(, testName, \
47  testing::ValuesIn(::angle::FilterTestParams(testName##params, ArraySize(testName##params))), \
48  testing::PrintToStringParamName());
49 
50 } // namespace angle
51 
52 #endif // ANGLE_TEST_INSTANTIATE_H_
bool IsPlatformAvailable(const PlatformParameters &param)
Definition: angle_test_instantiate.cpp:22
TestSubObjConstructor T
Definition: TestTypedefs.idl:84
Definition: Platform.h:33
for i
Definition: complexityMeasures.m:24
GLint param
Definition: gl2.h:471
std::vector< T > FilterTestParams(const T *params, size_t numParams)
Definition: angle_test_instantiate.h:27
GLenum GLint * params
Definition: gl2.h:440