resources: remove most uses of GetResourcePath()
Going forward, we will standardize on GetResourceAsData(), which will
make it easier to run tests in environments without access to the
filesystem.
Also: GetResourceAsData() complains when a resource is missing.
This is usually an error.
Change-Id: Iaf70b71b0ca5ed8cd1a5538a60ef185ae8736188
Reviewed-on: https://skia-review.googlesource.com/82642
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index 4cf605a..2543870 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -358,8 +358,8 @@
static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) {
{
// Load typeface from file to test CreateFromFile with index.
- SkString filename = GetResourcePath("/fonts/test.ttc");
- sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFile(filename.c_str(), 1));
+ auto data = GetResourceAsData("fonts/test.ttc");
+ auto typeface = SkTypeface::MakeFromStream(new SkMemoryStream(std::move(data)), 1);
if (!typeface) {
INFOF(reporter, "Could not run fontstream test because test.ttc not found.");
} else {
@@ -369,7 +369,7 @@
{
// Load typeface as stream to create with axis settings.
- std::unique_ptr<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf"));
+ std::unique_ptr<SkStreamAsset> distortable(GetResourceAsStream("fonts/Distortable.ttf"));
if (!distortable) {
INFOF(reporter, "Could not run fontstream test because Distortable.ttf not found.");
} else {