diff options
Diffstat (limited to 'tests/tests/media/src/android/media/cts/MediaRecorderTest.java')
-rw-r--r-- | tests/tests/media/src/android/media/cts/MediaRecorderTest.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java index 6313621765b..ca89e1b2812 100644 --- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java +++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java @@ -507,6 +507,12 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase2<MediaStu // Make sure the tolerance is very small - due to rounding errors?. Log.v(TAG, "location: " + location); + // Trim the trailing slash, if any. + int lastIndex = location.lastIndexOf('/'); + if (lastIndex != -1) { + location = location.substring(0, lastIndex); + } + // Get the position of the -/+ sign in location String, which indicates // the beginning of the longtitude. int index = location.lastIndexOf('-'); @@ -515,12 +521,8 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase2<MediaStu } assertTrue("+ or - is not found", index != -1); assertTrue("+ or - is only found at the beginning", index != 0); - float latitude = Float.parseFloat(location.substring(0, index - 1)); - int lastIndex = location.lastIndexOf('/', index); - if (lastIndex == -1) { - lastIndex = location.length(); - } - float longitude = Float.parseFloat(location.substring(index, lastIndex - 1)); + float latitude = Float.parseFloat(location.substring(0, index)); + float longitude = Float.parseFloat(location.substring(index)); assertTrue("Incorrect latitude: " + latitude, Math.abs(latitude - LATITUDE) <= TOLERANCE); assertTrue("Incorrect longitude: " + longitude, Math.abs(longitude - LONGITUDE) <= TOLERANCE); retriever.release(); |