| 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 var CONTROLLED_BY_THIS_EXTENSION = 'controlled_by_this_extension'; | 9 var CONTROLLED_BY_THIS_EXTENSION = 'controlled_by_this_extension'; |
| 10 var CONTROLLABLE_BY_THIS_EXTENSION = 'controllable_by_this_extension'; | 10 var CONTROLLABLE_BY_THIS_EXTENSION = 'controllable_by_this_extension'; |
| 11 | 11 |
| 12 function expect(expected, message) { | 12 function expect(expected, message) { |
| 13 return chrome.test.callbackPass(function(value) { | 13 return chrome.test.callbackPass(function(value) { |
| 14 chrome.test.assertEq(expected, value, message); | 14 chrome.test.assertEq(expected, value, message); |
| 15 }); | 15 }); |
| 16 } | 16 } |
| 17 | 17 |
| 18 chrome.test.runTests([ | 18 chrome.test.runTests([ |
| 19 // This test may fail on Windows if the font is not installed on the | 19 // This test may fail on Windows if the font is not installed on the |
| 20 // system. See crbug.com/122303 | 20 // system. See crbug.com/122303 |
| 21 function setPerScriptFont() { | 21 function setPerScriptFont() { |
| 22 var script = 'Hang'; | 22 var script = 'Kore'; |
| 23 var genericFamily = 'standard'; | 23 var genericFamily = 'standard'; |
| 24 var fontName = 'Verdana'; | 24 var fontName = 'Verdana'; |
| 25 | 25 |
| 26 chrome.test.listenOnce(fs.onFontChanged, function(details) { | 26 chrome.test.listenOnce(fs.onFontChanged, function(details) { |
| 27 chrome.test.assertEq({ | 27 chrome.test.assertEq({ |
| 28 script: script, | 28 script: script, |
| 29 genericFamily: genericFamily, | 29 genericFamily: genericFamily, |
| 30 fontName: fontName, | 30 fontName: fontName, |
| 31 levelOfControl: CONTROLLED_BY_THIS_EXTENSION | 31 levelOfControl: CONTROLLED_BY_THIS_EXTENSION |
| 32 }, details); | 32 }, details); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 fs.getFontList(chrome.test.callbackPass(function(value) { | 108 fs.getFontList(chrome.test.callbackPass(function(value) { |
| 109 chrome.test.assertTrue(value.length > 0, | 109 chrome.test.assertTrue(value.length > 0, |
| 110 'Font list is not expected to be empty.'); | 110 'Font list is not expected to be empty.'); |
| 111 chrome.test.assertEq('string', typeof(value[0].fontName), message); | 111 chrome.test.assertEq('string', typeof(value[0].fontName), message); |
| 112 chrome.test.assertEq('string', typeof(value[0].localizedName), message); | 112 chrome.test.assertEq('string', typeof(value[0].localizedName), message); |
| 113 })); | 113 })); |
| 114 }, | 114 }, |
| 115 | 115 |
| 116 function getPerScriptFontName() { | 116 function getPerScriptFontName() { |
| 117 fs.getFont({ | 117 fs.getFont({ |
| 118 script: 'Hang', | 118 script: 'Kore', |
| 119 genericFamily: 'standard' | 119 genericFamily: 'standard' |
| 120 }, expect({ | 120 }, expect({ |
| 121 fontName: 'Verdana', | 121 fontName: 'Verdana', |
| 122 levelOfControl: CONTROLLED_BY_THIS_EXTENSION | 122 levelOfControl: CONTROLLED_BY_THIS_EXTENSION |
| 123 })); | 123 })); |
| 124 }, | 124 }, |
| 125 | 125 |
| 126 function getGlobalFontName() { | 126 function getGlobalFontName() { |
| 127 fs.getFont({ | 127 fs.getFont({ |
| 128 genericFamily: 'sansserif' | 128 genericFamily: 'sansserif' |
| (...skipping 27 matching lines...) Expand all Loading... |
| 156 function getMinimumFontSize() { | 156 function getMinimumFontSize() { |
| 157 fs.getMinimumFontSize({}, expect({ | 157 fs.getMinimumFontSize({}, expect({ |
| 158 pixelSize: 7, | 158 pixelSize: 7, |
| 159 levelOfControl: CONTROLLED_BY_THIS_EXTENSION | 159 levelOfControl: CONTROLLED_BY_THIS_EXTENSION |
| 160 })); | 160 })); |
| 161 }, | 161 }, |
| 162 | 162 |
| 163 // This test may fail on Windows if the font is not installed on the | 163 // This test may fail on Windows if the font is not installed on the |
| 164 // system. See crbug.com/122303 | 164 // system. See crbug.com/122303 |
| 165 function clearPerScriptFont() { | 165 function clearPerScriptFont() { |
| 166 var script = 'Hang'; | 166 var script = 'Kore'; |
| 167 var genericFamily = 'standard'; | 167 var genericFamily = 'standard'; |
| 168 var fontName = 'Tahoma'; | 168 var fontName = 'Tahoma'; |
| 169 | 169 |
| 170 chrome.test.listenOnce(fs.onFontChanged, function(details) { | 170 chrome.test.listenOnce(fs.onFontChanged, function(details) { |
| 171 chrome.test.assertEq({ | 171 chrome.test.assertEq({ |
| 172 script: script, | 172 script: script, |
| 173 genericFamily: genericFamily, | 173 genericFamily: genericFamily, |
| 174 fontName: fontName, | 174 fontName: fontName, |
| 175 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 175 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 176 }, details); | 176 }, details); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 chrome.test.listenOnce(fs.onMinimumFontSizeChanged, function(details) { | 232 chrome.test.listenOnce(fs.onMinimumFontSizeChanged, function(details) { |
| 233 chrome.test.assertEq({ | 233 chrome.test.assertEq({ |
| 234 pixelSize: pixelSize, | 234 pixelSize: pixelSize, |
| 235 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 235 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 236 }, details); | 236 }, details); |
| 237 }); | 237 }); |
| 238 | 238 |
| 239 fs.clearMinimumFontSize({}, chrome.test.callbackPass()); | 239 fs.clearMinimumFontSize({}, chrome.test.callbackPass()); |
| 240 } | 240 } |
| 241 ]); | 241 ]); |
| OLD | NEW |