Commit 6a507318 authored by dino@apple.com's avatar dino@apple.com
Browse files

Track menu needs localization

https://bugs.webkit.org/show_bug.cgi?id=105233

Reviewed by Eric Carlson.

Source/WebCore:

Allow the UI strings in the closed captions menu to be localized, and
profile strings for the English locale.

Test: media/video-controls-captions-trackmenu-localized.html

* English.lproj/Localizable.strings: Adds the four new captions strings.
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu): Use localized getters.
* platform/LocalizedStrings.cpp:
(WebCore::textTrackClosedCaptionsText): New localized string getter.
(WebCore::textTrackSubtitlesText): Ditto.
(WebCore::textTrackOffText): Ditto.
(WebCore::textTrackNoLabelText): Ditto.
* platform/LocalizedStrings.h:

LayoutTests:

Test to exercise the localization of strings in the captions menu.
While I was here I merged some common code into a helper file.

* media/trackmenu-test.js: Added. New helper file to run common test operations.
* media/video-controls-captions-trackmenu-localized-expected.txt: Added.
* media/video-controls-captions-trackmenu-localized.html: Added.
* media/video-controls-captions-trackmenu-sorted.html: Updated to use helper functions.
* platform/chromium/TestExpectations: Skip unimplemented test.
* platform/efl/TestExpectations: Ditto.
* platform/gtk/TestExpectations: Ditto.
* platform/qt/TestExpectations: Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138071 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 75e8291d
2012-12-18 Dean Jackson <dino@apple.com>
Track menu needs localization
https://bugs.webkit.org/show_bug.cgi?id=105233
Reviewed by Eric Carlson.
Test to exercise the localization of strings in the captions menu.
While I was here I merged some common code into a helper file.
* media/trackmenu-test.js: Added. New helper file to run common test operations.
* media/video-controls-captions-trackmenu-localized-expected.txt: Added.
* media/video-controls-captions-trackmenu-localized.html: Added.
* media/video-controls-captions-trackmenu-sorted.html: Updated to use helper functions.
* platform/chromium/TestExpectations: Skip unimplemented test.
* platform/efl/TestExpectations: Ditto.
* platform/gtk/TestExpectations: Ditto.
* platform/qt/TestExpectations: Ditto.
2012-12-18 Beth Dakin <bdakin@apple.com>
 
https://bugs.webkit.org/show_bug.cgi?id=102579
var captionsButtonCoordinates;
function clickCCButton()
{
eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordinates[1]);
eventSender.mouseDown();
eventSender.mouseUp();
}
function startTrackMenuTest(testFunction)
{
if (window.eventSender) {
consoleWrite("<br>*** Set the user language preference.");
run("internals.setUserPreferredLanguages(['en'])");
try {
captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggle-closed-captions-button");
} catch (exception) {
failTest(exception.description);
return;
}
clickCCButton();
window.setTimeout(testFunction, 100);
}
}
function getTrackListElement()
{
var trackListElement;
try {
trackListElement = mediaControlsElement(internals.shadowRoot(video).firstChild, "-webkit-media-controls-closed-captions-track-list");
} catch (exception) {
failTest(exception.description);
return null;
}
return trackListElement;
}
Test that captions and subtitles menu items are localized.
EVENT(canplaythrough)
*** Set the user language preference.
RUN(internals.setUserPreferredLanguages(['en']))
EXPECTED (captionsSection.textContent == 'Closed Captions') OK
EXPECTED (captionsSection.textContent == 'Subtitles') OK
EXPECTED (item.textContent == 'Off') OK
EXPECTED (item.textContent == 'No label') OK
END OF TEST
<!DOCTYPE html>
<html>
<head>
<title>Testing that the track menu gets localized strings</title>
<script src="media-controls.js"></script>
<script src="media-file.js"></script>
<script src="video-test.js"></script>
<script src="trackmenu-test.js"></script>
<script>
var captionsSection;
var item;
if (window.testRunner)
testRunner.dumpAsText();
function testMenuHeaders()
{
var trackListElement = getTrackListElement();
if (!trackListElement)
return;
// Track list should have two <section> elements.
var trackListSections = trackListElement.querySelectorAll("h3");
if (!trackListSections || trackListSections.length != 2) {
failTest("There should be two section elements in track list menu");
return;
}
captionsSection = trackListSections[0];
logConsole("First section should be labelled 'Closed Captions'");
testExpected("captionsSection.textContent", "Closed Captions");
captionsSection = trackListSections[1];
logConsole("Second section should be labelled 'Subtitles'");
testExpected("captionsSection.textContent", "Subtitles");
var captionsEntries = trackListElement.querySelectorAll("li");
if (!captionsEntries || captionsEntries.length <= 0) {
failTest("Not enough items in captions menu");
return;
}
item = captionsEntries[0];
logConsole("First item in captions menu should be labelled 'Off'");
testExpected("item.textContent", "Off");
item = captionsEntries[1];
logConsole("Second item in captions menu should be labelled 'No label'");
testExpected("item.textContent", "No label");
endTest();
}
function start()
{
findMediaElement();
waitForEvent('canplaythrough', function () { startTrackMenuTest(testMenuHeaders); });
}
</script>
</head>
<body onload="start()">
<p>Test that captions and subtitles menu items are localized.</p>
<video width="500" height="300" controls>
<source src="content/test.mp4" type="video/mp4">
<source src="content/test.ogv" type="video/ogg">
<track kind="captions" src="track/captions-webvtt/captions-fast.vtt">
<track kind="subtitles" src="track/captions-webvtt/captions-fast.vtt">
</video>
</body>
</html>
......@@ -5,45 +5,16 @@
<script src="media-controls.js"></script>
<script src="media-file.js"></script>
<script src="video-test.js"></script>
<script src="trackmenu-test.js"></script>
<script>
var captionsButtonCoordinates;
if (window.testRunner)
testRunner.dumpAsText();
function clickCCButton()
{
eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordinates[1]);
eventSender.mouseDown();
eventSender.mouseUp();
}
function startTest()
{
if (window.eventSender) {
consoleWrite("<br>*** Set the user language preference.");
run("internals.setUserPreferredLanguages(['en'])");
try {
captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggle-closed-captions-button");
} catch (exception) {
failTest(exception.description);
return;
}
clickCCButton();
window.setTimeout(testSortedMenu, 100);
}
}
function testSortedMenu()
{
var trackListElement;
try {
trackListElement = mediaControlsElement(internals.shadowRoot(video).firstChild, "-webkit-media-controls-closed-captions-track-list");
} catch (exception) {
failTest(exception.description);
var trackListElement = getTrackListElement();
if (!trackListElement)
return;
}
// Track list should have two <ul> elements.
var trackListSections = trackListElement.querySelectorAll("ul");
if (!trackListSections || trackListSections.length != 2) {
......@@ -78,7 +49,7 @@
function start()
{
findMediaElement();
waitForEvent('canplaythrough', startTest);
waitForEvent('canplaythrough', function () { startTrackMenuTest(testSortedMenu); });
}
</script>
</head>
......
......@@ -3611,6 +3611,7 @@ webkit.org/b/94242 [ Android Debug ] media/track/track-cues-sorted-before-dispat
# Chromium still has the CC toggle button, not the menu of tracks.
webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ]
webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
webkit.org/b/101670 media/video-controls-captions-trackmenu-localized.html [ Skip ]
webkit.org/b/92835 [ Android Mac Win Debug ] svg/as-background-image/svg-as-background-5.html [ Pass Slow ]
......
......@@ -1642,6 +1642,7 @@ webkit.org/b/102493 fast/events/mouse-cursor.html [ Failure ]
# EFL still has the CC toggle button, not the menu of tracks.
webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ]
webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
webkit.org/b/101670 media/video-controls-captions-trackmenu-localized.html [ Skip ]
# Fails until we enable the Resource Timing API.
webkit.org/b/61138 http/tests/w3c/webperf/submission/resource-timing [ Skip ]
......
......@@ -720,6 +720,7 @@ Bug(GTK) fast/media/print-restores-previous-mediatype.html [ Timeout ]
# GTK still has the CC toggle button, not the menu of tracks.
webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ]
webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
webkit.org/b/101670 media/video-controls-captions-trackmenu-localized.html [ Skip ]
#////////////////////////////////////////////////////////////////////////////////////////
# End of Tests timing out
......
......@@ -2411,6 +2411,7 @@ webkit.org/b/100846 inspector-protocol/debugger-terminate-dedicated-worker-while
# QT still has the CC toggle button, not the menu of tracks.
webkit.org/b/101670 media/video-controls-captions-trackmenu.html [ Skip ]
webkit.org/b/101670 media/video-controls-captions-trackmenu-sorted.html [ Skip ]
webkit.org/b/101670 media/video-controls-captions-trackmenu-localized.html [ Skip ]
# New, but failing test
webkit.org/b/101035 fast/images/exif-orientation-image-document.html
......
2012-12-18 Dean Jackson <dino@apple.com>
Track menu needs localization
https://bugs.webkit.org/show_bug.cgi?id=105233
Reviewed by Eric Carlson.
Allow the UI strings in the closed captions menu to be localized, and
profile strings for the English locale.
Test: media/video-controls-captions-trackmenu-localized.html
* English.lproj/Localizable.strings: Adds the four new captions strings.
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu): Use localized getters.
* platform/LocalizedStrings.cpp:
(WebCore::textTrackClosedCaptionsText): New localized string getter.
(WebCore::textTrackSubtitlesText): Ditto.
(WebCore::textTrackOffText): Ditto.
(WebCore::textTrackNoLabelText): Ditto.
* platform/LocalizedStrings.h:
2012-12-18 Beth Dakin <bdakin@apple.com>
 
https://bugs.webkit.org/show_bug.cgi?id=102579
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -874,26 +874,26 @@ void MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu()
RefPtr<Element> captionsSection = doc->createElement(sectionTag, ASSERT_NO_EXCEPTION);
RefPtr<Element> captionsHeader = doc->createElement(h3Tag, ASSERT_NO_EXCEPTION);
captionsHeader->appendChild(doc->createTextNode("Closed Captions"));
captionsHeader->appendChild(doc->createTextNode(textTrackClosedCaptionsText()));
captionsSection->appendChild(captionsHeader);
RefPtr<Element> captionsMenuList = doc->createElement(ulTag, ASSERT_NO_EXCEPTION);
RefPtr<Element> subtitlesSection = doc->createElement(sectionTag, ASSERT_NO_EXCEPTION);
RefPtr<Element> subtitlesHeader = doc->createElement(h3Tag, ASSERT_NO_EXCEPTION);
subtitlesHeader->appendChild(doc->createTextNode("Subtitles"));
subtitlesHeader->appendChild(doc->createTextNode(textTrackSubtitlesText()));
subtitlesSection->appendChild(subtitlesHeader);
RefPtr<Element> subtitlesMenuList = doc->createElement(ulTag, ASSERT_NO_EXCEPTION);
RefPtr<Element> trackItem;
trackItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION);
trackItem->appendChild(doc->createTextNode("Off"));
trackItem->appendChild(doc->createTextNode(textTrackOffText()));
trackItem->setAttribute(trackIndexAttributeName(), textTracksOffAttrValue, ASSERT_NO_EXCEPTION);
captionsMenuList->appendChild(trackItem);
m_menuItems.append(trackItem);
trackItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION);
trackItem->appendChild(doc->createTextNode("Off"));
trackItem->appendChild(doc->createTextNode(textTrackOffText()));
trackItem->setAttribute(trackIndexAttributeName(), textTracksOffAttrValue, ASSERT_NO_EXCEPTION);
subtitlesMenuList->appendChild(trackItem);
m_menuItems.append(trackItem);
......@@ -915,7 +915,7 @@ void MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu()
if (labelText.isNull() || labelText.isEmpty())
labelText = displayNameForLanguageLocale(track->language());
if (labelText.isNull() || labelText.isEmpty())
labelText = "No Label";
labelText = textTrackNoLabelText();
trackItem->appendChild(doc->createTextNode(labelText));
if (track->kind() == track->captionsKeyword()) {
......
......@@ -1009,4 +1009,26 @@ String clickToExitFullScreenText()
return WEB_UI_STRING("Click to exit full screen mode", "Message to display in browser window when in webkit full screen mode.");
}
#if ENABLE(VIDEO_TRACK)
String textTrackClosedCaptionsText()
{
return WEB_UI_STRING("Closed Captions", "Menu section heading for closed captions");
}
String textTrackSubtitlesText()
{
return WEB_UI_STRING("Subtitles", "Menu section heading for subtitles");
}
String textTrackOffText()
{
return WEB_UI_STRING("Off", "Menu item label for the track that represents disabling closed captions");
}
String textTrackNoLabelText()
{
return WEB_UI_STRING("No label", "Menu item label for a closed captions track that has no other name");
}
#endif
} // namespace WebCore
......@@ -263,6 +263,13 @@ namespace WebCore {
String clickToExitFullScreenText();
#if ENABLE(VIDEO_TRACK)
String textTrackClosedCaptionsText();
String textTrackSubtitlesText();
String textTrackOffText();
String textTrackNoLabelText();
#endif
#if !PLATFORM(CHROMIUM)
#define WEB_UI_STRING(string, description) WebCore::localizedString(string)
#define WEB_UI_STRING_KEY(string, key, description) WebCore::localizedString(key)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment