Flutter Engine
 
Loading...
Searching...
No Matches
embedder_test.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_H_
6#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_H_
7
8#include <map>
9#include <memory>
10
11#include "flutter/fml/macros.h"
15#include "gtest/gtest.h"
16
17namespace flutter::testing {
18
19class EmbedderTestContextGL;
20class EmbedderTestContextMetal;
21class EmbedderTestContextSoftware;
22class EmbedderTestContextVulkan;
23
24class EmbedderTest : public ThreadTest {
25 public:
27
28 std::string GetFixturesDirectory() const;
29
30 template <typename T>
32 static_assert(false, "Unsupported test context type");
33 }
34
35 template <>
36 EmbedderTestContextGL& GetEmbedderContext<EmbedderTestContextGL>() {
37 return reinterpret_cast<EmbedderTestContextGL&>(GetGLContext());
38 }
39
40 template <>
41 EmbedderTestContextMetal& GetEmbedderContext<EmbedderTestContextMetal>() {
42 return reinterpret_cast<EmbedderTestContextMetal&>(GetMetalContext());
43 }
44
45 template <>
47 GetEmbedderContext<EmbedderTestContextSoftware>() {
48 return reinterpret_cast<EmbedderTestContextSoftware&>(GetSoftwareContext());
49 }
50
51 template <>
52 EmbedderTestContextVulkan& GetEmbedderContext<EmbedderTestContextVulkan>() {
53 return reinterpret_cast<EmbedderTestContextVulkan&>(GetVulkanContext());
54 }
55
56 protected:
57 // We return the base class here and reinterpret_cast in the template
58 // specializations because we're using forward declarations rather than
59 // including the headers directly, and thus the relationship between the base
60 // class and subclasses is unknown to the compiler here. We avoid including
61 // the headers directly because the Metal headers include Objective-C types,
62 // and thus cannot be included in pure C++ translation units.
67
68 std::unique_ptr<EmbedderTestContext> gl_context_;
69 std::unique_ptr<EmbedderTestContext> metal_context_;
70 std::unique_ptr<EmbedderTestContext> software_context_;
71 std::unique_ptr<EmbedderTestContext> vulkan_context_;
72
74};
75
77 : public EmbedderTest,
78 public ::testing::WithParamInterface<EmbedderTestContextType> {
79 public:
81};
82
83} // namespace flutter::testing
84
85#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_H_
GLenum type
std::unique_ptr< EmbedderTestContext > gl_context_
std::unique_ptr< EmbedderTestContext > software_context_
std::string GetFixturesDirectory() const
EmbedderTestContext & GetGLContext()
EmbedderTestContext & GetMetalContext()
EmbedderTestContext & GetVulkanContext()
EmbedderTestContext & GetSoftwareContext()
std::unique_ptr< EmbedderTestContext > vulkan_context_
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTest)
std::unique_ptr< EmbedderTestContext > metal_context_
A fixture that creates threads with running message loops that are terminated when the test is done (...
Definition thread_test.h:26