OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include <gtest/gtest.h> |
| 6 |
| 7 #include "gsub.h" |
| 8 #include "ots.h" |
| 9 #include "ots-memory-stream.h" |
| 10 #include "vhea.h" |
| 11 #include "vmtx.h" |
| 12 |
| 13 #define SET_TABLE(name, capname) \ |
| 14 do { file.name = new ots::OpenType##capname; } while (0) |
| 15 #define SET_LAYOUT_TABLE(name, capname) \ |
| 16 do { \ |
| 17 if (!file.name) { \ |
| 18 SET_TABLE(name, capname); \ |
| 19 } \ |
| 20 file.name->data = reinterpret_cast<const uint8_t*>(1); \ |
| 21 file.name->length = 1; \ |
| 22 } while (0) |
| 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) |
| 27 |
| 28 namespace { |
| 29 |
| 30 class TableDependenciesTest : public ::testing::Test { |
| 31 protected: |
| 32 virtual void SetUp() { |
| 33 SET_LAYOUT_TABLE(gsub, GSUB); |
| 34 SET_TABLE(vhea, VHEA); |
| 35 SET_TABLE(vmtx, VMTX); |
| 36 } |
| 37 |
| 38 virtual void TearDown() { |
| 39 DROP_TABLE(gsub); |
| 40 DROP_TABLE(vhea); |
| 41 DROP_TABLE(vmtx); |
| 42 } |
| 43 ots::OpenTypeFile file; |
| 44 }; |
| 45 } // namespace |
| 46 |
| 47 TEST_F(TableDependenciesTest, TestVhea) { |
| 48 EXPECT_TRUE(ots::ots_vhea_should_serialise(&file)); |
| 49 } |
| 50 |
| 51 TEST_F(TableDependenciesTest, TestVmtx) { |
| 52 EXPECT_TRUE(ots::ots_vmtx_should_serialise(&file)); |
| 53 } |
| 54 |
| 55 TEST_F(TableDependenciesTest, TestVheaVmtx) { |
| 56 DROP_TABLE(vmtx); |
| 57 EXPECT_FALSE(ots::ots_vhea_should_serialise(&file)); |
| 58 } |
| 59 |
| 60 TEST_F(TableDependenciesTest, TestVmtxVhea) { |
| 61 DROP_TABLE(vhea); |
| 62 EXPECT_FALSE(ots::ots_vmtx_should_serialise(&file)); |
| 63 } |
| 64 |
| 65 TEST_F(TableDependenciesTest, TestVheaGsub) { |
| 66 DROP_LAYOUT_TABLE(gsub); |
| 67 EXPECT_FALSE(ots::ots_vhea_should_serialise(&file)); |
| 68 DROP_TABLE(gsub); |
| 69 EXPECT_FALSE(ots::ots_vhea_should_serialise(&file)); |
| 70 } |
| 71 |
| 72 TEST_F(TableDependenciesTest, TestVmtxGsub) { |
| 73 DROP_LAYOUT_TABLE(gsub); |
| 74 EXPECT_FALSE(ots::ots_vmtx_should_serialise(&file)); |
| 75 DROP_TABLE(gsub); |
| 76 EXPECT_FALSE(ots::ots_vmtx_should_serialise(&file)); |
| 77 } |
| 78 |
OLD | NEW |