| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Font settings API test | 5 // Font settings API test |
| 6 // Run with browser_tests --gtest_filter=ExtensionApiTest.FontSettings | 6 // Run with browser_tests --gtest_filter=ExtensionApiTest.FontSettings |
| 7 | 7 |
| 8 var fs = chrome.experimental.fontSettings; | 8 var fs = chrome.experimental.fontSettings; |
| 9 | 9 |
| 10 function expect(expected, message) { | 10 function expect(expected, message) { |
| 11 return chrome.test.callbackPass(function(value) { | 11 return chrome.test.callbackPass(function(value) { |
| 12 chrome.test.assertEq(expected, value, message); | 12 chrome.test.assertEq(expected, value, message); |
| 13 }); | 13 }); |
| 14 } | 14 } |
| 15 | 15 |
| 16 chrome.test.runTests([ | 16 chrome.test.runTests([ |
| 17 // This test may fail on Windows if the font is not installed on the |
| 18 // system. See crbug.com/122303 |
| 17 function setPerScriptFontName() { | 19 function setPerScriptFontName() { |
| 20 var script = 'Hang'; |
| 21 var genericFamily = 'standard'; |
| 22 var fontName = 'Verdana'; |
| 23 |
| 24 chrome.test.listenOnce(fs.onFontNameChanged, function(details) { |
| 25 chrome.test.assertEq(details, { |
| 26 script: script, |
| 27 genericFamily: genericFamily, |
| 28 fontName: fontName, |
| 29 levelOfControl: 'controlled_by_this_extension' |
| 30 }); |
| 31 }); |
| 32 |
| 18 fs.setFontName({ | 33 fs.setFontName({ |
| 19 script: 'Hang', | 34 script: script, |
| 20 genericFamily: 'standard', | 35 genericFamily: genericFamily, |
| 21 fontName: 'Verdana' | 36 fontName: fontName |
| 22 }, chrome.test.callbackPass()); | 37 }, chrome.test.callbackPass()); |
| 23 }, | 38 }, |
| 24 | 39 |
| 25 function getPerScriptFontName() { | 40 function getPerScriptFontName() { |
| 26 var expected = 'Verdana'; | 41 var expected = 'Verdana'; |
| 27 var message = 'Setting for Hangul standard font should be ' + expected; | 42 var message = 'Setting for Hangul standard font should be ' + expected; |
| 28 | 43 |
| 29 // This test may fail on Windows if the font is not installed on the | |
| 30 // system. See crbug.com/122303 | |
| 31 fs.getFontName({ | 44 fs.getFontName({ |
| 32 script: 'Hang', | 45 script: 'Hang', |
| 33 genericFamily: 'standard' | 46 genericFamily: 'standard' |
| 34 }, expect({fontName: expected}, message)); | 47 }, expect({fontName: expected}, message)); |
| 35 }, | 48 }, |
| 36 | 49 |
| 50 // This test may fail on Windows if the font is not installed on |
| 51 // the system. See crbug.com/122303 |
| 37 function setGlobalFontName() { | 52 function setGlobalFontName() { |
| 53 var fontName = 'Tahoma'; |
| 54 var genericFamily = 'sansserif'; |
| 55 |
| 56 chrome.test.listenOnce(fs.onFontNameChanged, function(details) { |
| 57 chrome.test.assertEq(details, { |
| 58 genericFamily: genericFamily, |
| 59 fontName: fontName, |
| 60 levelOfControl: 'controlled_by_this_extension' |
| 61 }); |
| 62 }); |
| 63 |
| 38 fs.setFontName({ | 64 fs.setFontName({ |
| 39 genericFamily: 'sansserif', | 65 genericFamily: 'sansserif', |
| 40 fontName: 'Tahoma' | 66 fontName: 'Tahoma' |
| 41 }, chrome.test.callbackPass()); | 67 }, chrome.test.callbackPass()); |
| 42 }, | 68 }, |
| 43 | 69 |
| 44 function getGlobalFontName() { | 70 function getGlobalFontName() { |
| 45 var expected = 'Tahoma'; | 71 var expected = 'Tahoma'; |
| 46 var message = | 72 var message = |
| 47 'Setting for global sansserif font should be ' + expected; | 73 'Setting for global sansserif font should be ' + expected; |
| 48 | 74 |
| 49 // As above, this test may fail on Windows if the font is not installed on | |
| 50 // the system. See crbug.com/122303 | |
| 51 fs.getFontName({ | 75 fs.getFontName({ |
| 52 genericFamily: 'sansserif' | 76 genericFamily: 'sansserif' |
| 53 }, expect({fontName: expected}, message)); | 77 }, expect({fontName: expected}, message)); |
| 54 }, | 78 }, |
| 55 | 79 |
| 56 function getFontList() { | 80 function getFontList() { |
| 57 var message = 'getFontList should return an array of objects with ' + | 81 var message = 'getFontList should return an array of objects with ' + |
| 58 'fontName and localizedName properties.'; | 82 'fontName and localizedName properties.'; |
| 59 fs.getFontList(chrome.test.callbackPass(function(value) { | 83 fs.getFontList(chrome.test.callbackPass(function(value) { |
| 60 chrome.test.assertTrue(value.length > 0, | 84 chrome.test.assertTrue(value.length > 0, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 var message = 'Setting for default fixed font size should be ' + expected; | 123 var message = 'Setting for default fixed font size should be ' + expected; |
| 100 fs.getDefaultFixedFontSize({}, expect({pixelSize: expected}, message)); | 124 fs.getDefaultFixedFontSize({}, expect({pixelSize: expected}, message)); |
| 101 }, | 125 }, |
| 102 | 126 |
| 103 function getMinimumFontSize() { | 127 function getMinimumFontSize() { |
| 104 var expected = 7; | 128 var expected = 7; |
| 105 var message = 'Setting for minimum font size should be ' + expected; | 129 var message = 'Setting for minimum font size should be ' + expected; |
| 106 fs.getMinimumFontSize({}, expect({pixelSize: expected}, message)); | 130 fs.getMinimumFontSize({}, expect({pixelSize: expected}, message)); |
| 107 } | 131 } |
| 108 ]); | 132 ]); |
| OLD | NEW |