| 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 CONTROLLABLE_BY_THIS_EXTENSION = 'controllable_by_this_extension'; | 9 var CONTROLLABLE_BY_THIS_EXTENSION = 'controllable_by_this_extension'; |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // This test may fail on Windows if the font is not installed on | 51 // This test may fail on Windows if the font is not installed on |
| 52 // the system. See crbug.com/122303 | 52 // the system. See crbug.com/122303 |
| 53 function setGlobalFontName() { | 53 function setGlobalFontName() { |
| 54 var fontName = 'Tahoma'; | 54 var fontName = 'Tahoma'; |
| 55 var genericFamily = 'sansserif'; | 55 var genericFamily = 'sansserif'; |
| 56 | 56 |
| 57 chrome.test.listenOnce(fs.onFontChanged, function(details) { | 57 chrome.test.listenOnce(fs.onFontChanged, function(details) { |
| 58 chrome.test.assertEq({ | 58 chrome.test.assertEq({ |
| 59 genericFamily: genericFamily, | 59 genericFamily: genericFamily, |
| 60 fontName: fontName, | 60 fontName: fontName, |
| 61 script: 'Zyyy', |
| 61 levelOfControl: 'controlled_by_this_extension' | 62 levelOfControl: 'controlled_by_this_extension' |
| 62 }, details); | 63 }, details); |
| 63 }); | 64 }); |
| 64 | 65 |
| 65 fs.setFont({ | 66 fs.setFont({ |
| 66 genericFamily: 'sansserif', | 67 genericFamily: 'sansserif', |
| 67 fontName: 'Tahoma' | 68 fontName: 'Tahoma' |
| 68 }, chrome.test.callbackPass()); | 69 }, chrome.test.callbackPass()); |
| 69 }, | 70 }, |
| 70 | 71 |
| 71 function getGlobalFontName() { | 72 function getGlobalFontName() { |
| 72 var expected = 'Tahoma'; | 73 var expected = 'Tahoma'; |
| 73 var message = | 74 var message = |
| 74 'Setting for global sansserif font should be ' + expected; | 75 'Setting for global sansserif font should be ' + expected; |
| 75 | 76 |
| 76 fs.getFont({ | 77 fs.getFont({ |
| 77 genericFamily: 'sansserif' | 78 genericFamily: 'sansserif' |
| 78 }, expect({fontName: expected}, message)); | 79 }, expect({fontName: expected}, message)); |
| 79 }, | 80 }, |
| 80 | 81 |
| 81 function getFontList() { | 82 function getFontList() { |
| 82 var message = 'getFontList should return an array of objects with ' + | 83 var message = 'getFontList should return an array of objects with ' + |
| 83 'fontName and localizedName properties.'; | 84 'fontName and localizedName properties.'; |
| 84 fs.getFontList(chrome.test.callbackPass(function(value) { | 85 fs.getFontList(chrome.test.callbackPass(function(value) { |
| 85 chrome.test.assertTrue(value.length > 0, | 86 chrome.test.assertTrue(value.length > 0, |
| 86 "Font list is not expected to be empty."); | 87 'Font list is not expected to be empty.'); |
| 87 chrome.test.assertEq('string', typeof(value[0].fontName), message); | 88 chrome.test.assertEq('string', typeof(value[0].fontName), message); |
| 88 chrome.test.assertEq('string', typeof(value[0].localizedName), message); | 89 chrome.test.assertEq('string', typeof(value[0].localizedName), message); |
| 89 })); | 90 })); |
| 90 }, | 91 }, |
| 91 | 92 |
| 92 function setDefaultFontSize() { | 93 function setDefaultFontSize() { |
| 93 var pixelSize = 22; | 94 var pixelSize = 22; |
| 94 chrome.test.listenOnce(fs.onDefaultFontSizeChanged, function(details) { | 95 chrome.test.listenOnce(fs.onDefaultFontSizeChanged, function(details) { |
| 95 chrome.test.assertEq({ | 96 chrome.test.assertEq({ |
| 96 pixelSize: pixelSize, | 97 pixelSize: pixelSize, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 194 |
| 194 fs.clearFont({ | 195 fs.clearFont({ |
| 195 script: script, | 196 script: script, |
| 196 genericFamily: genericFamily, | 197 genericFamily: genericFamily, |
| 197 }, chrome.test.callbackPass()); | 198 }, chrome.test.callbackPass()); |
| 198 }, | 199 }, |
| 199 | 200 |
| 200 // This test may fail on Windows if the font is not installed on the | 201 // This test may fail on Windows if the font is not installed on the |
| 201 // system. See crbug.com/122303 | 202 // system. See crbug.com/122303 |
| 202 function clearGlobalFont() { | 203 function clearGlobalFont() { |
| 204 var script = 'Zyyy'; |
| 203 var genericFamily = 'sansserif'; | 205 var genericFamily = 'sansserif'; |
| 204 var fontName = 'Arial'; | 206 var fontName = 'Arial'; |
| 205 | 207 |
| 206 chrome.test.listenOnce(fs.onFontChanged, function(details) { | 208 chrome.test.listenOnce(fs.onFontChanged, function(details) { |
| 207 chrome.test.assertEq({ | 209 chrome.test.assertEq({ |
| 210 script: script, |
| 208 genericFamily: genericFamily, | 211 genericFamily: genericFamily, |
| 209 fontName: fontName, | 212 fontName: fontName, |
| 210 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 213 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 211 }, details); | 214 }, details); |
| 212 }); | 215 }); |
| 213 | 216 |
| 214 fs.clearFont({ | 217 fs.clearFont({ |
| 215 genericFamily: genericFamily, | 218 genericFamily: genericFamily, |
| 216 }, chrome.test.callbackPass()); | 219 }, chrome.test.callbackPass()); |
| 217 }, | 220 }, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 chrome.test.listenOnce(fs.onDefaultCharacterSetChanged, function(details) { | 260 chrome.test.listenOnce(fs.onDefaultCharacterSetChanged, function(details) { |
| 258 chrome.test.assertEq({ | 261 chrome.test.assertEq({ |
| 259 charset: charset, | 262 charset: charset, |
| 260 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 263 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 261 }, details); | 264 }, details); |
| 262 }); | 265 }); |
| 263 | 266 |
| 264 fs.clearDefaultCharacterSet({}, chrome.test.callbackPass()); | 267 fs.clearDefaultCharacterSet({}, chrome.test.callbackPass()); |
| 265 }, | 268 }, |
| 266 ]); | 269 ]); |
| OLD | NEW |