1313@interface M3U8KitTests : XCTestCase
1414
1515@property (nonatomic ) StringExample *example;
16+ @property (nonatomic ) M3U8PlaylistModel *playList;
17+
18+ @property (nonatomic ) M3U8PlaylistModel *masterList;
1619
1720@end
1821
@@ -23,6 +26,22 @@ - (void)setUp {
2326 // Put setup code here. This method is called before the invocation of each test method in the class.
2427
2528 _example = [[StringExample alloc ] init ];
29+
30+ NSURL *baseURL = [NSURL URLWithString: @" https://example.m3u8kit/9764a7a5vodtransgzp1252524126/953e2ef85285890782612785655/drm/" ];
31+ NSError *error = nil ;
32+ _playList = [[M3U8PlaylistModel alloc ]
33+ initWithString: _example.m3u8Playlist
34+ baseURL: baseURL
35+ error: &error];
36+ XCTAssertNil (error);
37+
38+ baseURL = [NSURL URLWithString: @" https://hls.ted.com" ];
39+ NSError *error1 = nil ;
40+ _masterList = [[M3U8PlaylistModel alloc ]
41+ initWithString: _example.m3u8Master
42+ baseURL: baseURL
43+ error: &error1];
44+ XCTAssertNil (error1);
2645}
2746
2847- (void )tearDown {
@@ -43,27 +62,13 @@ - (void)testLoadURLAsynchronously {
4362}
4463
4564- (void )testMasterM3U {
46- NSURL *baseURL = [NSURL URLWithString: @" https://hls.ted.com" ];
47- NSError *error = nil ;
48- M3U8PlaylistModel *playList = [[M3U8PlaylistModel alloc ]
49- initWithString: _example.m3u8Master
50- baseURL: baseURL
51- error: &error];
52- NSLog (@" %@ " , playList);
53- NSArray *codecs = [playList.masterPlaylist.xStreamList xStreamInfAtIndex: 0 ].codecs ;
65+ NSArray *codecs = [_masterList.masterPlaylist.xStreamList xStreamInfAtIndex: 0 ].codecs ;
5466 XCTAssert ([codecs[0 ] isEqualToString: @" avc1.42c01e" ]);
5567 XCTAssert ([codecs[1 ] isEqualToString: @" mp4a.40.2" ]);
56- XCTAssertNil (error);
5768}
5869
5970- (void )testPlaylistM3U {
60- NSURL *baseURL = [NSURL URLWithString: @" https://example.m3u8kit/9764a7a5vodtransgzp1252524126/953e2ef85285890782612785655/drm/" ];
61- NSError *error = nil ;
62- M3U8PlaylistModel *playList = [[M3U8PlaylistModel alloc ]
63- initWithString: _example.m3u8Playlist
64- baseURL: baseURL
65- error: &error];
66- M3U8SegmentInfoList *segments = playList.mainMediaPl .segmentList ;
71+ M3U8SegmentInfoList *segments = _playList.mainMediaPl .segmentList ;
6772 XCTAssertEqual (segments.count , 23 );
6873
6974 M3U8SegmentInfo *segment0 = [segments segmentInfoAtIndex: 0 ];
@@ -73,8 +78,19 @@ - (void)testPlaylistM3U {
7378 M3U8SegmentInfo *segment1 = [segments segmentInfoAtIndex: 1 ];
7479 XCTAssertNil (segment1.additionalParameters );
7580 XCTAssertEqual (segment1.duration , 2.0 );
76-
77- XCTAssertNil (error);
81+ }
82+
83+ - (void )testParseXMap {
84+ M3U8ExtXMap *xMap = _playList.mainMediaPl .xMap ;
85+ XCTAssertEqualObjects (xMap.URI .absoluteString , @" https://example.m3u8kit/xMap/init.mp4" );
86+ XCTAssertEqual (xMap.byteRange .length , 7355608 );
87+ XCTAssertEqual (xMap.byteRange .offset , 666 );
88+ }
89+
90+ - (void )testParseFrameRate {
91+ M3U8MasterPlaylist *master = _masterList.masterPlaylist ;
92+ M3U8ExtXStreamInf *info = master.xStreamList .firstStreamInf ;
93+ XCTAssertEqual (info.frameRate , 7355608.0 );
7894}
7995
8096- (void )testPerformanceExample {
0 commit comments