/* * Verifies that a cue text start tag with an invalid name will be ignored. * From http://dev.w3.org/html5/webvtt/#webvtt-tag-state As given by the algorithm defined and any connecting parts. (11/27/2012) * Relevant cue text specification rules: * 1. Characters that come after the "<" and before a white space are considered to be apart of the tag name. * 2. Tag names that are not valid are ignored. * 3. Characters that come after the beginning "<" brace and after a white space character are considered to be apart of the annotation. * * In this example the parser reads "iare</i" inside of the beginning "<" and ending ">" as the tag name. */ TEST_F(PayloadTagFormat,DISABLED_StartTagNoEndBrace) { loadVtt( "payload/tag-format/start-tag-no-end-brace.vtt" ); const InternalNode *head = getHeadOfCue( 0 ); ASSERT_TRUE( head->childCount() == 2 ); ASSERT_EQ( Node::Text, head->child( 0 )->kind() ); ASSERT_EQ( Node::Text, head->child( 1 )->kind() ); }
TEST_F(PayloadLangTag, InternalWithinTag) { loadVtt( "payload/lang-tag/internal-within-lang.vtt" ); const Node head = getHeadOfCue( 0 ); EXPECT_EQ( 1, head[ 0 ][ 0 ].childCount() ); EXPECT_EQ( Node::Bold, head[ 0 ][ 0 ].kind() ); EXPECT_STREQ( "en", head[ 0 ][ 0 ].lang().utf8() ); }
TEST_F(PayloadLangTag, LangWithoutAnnotation) { loadVtt( "payload/lang-tag/lang-without-annotation.vtt" ); const Node head = getHeadOfCue( 0 ); EXPECT_EQ( 1, head[ 0 ].childCount() ); EXPECT_EQ( Node::Lang, head[ 0 ].kind() ); EXPECT_STREQ( "", head[ 0 ].lang().utf8() ); }
/* * Verifies that a voice cue text tag that does not have an end tag is parsed correctly. * From http://dev.w3.org/html5/webvtt/#webvtt-cue-voice-span (11/27/2012) * Voice tags consist of: * 1. A cue span start tag "v" that requires an annotation. * 2. Cue internal text representing the voice text. * 3. A cue span end tag that can be ommitted for brevity if the voice span is the only tag in this webvtt cue text sequence. */ TEST_F(PayloadVoiceTag,DISABLED_VoiceTag) { loadVtt( "payload/v-tag/v-tag.vtt" ); const InternalNode *head = getHeadOfCue( 0 ); ASSERT_TRUE( head->childCount() == 1 ); ASSERT_EQ( Node::Voice, head->child( 0 )->kind() ); }
TEST_F(PayloadLangTag, BasicLangTag) { loadVtt( "payload/lang-tag/basic-lang.vtt" ); const Node head = getHeadOfCue( 0 ); EXPECT_EQ( 1, head.childCount() ); EXPECT_EQ( Node::Lang, head[ 0 ].kind() ); EXPECT_STREQ( "en", head[ 0 ].lang().utf8() ); }
TEST_F(PayloadLangTag, TwoLangTags) { loadVtt( "payload/lang-tag/two-lang-tags.vtt" ); const Node head = getHeadOfCue( 0 ); EXPECT_EQ( 2, head.childCount() ); EXPECT_EQ( Node::Lang, head[ 0 ].kind() ); EXPECT_STREQ( "en", head[ 0 ].lang().utf8() ); EXPECT_EQ( Node::Lang, head[ 1 ].kind() ); EXPECT_STREQ( "fe", head[ 1 ].lang().utf8() ); }
/* * Verifies that a voice cue text tag that has an annotation is parsed correctly and contains the annotation. * From http://dev.w3.org/html5/webvtt/#webvtt-cue-voice-span (11/27/2012) * Voice tags consist of: * 1. A cue span start tag "v" that requires an annotation. * 2. Cue internal text representing the voice text. * 3. A cue span end tag that can be ommitted for brevity if the voice span is the only tag in this webvtt cue text sequence. */ TEST_F(PayloadVoiceTag,DISABLED_VoiceTagAnnotation) { loadVtt( "payload/v-tag/v-tag-annotation.vtt" ); const InternalNode *head = getHeadOfCue( 0 ); ASSERT_TRUE( head->childCount() == 3 ); ASSERT_EQ( Node::Voice, head->child( 1 )->kind() ); String expectedString = String( (const byte *)"Annotation", 10 ); ASSERT_EQ( expectedString.text(), head->child( 1 )->toInternalNode()->annotation().text() ); }
/* * Verifies that cue text end tags that are malformed will be ignored. * From http://dev.w3.org/html5/webvtt/#webvtt-cue-text-parsing-rules step "If token is an end tag" (11/27/2012) * Relevant cue text specification rule(s): * 1. End tags that do not close the current open tag are ignored. * 2. End tags that are not formatted properly will be ignored. * Implications: * 1. Tags that are not closed properly are valid until the end of the current cue text. */ TEST_F(PayloadTagFormat,DISABLED_EndTagNoEndBrace) { loadVtt( "payload/tag-format/end-tag-no-end-brace.vtt.vtt" ); const InternalNode *head = getHeadOfCue( 0 ); ASSERT_TRUE( head->childCount() == 2 ); const InternalNode *italicNode = head->child( 1 )->toInternalNode(); ASSERT_EQ( Node::Italic, italicNode->kind() ); ASSERT_TRUE( italicNode->childCount() == 1 ); ASSERT_EQ( Node::Text, italicNode->child( 0 )->kind() ); }
/* * Verifies that cue text end tags that are out of order will be ignored. * From http://dev.w3.org/html5/webvtt/#webvtt-cue-text-parsing-rules step "If token is an end tag" (11/27/2012) * Relevant cue text specification rule(s): * 1. End tags that do not close the current open tag are ignored. * 2. End tags that are not formatted properly will be ignored. * Implications: * 1. Tags that are not closed properly are valid until the end of the current cue text. */ TEST_F(PayloadTagFormat,DISABLED_BadTagNesting) { loadVtt( "payload/tag-format/bad-tag-nesting.vtt" ); const InternalNode *head = getHeadOfCue( 0 ); ASSERT_TRUE( head->childCount() == 2 ); const InternalNode *italicNode = head->child( 1 )->toInternalNode(); ASSERT_EQ( Node::Italic, italicNode->kind() ); ASSERT_EQ( Node::Bold, italicNode->kind() ); ASSERT_EQ( Node::Text, italicNode->child( 0 )->kind() ); }
/* * Verifies that a single subclass can be attached to a cue text voice start tag. * From http://dev.w3.org/html5/webvtt/#webvtt-cue-span-start-tag (11/27/2012) * Cue span start tags consist of the following: * 1. A "<" character representing the beginning of the start tag. * 2. The tag name. * 3. Zero or more the following sequence representing a subclasses of the start tag * 3.1. A full stop "." character. * 3.2. A sequence of non-whitespace characters. * 4. If the start tag requires an annotation then a space or tab character followed by a sequence of * non-whitespace characters representing the annotation. * 5. A ">" character repsenting the end of the start tag. */ TEST_F(PayloadVoiceTag,DISABLED_VoiceTagSingleSubclass) { loadVtt( "payload/v-tag/v-tag-single-subclass.vtt" ); const InternalNode *head = getHeadOfCue( 0 ); ASSERT_TRUE( head->childCount() == 3 ); ASSERT_EQ( Node::Voice, head->child( 1 )->kind() ); StringList cssClasses = head->child( 1 )->toInternalNode()->cssClasses(); String expectedString = String( (const byte *)"class", 5 ); ASSERT_TRUE( cssClasses.length() == 1 ); ASSERT_EQ( expectedString.text(), cssClasses.stringAtIndex( 0 ).text() ); }
/* * Verifies that cue text end tags that are malformed will be ignored. * From http://dev.w3.org/html5/webvtt/#webvtt-cue-text-parsing-rules step "If token is an end tag" (11/27/2012) * Relevant cue text specification rule(s): * 1. End tags that do not close the current open tag are ignored. * 2. End tags that are not formatted properly will be ignored. * Implications: * 1. Tags that are not closed properly are valid until the end of the current cue text. */ TEST_F(PayloadTagFormat,DISABLED_MultiTagNoEndTag) { loadVtt( "payload/tag-format/multi-tag-no-end-tag.vtt" ); const InternalNode *head = getHeadOfCue( 0 ); ASSERT_TRUE( head->childCount() == 2 ); ASSERT_EQ( Node::Text, head->child( 0 )->kind() ); const InternalNode *italicNode0 = head->child( 1 )->toInternalNode(); ASSERT_TRUE( italicNode0->childCount() == 2 ); ASSERT_EQ( Node::Italic, italicNode0->kind() ); ASSERT_EQ( Node::Text, italicNode0->child( 0 )->kind() ); const InternalNode *italicNode1 = italicNode0->child( 1 )->toInternalNode(); ASSERT_EQ( Node::Italic, italicNode1->kind() ); ASSERT_EQ( Node::Text, italicNode1->child( 0 )->kind() ); }
/** * Verifies that multiple cue component are parsed correctly. * * From http://dev.w3.org/html5/webvtt/#webvtt-cue-text (11/27/2012) * Cue text text consists of one or more cue text components optionally * separated by a single line terminator which can be: * 1. CR (U+000D) * 2. LF (U+000A) * 3. CRLF pair */ TEST_F(PayloadFormat, MultilineMultipleCueTextTag) { loadVtt( "payload/format/multiline-multiple-cue-text-tag.vtt", 1 ); const Node head = getHeadOfCue( 0 ); ASSERT_LE( 1, head.childCount() ); const Node underlineTag = head[0]; EXPECT_EQ( Node::Underline, underlineTag.kind() ); ASSERT_LE( 2, underlineTag.childCount() ); EXPECT_EQ( Node::Text, underlineTag[0].kind() ); const Node italicTag = underlineTag[1]; EXPECT_EQ( Node::Italic, italicTag.kind() ); ASSERT_LE( 2, italicTag.childCount() ); EXPECT_EQ( Node::Text, italicTag[0].kind() ); const Node boldTag = italicTag[1]; EXPECT_EQ( Node::Bold, boldTag.kind() ); }
/* * Verifies that a cue text span with no tags will parse correctly. * From http://dev.w3.org/html5/webvtt/#webvtt-cue-text-span (11/27/2012) */ TEST_F(PayloadFormat, BasicCueText) { loadVtt( "payload/format/basic-cue-text.vtt", 1 ); ASSERT_EQ( Node::Text, getHeadOfCue( 0 )[ 0 ].kind() ); }
/* * Verifies that multiple cue components can be put in one line, one after * the other. * http://dev.w3.org/html5/webvtt/#webvtt-cue-components */ TEST_F(PayloadFormat, MultipleCueTextTagTogether) { loadVtt( "payload/format/multiple-cue-tag-together.vtt", 1 ); ASSERT_EQ( 4, getHeadOfCue( 0 ).childCount() ); }
/* Verifies that cue text with a malformed line terminator is still parsed correctly. * From http://dev.w3.org/html5/webvtt/#webvtt-parser-algorithm (12/02/2012) * The WebVTT parser algorithm is as follows: * [...] 50. Bad cue: Discard cue. */ TEST_F(PayloadFormat, MultilineBasicCueTextExtraLine) { loadVtt( "payload/format/multiline-extra-line-terminator.vtt", 1); ASSERT_EQ( Node::Text, getHeadOfCue( 0 )[ 0 ].kind() ); }
/* * Verifies that cue text separated by a CRLF line terminator is parsed correctly. * From http://dev.w3.org/html5/webvtt/#webvtt-cue-text (12/02/2012) * Cue text consists of one or more cue text components optionally separated by a single line terminator which can be: * 1. CR (U+000D) * 2. LF (U+000A) * 3. CRLF pair */ TEST_F(PayloadFormat, MultilineBasicCueTextCRLF) { loadVtt( "payload/format/multiline-basic-cue-text-crlf.vtt", 1 ); ASSERT_EQ( Node::Text, getHeadOfCue( 0 )[ 0 ].kind() ); }
/* * Verifies that cue text with single CRLF pair characters will be parsed. * From http://dev.w3.org/html5/webvtt/#webvtt-cue-text (11/27/2012) * Cue text text consists of one or more cue text components optionally separated by a single line terminator which can be: * 1. CR (U+000D) * 2. LF (U+000A) * 3. CRLF pair */ TEST_F(PayloadFormat, MultilineCueTextCRLF) { loadVtt( "payload/format/multiline-cue-text-crlf.vtt", 1 ); ASSERT_EQ( 5, getHeadOfCue( 0 ).childCount() ); }
/* Verifies that an incorrect class name cannot be used as a cue component. * From http://dev.w3.org/html5/webvtt/#webvtt-cue-text-parsing-rules step "If token is an end tag" (11/27/2012) * Relevant cue text specification rule(s): * 1. End tags that do not close the current open tag are ignored. * 2. End tags that are not formatted properly will be ignored. * 3. Tags that do not have a valid tag name are ignored. * Implications: * 1. Tags that are not closed properly are valid until the end of the current cue text. */ TEST_F(PayloadTagFormat,DISABLED_BadTagName) { loadVtt( "payload/tag-format/incorrect-tag-name.vtt" ); ASSERT_TRUE( getHeadOfCue( 0 )->childCount() == 3 ); }
/* * Verifies that a file with payload text containing a line feed in between the text * will finish the parsing attempt gracefully. * From http://dev.w3.org/html5/webvtt/#parsing (12/10/2012): * * ... * 50. Bad cue: Discard cue. * 51. Bad cue loop: If position is past the end of input, then jump to the step labeled end. */ TEST_F(PayloadFormat, MultilineCueTextExtraNewline) { loadVtt( "payload/format/multiline-cue-text-extra-newline.vtt", 1 ); ASSERT_EQ( 2, getHeadOfCue( 0 ).childCount() ); }
/* * This test is to verify that multiple cue text tags can be nested within eachother. * Based on the WebVTT cue components specification as of October 3, 2012. * http://dev.w3.org/html5/webvtt/#webvtt-cue-components */ TEST_F(PayloadTagFormat,DISABLED_MultipleCueTextTag) { loadVtt( "payload/tag-format/multiple-cue-text-tag.vtt" ); ASSERT_EQ( Node::Italic, getHeadOfCue( 0 )->child( 0 )->kind() ); ASSERT_EQ( Node::Bold, getHeadOfCue( 0 )->child( 0 )->toInternalNode()->child( 0 )->kind() ); }