genericfontnames_test.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright 2008 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. goog.provide('goog.locale.genericFontNamesTest');
  15. goog.setTestOnly('goog.locale.genericFontNamesTest');
  16. goog.require('goog.locale.genericFontNames');
  17. goog.require('goog.testing.jsunit');
  18. goog.locale.genericFontNames.data_['zh_TW'] = [
  19. {
  20. 'caption': '\u5fae\u8edf\u6b63\u9ed1\u9ad4',
  21. 'value': 'Microsoft JhengHei,\u5fae\u8edf\u6b63\u9ed1\u9ad4,SimHei,' +
  22. '\u9ed1\u4f53,MS Hei,STHeiti,\u534e\u6587\u9ed1\u4f53,Apple ' +
  23. 'LiGothic Medium,\u860b\u679c\u5137\u4e2d\u9ed1,LiHei Pro Medium,' +
  24. '\u5137\u9ed1 Pro,STHeiti Light,\u534e\u6587\u7ec6\u9ed1,AR PL ' +
  25. 'ZenKai Uni,\u6587\u9f0ePL\u4e2d\u6977Uni,FreeSans,sans-serif'
  26. },
  27. {
  28. 'caption': '\u5fae\u8f6f\u96c5\u9ed1\u5b57\u4f53',
  29. 'value': 'Microsoft sans-serif,\u5fae\u8f6f\u96c5\u9ed1\u5b57\u4f53,FreeSans,' +
  30. 'sans-serif'
  31. },
  32. {
  33. 'caption': '\u65b0\u7d30\u660e\u9ad4',
  34. 'value': 'SimSun,\u5b8b\u4f53,MS Song,STSong,\u534e\u6587\u5b8b\u4f53,' +
  35. 'Apple LiSung Light,\u860b\u679c\u5137\u7d30\u5b8b,LiSong Pro Light,' +
  36. '\u5137\u5b8b Pro,STFangSong,\u534e\u6587\u4eff\u5b8b,AR PL ' +
  37. 'ShanHeiSun Uni,\u6587\u9f0eP' +
  38. 'L\u7ec6\u4e0a\u6d77\u5b8bUni,AR PL New Sung,\u6587\u9f0e PL \u65b0' +
  39. '\u5b8b,FreeSerif,serif'
  40. },
  41. {
  42. 'caption': '\u7d30\u660e\u9ad4',
  43. 'value': 'NSimsun,\u65b0\u5b8b\u4f53,FreeMono,monospace'
  44. }
  45. ];
  46. function testNormalize() {
  47. var result = goog.locale.genericFontNames.normalize_('zh');
  48. assertEquals('zh', result);
  49. var result = goog.locale.genericFontNames.normalize_('zh-hant');
  50. assertEquals('zh_Hant', result);
  51. var result = goog.locale.genericFontNames.normalize_('zh-hant-tw');
  52. assertEquals('zh_Hant_TW', result);
  53. }
  54. function testInvalid() {
  55. var result = goog.locale.genericFontNames.getList('invalid');
  56. assertArrayEquals([], result);
  57. }
  58. function testZhHant() {
  59. var result = goog.locale.genericFontNames.getList('zh-tw');
  60. assertObjectEquals(
  61. [
  62. {
  63. 'caption': '\u5fae\u8edf\u6b63\u9ed1\u9ad4',
  64. 'value': 'Microsoft JhengHei,\u5fae\u8edf\u6b63\u9ed1\u9ad4,SimHei,' +
  65. '\u9ed1\u4f53,MS Hei,STHeiti,\u534e\u6587\u9ed1\u4f53,Apple ' +
  66. 'LiGothic Medium,\u860b\u679c\u5137\u4e2d\u9ed1,LiHei Pro Medium,' +
  67. '\u5137\u9ed1 Pro,STHeiti Light,\u534e\u6587\u7ec6\u9ed1,AR PL ' +
  68. 'ZenKai Uni,\u6587\u9f0ePL\u4e2d\u6977Uni,FreeSans,sans-serif'
  69. },
  70. {
  71. 'caption': '\u5fae\u8f6f\u96c5\u9ed1\u5b57\u4f53',
  72. 'value': 'Microsoft sans-serif,\u5fae\u8f6f\u96c5\u9ed1\u5b57\u4f53,' +
  73. 'FreeSans,sans-serif'
  74. },
  75. {
  76. 'caption': '\u65b0\u7d30\u660e\u9ad4',
  77. 'value':
  78. 'SimSun,\u5b8b\u4f53,MS Song,STSong,\u534e\u6587\u5b8b\u4f53,' +
  79. 'Apple LiSung Light,\u860b\u679c\u5137\u7d30\u5b8b,LiSong Pro ' +
  80. 'Light,\u5137\u5b8b Pro,STFangSong,\u534e\u6587\u4eff\u5b8b,AR PL ' +
  81. 'ShanHeiSun Uni,\u6587\u9f0ePL\u7ec6\u4e0a\u6d77\u5b8bUni,AR PL New' +
  82. ' Sung,\u6587\u9f0e PL \u65b0\u5b8b,FreeSerif,serif'
  83. },
  84. {
  85. 'caption': '\u7d30\u660e\u9ad4',
  86. 'value': 'NSimsun,\u65b0\u5b8b\u4f53,FreeMono,monospace'
  87. }
  88. ],
  89. result);
  90. }