OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 EXPECT_EQ(video_track.language(), ""); | 1394 EXPECT_EQ(video_track.language(), ""); |
1395 | 1395 |
1396 const MediaTrack& audio_track = *(media_tracks_->tracks()[1]); | 1396 const MediaTrack& audio_track = *(media_tracks_->tracks()[1]); |
1397 EXPECT_EQ(audio_track.type(), MediaTrack::Audio); | 1397 EXPECT_EQ(audio_track.type(), MediaTrack::Audio); |
1398 EXPECT_EQ(audio_track.bytestream_track_id(), 2); | 1398 EXPECT_EQ(audio_track.bytestream_track_id(), 2); |
1399 EXPECT_EQ(audio_track.kind(), "main"); | 1399 EXPECT_EQ(audio_track.kind(), "main"); |
1400 EXPECT_EQ(audio_track.label(), ""); | 1400 EXPECT_EQ(audio_track.label(), ""); |
1401 EXPECT_EQ(audio_track.language(), ""); | 1401 EXPECT_EQ(audio_track.language(), ""); |
1402 } | 1402 } |
1403 | 1403 |
| 1404 // UTCDateToTime_* tests here assume FFmpegDemuxer's ExtractTimelineOffset |
| 1405 // helper uses base::Time::FromUTCString() for conversion. |
| 1406 TEST_F(FFmpegDemuxerTest, UTCDateToTime_Valid) { |
| 1407 base::Time result; |
| 1408 EXPECT_TRUE( |
| 1409 base::Time::FromUTCString("2012-11-10T12:34:56.987654Z", &result)); |
| 1410 |
| 1411 base::Time::Exploded exploded; |
| 1412 result.UTCExplode(&exploded); |
| 1413 EXPECT_TRUE(exploded.HasValidValues()); |
| 1414 EXPECT_EQ(2012, exploded.year); |
| 1415 EXPECT_EQ(11, exploded.month); |
| 1416 EXPECT_EQ(6, exploded.day_of_week); |
| 1417 EXPECT_EQ(10, exploded.day_of_month); |
| 1418 EXPECT_EQ(12, exploded.hour); |
| 1419 EXPECT_EQ(34, exploded.minute); |
| 1420 EXPECT_EQ(56, exploded.second); |
| 1421 EXPECT_EQ(987, exploded.millisecond); |
| 1422 |
| 1423 // base::Time exploding operations round fractional milliseconds down, so |
| 1424 // verify fractional milliseconds using a base::TimeDelta. |
| 1425 base::Time without_fractional_ms; |
| 1426 EXPECT_TRUE(base::Time::FromUTCExploded(exploded, &without_fractional_ms)); |
| 1427 base::TimeDelta delta = result - without_fractional_ms; |
| 1428 EXPECT_EQ(654, delta.InMicroseconds()); |
| 1429 } |
| 1430 |
| 1431 TEST_F(FFmpegDemuxerTest, UTCDateToTime_Invalid) { |
| 1432 const char* invalid_date_strings[] = { |
| 1433 "", |
| 1434 "12:34:56", |
| 1435 "-- ::", |
| 1436 "2012-11- 12:34:56", |
| 1437 "2012--10 12:34:56", |
| 1438 "-11-10 12:34:56", |
| 1439 "2012-11 12:34:56", |
| 1440 "ABCD-11-10 12:34:56", |
| 1441 "2012-EF-10 12:34:56", |
| 1442 "2012-11-GH 12:34:56", |
| 1443 "2012-11-1012:34:56", |
| 1444 }; |
| 1445 |
| 1446 for (size_t i = 0; i < arraysize(invalid_date_strings); ++i) { |
| 1447 const char* date_string = invalid_date_strings[i]; |
| 1448 base::Time result; |
| 1449 EXPECT_FALSE(base::Time::FromUTCString(date_string, &result)) |
| 1450 << "date_string '" << date_string << "'"; |
| 1451 } |
| 1452 } |
| 1453 |
1404 } // namespace media | 1454 } // namespace media |
OLD | NEW |