Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
75a7385b
authored
Oct 01, 2018
by
Arnold Szabo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
#4306 - extends test case with line and position anchor verifications
parent
fc5eb12e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
1 deletions
library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java
library/core/src/test/assets/subrip/typical_with_tags
library/core/src/test/java/com/google/android/exoplayer2/text/subrip/SubripDecoderTest.java
library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java
View file @
75a7385b
...
@@ -176,7 +176,7 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
...
@@ -176,7 +176,7 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
// Extract tags
// Extract tags
int
replacedCharacters
=
0
;
int
replacedCharacters
=
0
;
StringBuilder
processedLine
=
new
StringBuilder
(
trimmedLine
);
StringBuilder
processedLine
=
new
StringBuilder
(
trimmedLine
);
Matcher
matcher
=
SUBRIP_TAG_PATTERN
.
matcher
(
process
edLine
);
Matcher
matcher
=
SUBRIP_TAG_PATTERN
.
matcher
(
trimm
edLine
);
while
(
matcher
.
find
())
{
while
(
matcher
.
find
())
{
String
tag
=
matcher
.
group
();
String
tag
=
matcher
.
group
();
...
...
library/core/src/test/assets/subrip/typical_with_tags
View file @
75a7385b
...
@@ -18,3 +18,39 @@ This { \an2} is the fourth subtitle.
...
@@ -18,3 +18,39 @@ This { \an2} is the fourth subtitle.
5
5
00:00:013,567 --> 00:00:14,901
00:00:013,567 --> 00:00:14,901
This {\an2} is the fifth subtitle with multiple {\xyz} valid {\qwe} tags.
This {\an2} is the fifth subtitle with multiple {\xyz} valid {\qwe} tags.
6
00:00:015,567 --> 00:00:15,901
This {\an1} is a lines.
7
00:00:016,567 --> 00:00:16,901
This {\an2} is a line.
8
00:00:017,567 --> 00:00:17,901
This {\an3} is a line.
9
00:00:018,567 --> 00:00:18,901
This {\an4} is a line.
10
00:00:019,567 --> 00:00:19,901
This {\an5} is a line.
11
00:00:020,567 --> 00:00:20,901
This {\an6} is a line.
12
00:00:021,567 --> 00:00:22,901
This {\an7} is a line.
13
00:00:023,567 --> 00:00:23,901
This {\an8} is a line.
14
00:00:024,567 --> 00:00:24,901
This {\an9} is a line.
\ No newline at end of file
library/core/src/test/java/com/google/android/exoplayer2/text/subrip/SubripDecoderTest.java
View file @
75a7385b
...
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2.text.subrip;
...
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2.text.subrip;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
com.google.android.exoplayer2.testutil.TestUtil
;
import
com.google.android.exoplayer2.testutil.TestUtil
;
import
com.google.android.exoplayer2.text.Cue
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -174,6 +176,71 @@ public final class SubripDecoderTest {
...
@@ -174,6 +176,71 @@ public final class SubripDecoderTest {
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
8
)).
get
(
0
).
text
.
toString
())
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
8
)).
get
(
0
).
text
.
toString
())
.
isEqualTo
(
"This is the fifth subtitle with multiple valid tags."
);
.
isEqualTo
(
"This is the fifth subtitle with multiple valid tags."
);
// Verify positions
// {/an1}
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
10
)).
get
(
0
).
positionAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_START
);
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
10
)).
get
(
0
).
lineAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_END
);
// {/an2}
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
12
)).
get
(
0
).
positionAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_MIDDLE
);
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
12
)).
get
(
0
).
lineAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_END
);
// {/an3}
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
14
)).
get
(
0
).
positionAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_END
);
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
14
)).
get
(
0
).
lineAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_END
);
// {/an4}
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
16
)).
get
(
0
).
positionAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_START
);
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
16
)).
get
(
0
).
lineAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_MIDDLE
);
// {/an5}
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
18
)).
get
(
0
).
positionAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_MIDDLE
);
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
18
)).
get
(
0
).
lineAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_MIDDLE
);
// {/an6}
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
20
)).
get
(
0
).
positionAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_END
);
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
20
)).
get
(
0
).
lineAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_MIDDLE
);
// {/an7}
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
22
)).
get
(
0
).
positionAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_START
);
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
22
)).
get
(
0
).
lineAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_START
);
// {/an8}
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
24
)).
get
(
0
).
positionAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_MIDDLE
);
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
24
)).
get
(
0
).
lineAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_START
);
// {/an9}
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
26
)).
get
(
0
).
positionAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_END
);
assertThat
(
subtitle
.
getCues
(
subtitle
.
getEventTime
(
26
)).
get
(
0
).
lineAnchor
)
.
isEqualTo
(
Cue
.
ANCHOR_TYPE_START
);
}
}
private
static
void
assertTypicalCue1
(
SubripSubtitle
subtitle
,
int
eventIndex
)
{
private
static
void
assertTypicalCue1
(
SubripSubtitle
subtitle
,
int
eventIndex
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment