Skip to content

Commit

Permalink
Test logs
Browse files Browse the repository at this point in the history
  • Loading branch information
bdero committed Feb 2, 2022
1 parent 81ba581 commit 01dee39
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions shell/platform/embedder/tests/embedder_config_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ void EmbedderConfigBuilder::SetMetalRendererConfig(SkISize surface_size) {

void EmbedderConfigBuilder::SetVulkanRendererConfig(SkISize surface_size) {
#ifdef SHELL_ENABLE_VULKAN
FML_LOG(ERROR) << "==== bdero ==== SetVulkanRendererConfig";
renderer_config_.type = FlutterRendererType::kVulkan;
renderer_config_.vulkan = vulkan_renderer_config_;
context_.SetupSurface(surface_size);
Expand Down Expand Up @@ -468,9 +469,12 @@ void EmbedderConfigBuilder::InitializeMetalRendererConfig() {
#ifdef SHELL_ENABLE_VULKAN

void EmbedderConfigBuilder::InitializeVulkanRendererConfig() {
FML_LOG(ERROR) << "==== bdero ==== InitializeVulkanRendererConfig";
if (context_.GetContextType() != EmbedderTestContextType::kVulkanContext) {
FML_LOG(ERROR) << "==== bdero ==== InitializeVulkanRendererConfig SKIPPED";
return;
}
FML_LOG(ERROR) << "==== bdero ==== context_.GetContextType() must be Vulkan";

vulkan_renderer_config_.struct_size = sizeof(FlutterVulkanRendererConfig);
vulkan_renderer_config_.version =
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/embedder/tests/embedder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ std::string EmbedderTest::GetFixturesDirectory() const {

EmbedderTestContext& EmbedderTest::GetEmbedderContext(
EmbedderTestContextType type) {
FML_LOG(ERROR) << "==== bdero ==== GetEmbedderContext";
// Setup the embedder context lazily instead of in the constructor because we
// don't to do all the work if the test won't end up using context.
if (!embedder_contexts_[type]) {
Expand All @@ -36,6 +37,9 @@ EmbedderTestContext& EmbedderTest::GetEmbedderContext(
break;
#ifdef SHELL_ENABLE_VULKAN
case EmbedderTestContextType::kVulkanContext:

FML_LOG(ERROR) << "==== bdero ==== GetEmbedderContext: "
"EmbedderTestContextVulkan was constructed";
embedder_contexts_[type] =
std::make_unique<EmbedderTestContextVulkan>(GetFixturesDirectory());
break;
Expand Down
19 changes: 19 additions & 0 deletions shell/platform/embedder/tests/embedder_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ TEST_F(EmbedderTest, VMAndIsolateSnapshotSizesAreRedundantInAOTMode) {
///
TEST_F(EmbedderTest,
CompositorMustBeAbleToRenderKnownSceneWithSoftwareCompositor) {
FML_LOG(ERROR) << "====bdero==== 0 BEGIN";
auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);

EmbedderConfigBuilder builder(context);
Expand All @@ -606,8 +607,12 @@ TEST_F(EmbedderTest,

auto scene_image = context.GetNextSceneImage();

FML_LOG(ERROR) << "====bdero==== 1 GetNextSceneImage";

context.GetCompositor().SetNextPresentCallback(
[&](const FlutterLayer** layers, size_t layers_count) {
FML_LOG(ERROR) << "====bdero==== Present callback BEGIN";

ASSERT_EQ(layers_count, 5u);

// Layer Root
Expand Down Expand Up @@ -693,12 +698,17 @@ TEST_F(EmbedderTest,
ASSERT_EQ(*layers[4], layer);
}

FML_LOG(ERROR) << "====bdero==== Present callback latch";
latch.CountDown();

FML_LOG(ERROR) << "====bdero==== Present callback END";
});

context.GetCompositor().SetPlatformViewRendererCallback(
[&](const FlutterLayer& layer, GrDirectContext*
/* don't use because software compositor */) -> sk_sp<SkImage> {
FML_LOG(ERROR) << "====bdero==== Renderer callback BEGIN";

auto surface = CreateRenderSurface(
layer, nullptr /* null because software compositor */);
auto canvas = surface->getCanvas();
Expand Down Expand Up @@ -731,6 +741,7 @@ TEST_F(EmbedderTest,
<< "Test was asked to composite an unknown platform view.";
}

FML_LOG(ERROR) << "====bdero==== Renderer callback END";
return surface->makeImageSnapshot();
});

Expand All @@ -739,8 +750,12 @@ TEST_F(EmbedderTest,
CREATE_NATIVE_ENTRY(
[&latch](Dart_NativeArguments args) { latch.CountDown(); }));

FML_LOG(ERROR) << "====bdero==== 2 Before LaunchEngine";

auto engine = builder.LaunchEngine();

FML_LOG(ERROR) << "====bdero==== 3 After LaunchEngine";

// Send a window metrics events so frames may be scheduled.
FlutterWindowMetricsEvent event = {};
event.struct_size = sizeof(event);
Expand All @@ -755,12 +770,16 @@ TEST_F(EmbedderTest,
kSuccess);
ASSERT_TRUE(engine.is_valid());

FML_LOG(ERROR) << "====bdero==== 4 Before latch";
latch.Wait();
FML_LOG(ERROR) << "====bdero==== 5 After latch";

ASSERT_TRUE(ImageMatchesFixture("compositor_software.png", scene_image));

// There should no present calls on the root surface.
ASSERT_EQ(context.GetSurfacePresentCount(), 0u);

FML_LOG(ERROR) << "====bdero==== 6 END";
}

//------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions testing/test_vulkan_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ TestVulkanContext::TestVulkanContext() {
}

TestVulkanContext::~TestVulkanContext() {
FML_LOG(ERROR) << "~TestVulkanContext begin";
if (context_) {
context_->releaseResourcesAndAbandonContext();
}

FML_LOG(ERROR) << "~TestVulkanContext end";
}

std::optional<TestVulkanImage> TestVulkanContext::CreateImage(
Expand Down

0 comments on commit 01dee39

Please sign in to comment.