| 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'; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // This test may fail on Windows if the font is not installed on | 42 // This test may fail on Windows if the font is not installed on |
| 43 // the system. See crbug.com/122303 | 43 // the system. See crbug.com/122303 |
| 44 function setGlobalFontName() { | 44 function setGlobalFontName() { |
| 45 var genericFamily = 'sansserif'; | 45 var genericFamily = 'sansserif'; |
| 46 var fontName = 'Tahoma'; | 46 var fontName = 'Tahoma'; |
| 47 | 47 |
| 48 chrome.test.listenOnce(fs.onFontChanged, function(details) { | 48 chrome.test.listenOnce(fs.onFontChanged, function(details) { |
| 49 chrome.test.assertEq({ | 49 chrome.test.assertEq({ |
| 50 genericFamily: genericFamily, | 50 genericFamily: genericFamily, |
| 51 fontName: fontName, | 51 fontName: fontName, |
| 52 script: 'Zyyy', |
| 52 levelOfControl: CONTROLLED_BY_THIS_EXTENSION | 53 levelOfControl: CONTROLLED_BY_THIS_EXTENSION |
| 53 }, details); | 54 }, details); |
| 54 }); | 55 }); |
| 55 | 56 |
| 56 fs.setFont({ | 57 fs.setFont({ |
| 57 genericFamily: genericFamily, | 58 genericFamily: genericFamily, |
| 58 fontName: fontName | 59 fontName: fontName |
| 59 }, chrome.test.callbackPass()); | 60 }, chrome.test.callbackPass()); |
| 60 }, | 61 }, |
| 61 | 62 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 fs.setDefaultCharacterSet({ | 114 fs.setDefaultCharacterSet({ |
| 114 charset: charset | 115 charset: charset |
| 115 }, chrome.test.callbackPass()); | 116 }, chrome.test.callbackPass()); |
| 116 }, | 117 }, |
| 117 | 118 |
| 118 function getFontList() { | 119 function getFontList() { |
| 119 var message = 'getFontList should return an array of objects with ' + | 120 var message = 'getFontList should return an array of objects with ' + |
| 120 'fontName and localizedName properties.'; | 121 'fontName and localizedName properties.'; |
| 121 fs.getFontList(chrome.test.callbackPass(function(value) { | 122 fs.getFontList(chrome.test.callbackPass(function(value) { |
| 122 chrome.test.assertTrue(value.length > 0, | 123 chrome.test.assertTrue(value.length > 0, |
| 123 "Font list is not expected to be empty."); | 124 'Font list is not expected to be empty.'); |
| 124 chrome.test.assertEq('string', typeof(value[0].fontName), message); | 125 chrome.test.assertEq('string', typeof(value[0].fontName), message); |
| 125 chrome.test.assertEq('string', typeof(value[0].localizedName), message); | 126 chrome.test.assertEq('string', typeof(value[0].localizedName), message); |
| 126 })); | 127 })); |
| 127 }, | 128 }, |
| 128 | 129 |
| 129 function getPerScriptFontName() { | 130 function getPerScriptFontName() { |
| 130 fs.getFont({ | 131 fs.getFont({ |
| 131 script: 'Hang', | 132 script: 'Hang', |
| 132 genericFamily: 'standard' | 133 genericFamily: 'standard' |
| 133 }, expect({ | 134 }, expect({ |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 199 |
| 199 fs.clearFont({ | 200 fs.clearFont({ |
| 200 script: script, | 201 script: script, |
| 201 genericFamily: genericFamily, | 202 genericFamily: genericFamily, |
| 202 }, chrome.test.callbackPass()); | 203 }, chrome.test.callbackPass()); |
| 203 }, | 204 }, |
| 204 | 205 |
| 205 // This test may fail on Windows if the font is not installed on the | 206 // This test may fail on Windows if the font is not installed on the |
| 206 // system. See crbug.com/122303 | 207 // system. See crbug.com/122303 |
| 207 function clearGlobalFont() { | 208 function clearGlobalFont() { |
| 209 var script = 'Zyyy'; |
| 208 var genericFamily = 'sansserif'; | 210 var genericFamily = 'sansserif'; |
| 209 var fontName = 'Arial'; | 211 var fontName = 'Arial'; |
| 210 | 212 |
| 211 chrome.test.listenOnce(fs.onFontChanged, function(details) { | 213 chrome.test.listenOnce(fs.onFontChanged, function(details) { |
| 212 chrome.test.assertEq({ | 214 chrome.test.assertEq({ |
| 215 script: script, |
| 213 genericFamily: genericFamily, | 216 genericFamily: genericFamily, |
| 214 fontName: fontName, | 217 fontName: fontName, |
| 215 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 218 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 216 }, details); | 219 }, details); |
| 217 }); | 220 }); |
| 218 | 221 |
| 219 fs.clearFont({ | 222 fs.clearFont({ |
| 220 genericFamily: genericFamily, | 223 genericFamily: genericFamily, |
| 221 }, chrome.test.callbackPass()); | 224 }, chrome.test.callbackPass()); |
| 222 }, | 225 }, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 chrome.test.listenOnce(fs.onDefaultCharacterSetChanged, function(details) { | 265 chrome.test.listenOnce(fs.onDefaultCharacterSetChanged, function(details) { |
| 263 chrome.test.assertEq({ | 266 chrome.test.assertEq({ |
| 264 charset: charset, | 267 charset: charset, |
| 265 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 268 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 266 }, details); | 269 }, details); |
| 267 }); | 270 }); |
| 268 | 271 |
| 269 fs.clearDefaultCharacterSet({}, chrome.test.callbackPass()); | 272 fs.clearDefaultCharacterSet({}, chrome.test.callbackPass()); |
| 270 }, | 273 }, |
| 271 ]); | 274 ]); |
| OLD | NEW |