Skip to content

Commit 1b6ca7a

Browse files
committed
Enable mixed mode integration test.
1 parent bcb0fe3 commit 1b6ca7a

File tree

1 file changed

+28
-43
lines changed

1 file changed

+28
-43
lines changed

ift/integration_test.cc

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ class IntegrationTest : public ::testing::Test {
4848
// Noto Sans JP
4949
auto blob = make_hb_blob(
5050
hb_blob_create_from_file("ift/testdata/NotoSansJP-Regular.subset.ttf"));
51-
auto face = make_hb_face(hb_face_create(blob.get(), 0));
52-
noto_sans_jp_.set(face.get());
51+
noto_sans_jp_.set(blob.get());
5352

54-
/*
5553
iftb_patches_.resize(5);
5654
for (int i = 1; i <= 4; i++) {
5755
std::string name =
@@ -61,6 +59,7 @@ class IntegrationTest : public ::testing::Test {
6159
iftb_patches_[i].set(blob.get());
6260
}
6361

62+
/*
6463
// Noto Sans JP VF
6564
blob = make_hb_blob(
6665
hb_blob_create_from_file("ift/testdata/NotoSansJP[wght].subset.ttf"));
@@ -94,22 +93,16 @@ class IntegrationTest : public ::testing::Test {
9493

9594
blob = make_hb_blob(
9695
hb_blob_create_from_file("common/testdata/Roboto[wdth,wght].ttf"));
97-
face = make_hb_face(hb_face_create(blob.get(), 0));
98-
roboto_vf_.set(face.get());
96+
roboto_vf_.set(blob.get());
9997
}
10098

101-
/*
102-
Status InitEncoderForIftb(Encoder& encoder) {
103-
encoder.SetUrlTemplate("0x$2$1");
99+
Status InitEncoderForMixedMode(Encoder& encoder) {
100+
encoder.SetUrlTemplate("{id}");
104101
{
105102
hb_face_t* face = noto_sans_jp_.reference_face();
106103
encoder.SetFace(face);
107104
hb_face_destroy(face);
108105
}
109-
auto sc = encoder.SetId({0x3c2bfda0, 0x890625c9, 0x40c644de, 0xb1195627});
110-
if (!sc.ok()) {
111-
return sc;
112-
}
113106

114107
for (uint i = 1; i < iftb_patches_.size(); i++) {
115108
auto sc = encoder.AddExistingIftbPatch(i, iftb_patches_[i]);
@@ -121,6 +114,7 @@ class IntegrationTest : public ::testing::Test {
121114
return absl::OkStatus();
122115
}
123116

117+
/*
124118
Status InitEncoderForVfIftb(Encoder& encoder) {
125119
encoder.SetUrlTemplate("0x$2$1");
126120
{
@@ -214,7 +208,7 @@ class IntegrationTest : public ::testing::Test {
214208
*/
215209

216210
FontData noto_sans_jp_;
217-
// std::vector<FontData> iftb_patches_;
211+
std::vector<FontData> iftb_patches_;
218212

219213
// FontData noto_sans_vf_;
220214
// std::vector<FontData> vf_iftb_patches_;
@@ -224,7 +218,6 @@ class IntegrationTest : public ::testing::Test {
224218

225219
FontData roboto_vf_;
226220

227-
/*
228221
uint32_t chunk0_cp = 0x47;
229222
uint32_t chunk1_cp = 0xb7;
230223
uint32_t chunk2_cp = 0xb2;
@@ -237,7 +230,6 @@ class IntegrationTest : public ::testing::Test {
237230
uint32_t chunk2_gid_non_cmapped = 900;
238231
uint32_t chunk3_gid = 169;
239232
uint32_t chunk4_gid = 103;
240-
*/
241233

242234
// static constexpr hb_tag_t kVrt3 = HB_TAG('v', 'r', 't', '3');
243235
};
@@ -512,10 +504,9 @@ TEST_F(IntegrationTest, SharedBrotli_DesignSpaceAugmentation) {
512504
ASSERT_EQ(*ds, expected_ds);
513505
}
514506

515-
/*
516507
TEST_F(IntegrationTest, MixedMode) {
517508
Encoder encoder;
518-
auto sc = InitEncoderForIftb(encoder);
509+
auto sc = InitEncoderForMixedMode(encoder);
519510
ASSERT_TRUE(sc.ok()) << sc;
520511

521512
// target paritions: {{0, 1}, {2}, {3, 4}}
@@ -526,49 +517,43 @@ TEST_F(IntegrationTest, MixedMode) {
526517

527518
auto encoded = encoder.Encode();
528519
ASSERT_TRUE(encoded.ok()) << encoded.status();
520+
auto encoded_face = encoded->face();
529521

530-
auto codepoints = ToCodepointsSet(*encoded);
522+
auto codepoints = FontHelper::ToCodepointsSet(encoded_face.get());
531523
ASSERT_TRUE(codepoints.contains(chunk0_cp));
532524
ASSERT_TRUE(codepoints.contains(chunk1_cp));
533525
ASSERT_FALSE(codepoints.contains(chunk2_cp));
534526
ASSERT_FALSE(codepoints.contains(chunk3_cp));
535527
ASSERT_FALSE(codepoints.contains(chunk4_cp));
536528

537-
auto client = IFTClient::NewClient(std::move(*encoded));
538-
ASSERT_TRUE(client.ok()) << client.status();
539-
540-
client->AddDesiredCodepoints({chunk3_cp, chunk4_cp});
541-
auto state = client->Process();
542-
ASSERT_TRUE(state.ok()) << state.status();
543-
ASSERT_EQ(*state, IFTClient::NEEDS_PATCHES);
544-
545-
auto patches = client->PatchesNeeded();
546-
ASSERT_EQ(patches.size(), 3); // 1 shared brotli and 2 iftb.
547-
548-
sc = AddPatches(*client, encoder);
549-
ASSERT_TRUE(sc.ok()) << sc;
550-
551-
state = client->Process();
552-
ASSERT_TRUE(state.ok()) << state.status();
553-
ASSERT_EQ(*state, IFTClient::READY);
529+
auto extended = Extend(encoder, *encoded, {chunk3_cp, chunk4_cp});
530+
ASSERT_TRUE(extended.ok()) << extended.status();
531+
auto extended_face = extended->face();
554532

555-
codepoints = ToCodepointsSet(client->GetFontData());
533+
codepoints = FontHelper::ToCodepointsSet(extended_face.get());
556534
ASSERT_TRUE(codepoints.contains(chunk0_cp));
557535
ASSERT_TRUE(codepoints.contains(chunk1_cp));
558536
ASSERT_FALSE(codepoints.contains(chunk2_cp));
559537
ASSERT_TRUE(codepoints.contains(chunk3_cp));
560538
ASSERT_TRUE(codepoints.contains(chunk4_cp));
561539

562-
auto face = client->GetFontData().face();
563-
ASSERT_TRUE(!FontHelper::GlyfData(face.get(), chunk0_gid)->empty());
564-
ASSERT_TRUE(!FontHelper::GlyfData(face.get(), chunk1_gid)->empty());
565-
ASSERT_FALSE(!FontHelper::GlyfData(face.get(), chunk2_gid)->empty());
540+
ASSERT_TRUE(!FontHelper::GlyfData(extended_face.get(), chunk0_gid)->empty());
541+
ASSERT_TRUE(!FontHelper::GlyfData(extended_face.get(), chunk1_gid)->empty());
542+
ASSERT_FALSE(!FontHelper::GlyfData(extended_face.get(), chunk2_gid)->empty());
566543
ASSERT_FALSE(
567-
!FontHelper::GlyfData(face.get(), chunk2_gid_non_cmapped)->empty());
568-
ASSERT_TRUE(!FontHelper::GlyfData(face.get(), chunk3_gid)->empty());
569-
ASSERT_TRUE(!FontHelper::GlyfData(face.get(), chunk4_gid)->empty());
544+
!FontHelper::GlyfData(extended_face.get(), chunk2_gid_non_cmapped)
545+
->empty());
546+
ASSERT_TRUE(!FontHelper::GlyfData(extended_face.get(), chunk3_gid)->empty());
547+
ASSERT_TRUE(!FontHelper::GlyfData(extended_face.get(), chunk4_gid)->empty());
548+
549+
auto original_face = noto_sans_jp_.face();
550+
GlyphDataMatches(original_face.get(), extended_face.get(), chunk0_gid);
551+
GlyphDataMatches(original_face.get(), extended_face.get(), chunk1_gid);
552+
GlyphDataMatches(original_face.get(), extended_face.get(), chunk3_gid);
553+
GlyphDataMatches(original_face.get(), extended_face.get(), chunk4_gid);
570554
}
571555

556+
/*
572557
TEST_F(IntegrationTest, MixedMode_OptionalFeatureTags) {
573558
Encoder encoder;
574559
auto sc = InitEncoderForIftbFeatureTest(encoder);

0 commit comments

Comments
 (0)