1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <gtest/gtest.h>
9 #include "ots-memory-stream.h"
13 #define SET_TABLE(name, capname) \
14 do { file.name = new ots::OpenType##capname; } while (0)
15 #define SET_LAYOUT_TABLE(name, capname) \
18 SET_TABLE(name, capname); \
20 file.name->data = reinterpret_cast<const uint8_t*>(1); \
21 file.name->length = 1; \
23 #define DROP_TABLE(name) \
24 do { delete file.name; file.name = NULL; } while (0)
25 #define DROP_LAYOUT_TABLE(name) \
26 do { file.name->data = NULL; file.name->length = 0; } while (0)
30 class TableDependenciesTest
: public ::testing::Test
{
32 virtual void SetUp() {
33 SET_LAYOUT_TABLE(gsub
, GSUB
);
34 SET_TABLE(vhea
, VHEA
);
35 SET_TABLE(vmtx
, VMTX
);
38 virtual void TearDown() {
43 ots::OpenTypeFile file
;
47 TEST_F(TableDependenciesTest
, TestVhea
) {
48 EXPECT_TRUE(ots::ots_vhea_should_serialise(&file
));
51 TEST_F(TableDependenciesTest
, TestVmtx
) {
52 EXPECT_TRUE(ots::ots_vmtx_should_serialise(&file
));
55 TEST_F(TableDependenciesTest
, TestVheaVmtx
) {
57 EXPECT_FALSE(ots::ots_vhea_should_serialise(&file
));
60 TEST_F(TableDependenciesTest
, TestVmtxVhea
) {
62 EXPECT_FALSE(ots::ots_vmtx_should_serialise(&file
));
65 TEST_F(TableDependenciesTest
, TestVheaGsub
) {
66 DROP_LAYOUT_TABLE(gsub
);
67 EXPECT_FALSE(ots::ots_vhea_should_serialise(&file
));
69 EXPECT_FALSE(ots::ots_vhea_should_serialise(&file
));
72 TEST_F(TableDependenciesTest
, TestVmtxGsub
) {
73 DROP_LAYOUT_TABLE(gsub
);
74 EXPECT_FALSE(ots::ots_vmtx_should_serialise(&file
));
76 EXPECT_FALSE(ots::ots_vmtx_should_serialise(&file
));