Files
engine/testing/testing.cc
T
Amir Hardon a34f9a811c Skip empty platform view overlays. (#11427)
This change sets up a "spying canvas" to try and detect empty canvases.
When using platform views with a custom embedder, if a platform view
overlay canvas is known to be empty we skip creating a compositor layer
for that overlay.
2019-08-26 11:40:49 -07:00

54 lines
1.5 KiB
C++

// 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 "testing.h"
#include "flutter/fml/file.h"
namespace flutter {
namespace testing {
std::string GetCurrentTestName() {
return ::testing::UnitTest::GetInstance()->current_test_info()->name();
}
fml::UniqueFD OpenFixturesDirectory() {
auto fixtures_directory =
OpenDirectory(GetFixturesPath(), // path
false, // create
fml::FilePermission::kRead // permission
);
if (!fixtures_directory.is_valid()) {
FML_LOG(ERROR) << "Could not open fixtures directory.";
return {};
}
return fixtures_directory;
}
fml::UniqueFD OpenFixture(std::string fixture_name) {
if (fixture_name.size() == 0) {
FML_LOG(ERROR) << "Invalid fixture name.";
return {};
}
auto fixtures_directory = OpenFixturesDirectory();
auto fixture_fd = fml::OpenFile(fixtures_directory, // base directory
fixture_name.c_str(), // path
false, // create
fml::FilePermission::kRead // permission
);
if (!fixture_fd.is_valid()) {
FML_LOG(ERROR) << "Could not open fixture for path: " << GetFixturesPath()
<< "/" << fixture_name << ".";
return {};
}
return fixture_fd;
}
} // namespace testing
} // namespace flutter