Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions shell/platform/embedder/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ if (enable_unittests) {
"tests/embedder_test_compositor_gl.h",
"tests/embedder_test_context_gl.cc",
"tests/embedder_test_context_gl.h",
"tests/embedder_test_gl.cc",
]

public_deps += [
Expand All @@ -331,6 +332,7 @@ if (enable_unittests) {
"tests/embedder_test_compositor_metal.h",
"tests/embedder_test_context_metal.cc",
"tests/embedder_test_context_metal.h",
"tests/embedder_test_metal.mm",
]

public_deps += [ "//flutter/testing:metal" ]
Expand All @@ -342,6 +344,7 @@ if (enable_unittests) {
"tests/embedder_test_compositor_vulkan.h",
"tests/embedder_test_context_vulkan.cc",
"tests/embedder_test_context_vulkan.h",
"tests/embedder_test_vulkan.cc",
]

public_deps += [
Expand Down
66 changes: 37 additions & 29 deletions shell/platform/embedder/tests/embedder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@
#include "flutter/shell/platform/embedder/tests/embedder_test.h"
#include "flutter/shell/platform/embedder/tests/embedder_test_context_software.h"

#ifdef SHELL_ENABLE_GL
#include "flutter/shell/platform/embedder/tests/embedder_test_context_gl.h"
#endif

#ifdef SHELL_ENABLE_METAL
#include "flutter/shell/platform/embedder/tests/embedder_test_context_metal.h"
#endif

#ifdef SHELL_ENABLE_VULKAN
#include "flutter/shell/platform/embedder/tests/embedder_test_context_vulkan.h"
#endif

namespace flutter {
namespace testing {

Expand All @@ -33,28 +21,17 @@ EmbedderTestContext& EmbedderTest::GetEmbedderContext(
if (!embedder_contexts_[type]) {
switch (type) {
case EmbedderTestContextType::kSoftwareContext:
embedder_contexts_[type] =
std::make_unique<EmbedderTestContextSoftware>(
GetFixturesDirectory());
embedder_contexts_[type] = CreateSoftwareContext();
break;
#ifdef SHELL_ENABLE_VULKAN
case EmbedderTestContextType::kVulkanContext:
embedder_contexts_[type] =
std::make_unique<EmbedderTestContextVulkan>(GetFixturesDirectory());
break;
#endif
#ifdef SHELL_ENABLE_GL
case EmbedderTestContextType::kOpenGLContext:
embedder_contexts_[type] =
std::make_unique<EmbedderTestContextGL>(GetFixturesDirectory());
embedder_contexts_[type] = CreateGLContext();
break;
case EmbedderTestContextType::kVulkanContext:
embedder_contexts_[type] = CreateVulkanContext();
break;
#endif
#ifdef SHELL_ENABLE_METAL
case EmbedderTestContextType::kMetalContext:
embedder_contexts_[type] =
std::make_unique<EmbedderTestContextMetal>(GetFixturesDirectory());
embedder_contexts_[type] = CreateMetalContext();
break;
#endif
default:
FML_DCHECK(false) << "Invalid context type specified.";
break;
Expand All @@ -64,5 +41,36 @@ EmbedderTestContext& EmbedderTest::GetEmbedderContext(
return *embedder_contexts_[type];
}

std::unique_ptr<EmbedderTestContext> EmbedderTest::CreateSoftwareContext() {
return std::make_unique<EmbedderTestContextSoftware>(GetFixturesDirectory());
}

#ifndef SHELL_ENABLE_GL
// Fallback implementation.
// See: flutter/shell/platform/embedder/tests/embedder_test_gl.cc.
std::unique_ptr<EmbedderTestContext> EmbedderTest::CreateGLContext() {
FML_LOG(FATAL) << "OpenGL is not supported in this build";
return nullptr;
}
#endif

#ifndef SHELL_ENABLE_METAL
// Fallback implementation.
// See: flutter/shell/platform/embedder/tests/embedder_test_metal.mm.
std::unique_ptr<EmbedderTestContext> EmbedderTest::CreateMetalContext() {
FML_LOG(FATAL) << "Metal is not supported in this build";
return nullptr;
}
#endif

#ifndef SHELL_ENABLE_VULKAN
// Fallback implementation.
// See: flutter/shell/platform/embedder/tests/embedder_test_vulkan.cc.
std::unique_ptr<EmbedderTestContext> EmbedderTest::CreateVulkanContext() {
FML_LOG(FATAL) << "Vulkan is not supported in this build";
return nullptr;
}
#endif

} // namespace testing
} // namespace flutter
5 changes: 5 additions & 0 deletions shell/platform/embedder/tests/embedder_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class EmbedderTest : public ThreadTest {
std::map<EmbedderTestContextType, std::unique_ptr<EmbedderTestContext>>
embedder_contexts_;

std::unique_ptr<EmbedderTestContext> CreateSoftwareContext();
std::unique_ptr<EmbedderTestContext> CreateGLContext();
std::unique_ptr<EmbedderTestContext> CreateMetalContext();
std::unique_ptr<EmbedderTestContext> CreateVulkanContext();

FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTest);
};

Expand Down
17 changes: 17 additions & 0 deletions shell/platform/embedder/tests/embedder_test_gl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/embedder/tests/embedder_test.h"

#include "flutter/shell/platform/embedder/tests/embedder_test_context_gl.h"

namespace flutter {
namespace testing {

std::unique_ptr<EmbedderTestContext> EmbedderTest::CreateGLContext() {
return std::make_unique<EmbedderTestContextGL>(GetFixturesDirectory());
}

} // namespace testing
} // namespace flutter
17 changes: 17 additions & 0 deletions shell/platform/embedder/tests/embedder_test_metal.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/embedder/tests/embedder_test.h"

#include "flutter/shell/platform/embedder/tests/embedder_test_context_metal.h"

namespace flutter {
namespace testing {

std::unique_ptr<EmbedderTestContext> EmbedderTest::CreateMetalContext() {
return std::make_unique<EmbedderTestContextMetal>(GetFixturesDirectory());
}

} // namespace testing
} // namespace flutter
17 changes: 17 additions & 0 deletions shell/platform/embedder/tests/embedder_test_vulkan.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/embedder/tests/embedder_test.h"

#include "flutter/shell/platform/embedder/tests/embedder_test_context_vulkan.h"

namespace flutter {
namespace testing {

std::unique_ptr<EmbedderTestContext> EmbedderTest::CreateVulkanContext() {
return std::make_unique<EmbedderTestContextVulkan>(GetFixturesDirectory());
}

} // namespace testing
} // namespace flutter