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 all commits
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
8 changes: 7 additions & 1 deletion third_party/txt/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,17 @@ if (enable_unittests) {
executable("txt_unittests") {
testonly = true

sources = [ "tests/txt_run_all_unittests.cc" ]
sources = [
"tests/font_collection_tests.cc",
"tests/txt_run_all_unittests.cc",
]

public_configs = [ ":txt_config" ]

configs += [ ":allow_posix_names" ]

deps = [
":txt",
":txt_fixtures",
"//flutter/fml",
"//flutter/testing:testing_lib",
Expand Down
1 change: 1 addition & 0 deletions third_party/txt/src/txt/font_collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ size_t FontCollection::GetFontManagersCount() const {
void FontCollection::SetupDefaultFontManager(
uint32_t font_initialization_data) {
default_font_manager_ = GetDefaultFontManager(font_initialization_data);
skt_collection_.reset();
}

void FontCollection::SetDefaultFontManager(sk_sp<SkFontMgr> font_manager) {
Expand Down
43 changes: 43 additions & 0 deletions third_party/txt/tests/font_collection_tests.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2017 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "gtest/gtest.h"

#include <sstream>

#include "txt/font_collection.h"

namespace txt {
namespace testing {

class FontCollectionTests : public ::testing::Test {
public:
FontCollectionTests() {}

void SetUp() override {}
};

TEST_F(FontCollectionTests, SettingUpDefaultFontManagerClearsCache) {
FontCollection font_collection;
sk_sp<skia::textlayout::FontCollection> sk_font_collection =
font_collection.CreateSktFontCollection();
ASSERT_EQ(sk_font_collection->getFallbackManager().get(), nullptr);
font_collection.SetupDefaultFontManager(0);
sk_font_collection = font_collection.CreateSktFontCollection();
ASSERT_NE(sk_font_collection->getFallbackManager().get(), nullptr);
}
} // namespace testing
} // namespace txt