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
3 // found in the LICENSE file.
6 // browser_tests.exe --gtest_filter=ExtensionApiTest.I18N --lib=browser_tests
8 var testCallback = chrome.test.testCallback;
9 var callbackPass = chrome.test.callbackPass;
11 chrome.test.getConfig(function(config) {
13 var TEST_FILE_URL = "http://localhost:PORT/extensions/test_file.html"
14 .replace(/PORT/, config.testServer.port);
16 chrome.test.runTests([
17 function getAcceptLanguages() {
18 chrome.i18n.getAcceptLanguages(callbackPass(function(results) {
19 chrome.test.assertEq(results.length, 2);
20 chrome.test.assertEq(results[0], "en-US");
21 chrome.test.assertEq(results[1], "en");
24 function getMessage() {
25 var message = chrome.i18n.getMessage("simple_message");
26 chrome.test.assertEq(message, "Simple message");
28 message = chrome.i18n.getMessage("message_with_placeholders",
30 chrome.test.assertEq(message, "Cira and John work for Google");
32 message = chrome.i18n.getMessage("message_with_one_placeholder", "19");
33 chrome.test.assertEq(message, "Number of errors: 19");
35 message = chrome.i18n.getMessage("message_with_double_dollar_sign");
36 chrome.test.assertEq(message, "I need $500 please.");
38 message = chrome.i18n.getMessage(
39 "message_with_double_dollar_sign_and_placeholders",
40 ["Mitchell", "Chris"]);
41 chrome.test.assertEq(message,
42 "We should really be paying Mitchell and Chris more $$$.");
44 chrome.test.succeed();
46 function getMessageFromContentScript() {
47 chrome.extension.onRequest.addListener(
48 function(request, sender, sendResponse) {
49 chrome.test.assertEq(request, "Number of errors: 19");
52 chrome.test.log("Creating tab...");
56 chrome.test.succeed();
58 function getUILanguage() {
59 chrome.test.assertEq('en-US', chrome.i18n.getUILanguage());
60 chrome.test.succeed();