Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "chore: update dependencies (#38)" #39

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ on:
jobs:
tests:
name: Test the SDK with a Demo App
runs-on: macos-15
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run tests
run: "./scripts/run-tests.sh"
run: "./run-tests.sh"

11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,12 @@ DerivedData
# Carthage/Checkouts

Carthage/Build
**/Pods
**/Podfile.lock

# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Note: if you ignore the Pods directory, make sure to uncomment
# `pod install` in .travis.yml
#
# Pods/
161 changes: 161 additions & 0 deletions Example/DemoAppTests/MuxImaListener_Test.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
//
// MUXSDKImaListenerTests.m
// MUXSDKImaListenerTests
//
// Created by Dylan Jhaveri on 09/11/2019.
// Copyright (c) 2019 Dylan Jhaveri. All rights reserved.
//

// https://github.com/Specta/Specta

#import <MuxStatsGoogleIMAPlugin/MuxImaListener.h>
#import <AVKit/AVKit.h>

@interface MuxMockAVPlayerViewController : AVPlayerViewController
@end

@implementation MuxMockAVPlayerViewController
- (id)init {
if (self = [super init]) {
self.player = [[AVPlayer alloc] init];
}
return self;
}
@end

@interface MuxMockImaAdEvent : IMAAdEvent {
enum IMAAdEventType type;
}
@property (nonatomic) enum IMAAdEventType type;
@property(nonatomic, copy, nullable) NSDictionary<NSString *, id> *adData;
@end

@implementation MuxMockImaAdEvent

@synthesize type;
@synthesize adData;

- (id)initWithType:(NSInteger)_type {
type = _type;
return self;
}

- (id)initWithType:(NSInteger)_type andAdData:(NSDictionary*)_adData {
type = _type;
adData = _adData;
return self;
}
@end

SpecBegin(InitialSpecs)

describe(@"MuxImaListener", ^{
__block MUXSDKPlayerBinding *playerBinding = nil;
beforeEach(^{
NSString *name = @"Test Player Name";
MUXSDKCustomerPlayerData *playerData = [[MUXSDKCustomerPlayerData alloc] initWithPropertyKey:@"YOUR_ENVIRONMENT_KEY"];
MUXSDKCustomerVideoData *videoData = [MUXSDKCustomerVideoData new];
videoData.videoTitle = @"Big Buck Bunny";
videoData.videoId = @"bigbuckbunny";
videoData.videoSeries = @"animation";
MuxMockAVPlayerViewController *avPlayerController = [[MuxMockAVPlayerViewController alloc] init];
MUXSDKCustomerData *customerData = [[MUXSDKCustomerData alloc] initWithCustomerPlayerData:playerData
videoData:videoData
viewData:nil];
playerBinding = [MUXSDKStats monitorAVPlayerViewController:avPlayerController
withPlayerName:name
customerData:customerData];
});

describe(@"initWithPlayerBinding", ^{
it(@"should initialize an object", ^{
MuxImaListener *imaListener = [[MuxImaListener alloc] initWithPlayerBinding:playerBinding];
expect(imaListener).toNot.beNil();
});
});

describe(@"initWithPlayerBindingWithOptions", ^{
it(@"should initialize an object", ^{
MuxImaListenerOptions options = MuxImaListenerOptionsPictureInPicture;
MuxImaListener *imaListener = [[MuxImaListener alloc] initWithPlayerBinding:playerBinding options:options];
expect(imaListener).toNot.beNil();
});
});

describe(@"dispatchEvent", ^{
__block MuxImaListener *imaListener = nil;
beforeEach(^{
imaListener = [[MuxImaListener alloc] initWithPlayerBinding:playerBinding];
});

it(@"should dispatch the correct event for kIMAAdEvent_STARTED", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_STARTED];
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beKindOf([MUXSDKAdPlayingEvent class]);
});

it(@"should dispatch the correct event for kIMAAdEvent_FIRST_QUARTILE", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_FIRST_QUARTILE];
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beKindOf([MUXSDKAdFirstQuartileEvent class]);
});

it(@"should dispatch the correct event for kIMAAdEvent_MIDPOINT", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_MIDPOINT];
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beKindOf([MUXSDKAdMidpointEvent class]);
});

it(@"should dispatch the correct event for kIMAAdEvent_THIRD_QUARTILE", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_THIRD_QUARTILE];
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beKindOf([MUXSDKAdThirdQuartileEvent class]);
});

it(@"should dispatch the correct event for kIMAAdEvent_SKIPPED", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_SKIPPED];
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beKindOf([MUXSDKAdEndedEvent class]);
});

it(@"should dispatch the correct event for kIMAAdEvent_COMPLETE", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_COMPLETE];
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beKindOf([MUXSDKAdEndedEvent class]);
});

it(@"should dispatch the correct event for kIMAAdEvent_PAUSE", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_PAUSE];
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beKindOf([MUXSDKAdPauseEvent class]);
});

it(@"should not dispatch aderror for LOG event *without* error info", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_LOG];
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beNil();
});

it(@"should dispatch aderror for LOG event with error info", ^{
NSMutableDictionary *mockErrorData = [[NSMutableDictionary alloc] init];
[mockErrorData setObject:[NSNumber numberWithInt:110] forKey:@"errorCode"];
[mockErrorData setObject:@"mock message" forKey:@"errorMessage"];
[mockErrorData setObject:@"adPlayError" forKey:@"type"];
NSMutableDictionary *mockLogData = [[NSMutableDictionary alloc] init];
[mockLogData setObject:mockErrorData forKey:@"logData"];

MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_LOG andAdData:mockLogData];

MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beKindOf([MUXSDKAdErrorEvent class]);
});

it(@"should not dispatch an event for kIMAAdEvent_TAPPED", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_TAPPED];
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beNil();
});
});
});

SpecEnd
Loading
Loading