diff options
author | sidchat@chromium.org <sidchat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-07 19:55:15 +0000 |
---|---|---|
committer | sidchat@chromium.org <sidchat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-07 19:55:15 +0000 |
commit | 5ffc108781d1d439bb7800a38975c1d022044bee (patch) | |
tree | a8d0f00d494ab6ac3ad1e8e0b7dc511eef2d2992 /chrome/test/data/extensions | |
parent | 5aae4c66b3b7343677c64c4291982822459f2cba (diff) | |
download | chromium_src-5ffc108781d1d439bb7800a38975c1d022044bee.zip chromium_src-5ffc108781d1d439bb7800a38975c1d022044bee.tar.gz chromium_src-5ffc108781d1d439bb7800a38975c1d022044bee.tar.bz2 |
Change detectLanguage() API to now return the top three languages as well their percentages. Added suitable unit testing to test that top three languages are returned as expected.
BUG=20666
TEST=none
Review URL: http://codereview.chromium.org/223010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28293 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/data/extensions')
4 files changed, 33 insertions, 6 deletions
diff --git a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/three_languages.html b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/three_languages.html new file mode 100644 index 0000000..a4d4362 --- /dev/null +++ b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/three_languages.html @@ -0,0 +1,22 @@ +<!-- +Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this +source code is governed by a BSD-style license that can be found in the +LICENSE file. +--> +<html> +<body> +<p> +<!-- Sentence in French (Shortest) --> +Il s'agit d'une courte phrase en français qui ne signifie pas grand chose. +</p> +<p> +<!-- Sentence in English --> +This is simple and short sentence in English which is being used simply to guess what language this is. +</p> +<p> +<!-- Sentence in Italian (Longest) --> +Questa è una frase molto lunga lingua tedesca, e anche se non ha alcun senso, lo fa ancora lo scopo di verificare se questa cosa funziona a tutti o no. +</p> + +</body> +</html> diff --git a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html index 8fb82aa..f4746a4 100644 --- a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html +++ b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html @@ -14,8 +14,10 @@ function testTabsAPI() { // function to make sure it can be used as an extension API. This will pass if // the browser navigates to a page in French language before this is called. function testTabsLanguageAPI() { - chrome.tabs.detectLanguage(null, function(language) { - window.domAutomationController.send(language == 'fr'); + chrome.tabs.detectLanguage(null, function(topLanguages) { + window.domAutomationController.send(topLanguages[0].languageName == 'it' && + topLanguages[1].languageName == 'en' && + topLanguages[2].languageName == 'fr'); }); } diff --git a/chrome/test/data/extensions/samples/cld/manifest.json b/chrome/test/data/extensions/samples/cld/manifest.json index c0f20f2..cb8bf3e 100644 --- a/chrome/test/data/extensions/samples/cld/manifest.json +++ b/chrome/test/data/extensions/samples/cld/manifest.json @@ -1,6 +1,7 @@ { "name": "CLD", "description": "Returns language of a tab", - "version": "0.1", - "toolstrips": ["toolstrip.html"] + "version": "1.0", + "toolstrips": ["toolstrip.html"], + "permissions": ["tabs"] } diff --git a/chrome/test/data/extensions/samples/cld/toolstrip.html b/chrome/test/data/extensions/samples/cld/toolstrip.html index 03851c2b..b71a1f8 100644 --- a/chrome/test/data/extensions/samples/cld/toolstrip.html +++ b/chrome/test/data/extensions/samples/cld/toolstrip.html @@ -11,8 +11,10 @@ LICENSE file. var selectedId = -1; function refreshLanguage() { console.log("refeshing..."); - chrome.tabs.detectLanguage(null, function(language) { - document.getElementById("languageDiv").innerHTML = language; + chrome.tabs.detectLanguage(null, function(topLanguages) { + var dictionaryValue = topLanguages[0]; + document.getElementById("languageDiv").innerHTML = + dictionaryValue.languageName; }); } |