Chinmay Garde 1405016707 Add a separate target for Dart coverter on FML types. (flutter/engine#14011)
The converters are still in a separate target that must be included manually. This allows targets that depend on FML but not Dart runtime not have to depend on the runtime.

Adds a test that includes this target and tests image decompression from assets. There is also a test for the standalone DartConvertor in shell_unittests but not in fml_unittests be cause FML uni-tests cannot yet launch a VM. I will work on adding fixtures for those.
2019-11-26 13:33:56 -08:00

58 lines
1.7 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;
}
std::unique_ptr<fml::Mapping> OpenFixtureAsMapping(std::string fixture_name) {
return fml::FileMapping::CreateReadOnly(OpenFixture(fixture_name));
}
} // namespace testing
} // namespace flutter