| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 fs.getFontList(chrome.test.callbackPass(function(value) { | 122 fs.getFontList(chrome.test.callbackPass(function(value) { |
| 123 chrome.test.assertTrue(value.length > 0, | 123 chrome.test.assertTrue(value.length > 0, |
| 124 'Font list is not expected to be empty.'); | 124 'Font list is not expected to be empty.'); |
| 125 chrome.test.assertEq('string', typeof(value[0].fontName), message); | 125 chrome.test.assertEq('string', typeof(value[0].fontName), message); |
| 126 chrome.test.assertEq('string', typeof(value[0].localizedName), message); | 126 chrome.test.assertEq('string', typeof(value[0].localizedName), message); |
| 127 })); | 127 })); |
| 128 }, | 128 }, |
| 129 | 129 |
| 130 function getPerScriptFontName() { | 130 function getPerScriptFontName() { |
| 131 fs.getFont({ | 131 fs.getFont({ |
| 132 script: 'Hang', | 132 script: 'Kore', |
| 133 genericFamily: 'standard' | 133 genericFamily: 'standard' |
| 134 }, expect({ | 134 }, expect({ |
| 135 fontName: 'Verdana', | 135 fontName: 'Verdana', |
| 136 levelOfControl: CONTROLLED_BY_THIS_EXTENSION | 136 levelOfControl: CONTROLLED_BY_THIS_EXTENSION |
| 137 })); | 137 })); |
| 138 }, | 138 }, |
| 139 | 139 |
| 140 function getGlobalFontName() { | 140 function getGlobalFontName() { |
| 141 fs.getFont({ | 141 fs.getFont({ |
| 142 genericFamily: 'sansserif' | 142 genericFamily: 'sansserif' |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 function getDefaultCharacterSet() { | 177 function getDefaultCharacterSet() { |
| 178 fs.getDefaultCharacterSet({}, expect({ | 178 fs.getDefaultCharacterSet({}, expect({ |
| 179 charset: 'GBK', | 179 charset: 'GBK', |
| 180 levelOfControl: CONTROLLED_BY_THIS_EXTENSION | 180 levelOfControl: CONTROLLED_BY_THIS_EXTENSION |
| 181 })); | 181 })); |
| 182 }, | 182 }, |
| 183 | 183 |
| 184 // This test may fail on Windows if the font is not installed on the | 184 // This test may fail on Windows if the font is not installed on the |
| 185 // system. See crbug.com/122303 | 185 // system. See crbug.com/122303 |
| 186 function clearPerScriptFont() { | 186 function clearPerScriptFont() { |
| 187 var script = 'Hang'; | 187 var script = 'Kore'; |
| 188 var genericFamily = 'standard'; | 188 var genericFamily = 'standard'; |
| 189 var fontName = 'Tahoma'; | 189 var fontName = 'Tahoma'; |
| 190 | 190 |
| 191 chrome.test.listenOnce(fs.onFontChanged, function(details) { | 191 chrome.test.listenOnce(fs.onFontChanged, function(details) { |
| 192 chrome.test.assertEq({ | 192 chrome.test.assertEq({ |
| 193 script: script, | 193 script: script, |
| 194 genericFamily: genericFamily, | 194 genericFamily: genericFamily, |
| 195 fontName: fontName, | 195 fontName: fontName, |
| 196 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 196 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 197 }, details); | 197 }, details); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 chrome.test.listenOnce(fs.onDefaultCharacterSetChanged, function(details) { | 265 chrome.test.listenOnce(fs.onDefaultCharacterSetChanged, function(details) { |
| 266 chrome.test.assertEq({ | 266 chrome.test.assertEq({ |
| 267 charset: charset, | 267 charset: charset, |
| 268 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 268 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 269 }, details); | 269 }, details); |
| 270 }); | 270 }); |
| 271 | 271 |
| 272 fs.clearDefaultCharacterSet({}, chrome.test.callbackPass()); | 272 fs.clearDefaultCharacterSet({}, chrome.test.callbackPass()); |
| 273 }, | 273 }, |
| 274 ]); | 274 ]); |
| OLD | NEW |