Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
9f02730
get libraries to generate
bparrishMines Apr 26, 2024
5f767fb
add a bunch of classes
bparrishMines Apr 26, 2024
b3317a0
some more videview stuff
bparrishMines Apr 26, 2024
631c1e0
some display implementation for android
bparrishMines Apr 27, 2024
35a4445
add the minimum required wrappings
bparrishMines Apr 29, 2024
8ac0311
fix build error
bparrishMines Apr 29, 2024
bc4d770
implement other platform classes
bparrishMines Apr 30, 2024
1f74ead
start creating an implementation
bparrishMines Apr 30, 2024
4320f50
move interfaces to bottom and format
bparrishMines Apr 30, 2024
e85027d
fix callback events
bparrishMines May 6, 2024
6739d7f
remove prints
bparrishMines May 7, 2024
e803962
fix removeStrongReference error
bparrishMines May 7, 2024
0d59a8e
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 9, 2024
6b22ebc
also send time updates
bparrishMines May 9, 2024
957e2ba
combine implementation files
bparrishMines May 9, 2024
d0be873
fix lint warnings
bparrishMines May 9, 2024
875d6be
fix Android dartPluginClass
bparrishMines May 9, 2024
0122f6c
fix missing params call
bparrishMines May 9, 2024
d0971db
make tracking ad progress in ad display container
bparrishMines May 10, 2024
6b8ee3a
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 14, 2024
b1ace40
add missing error codes
bparrishMines May 14, 2024
cc728d2
discard ad break
bparrishMines May 14, 2024
f345071
licenses
bparrishMines May 14, 2024
90965aa
copyright header
bparrishMines May 14, 2024
93c239b
first test file
bparrishMines May 14, 2024
c1b00f1
working tests
bparrishMines May 14, 2024
dce1723
more working tests
bparrishMines May 14, 2024
76af339
more tests
bparrishMines May 14, 2024
c2d6f67
media player test
bparrishMines May 14, 2024
9dde9d6
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 14, 2024
15aa049
some more tests
bparrishMines May 14, 2024
7c3dc18
finish platform unit tests
bparrishMines May 14, 2024
48c7a42
switch tests to use TestProxyApiRegistrar
bparrishMines May 14, 2024
c5842ad
fix ad size
bparrishMines May 14, 2024
8157448
version bump
bparrishMines May 15, 2024
37fce6f
fix name
bparrishMines May 15, 2024
f00caf2
remove pigeon bro
bparrishMines May 15, 2024
979ad8c
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 15, 2024
bdac900
start proxy
bparrishMines May 15, 2024
9250e8d
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 16, 2024
1dc6a07
change calls to proxy
bparrishMines May 16, 2024
713bdbd
remove pigeon
bparrishMines May 16, 2024
828ea3a
documentation
bparrishMines May 16, 2024
b4e8cda
fix key and some cleanup
bparrishMines May 16, 2024
c25d360
working addisplaycontainer test
bparrishMines May 16, 2024
849ca63
erge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 17, 2024
b182af5
onerror and oncompletion test
bparrishMines May 19, 2024
e2fb27e
on prepared test
bparrishMines May 19, 2024
48fb4de
pause ad and play ad tests
bparrishMines May 19, 2024
0bbba9a
assert and tests
bparrishMines May 20, 2024
1ce77c1
request ads and onAdsLoaded test
bparrishMines May 20, 2024
c7a320e
finish tests
bparrishMines May 20, 2024
a558a54
finish basic tests
bparrishMines May 20, 2024
1c3a2c2
finish all tests
bparrishMines May 20, 2024
428ecec
formatting
bparrishMines May 20, 2024
e8d822c
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 20, 2024
5311d85
version bump and license
bparrishMines May 20, 2024
ba23b1d
lower kotlin version
bparrishMines May 20, 2024
52a2c49
try fix lint
bparrishMines May 20, 2024
f32e74f
update generated kotlin
bparrishMines May 20, 2024
75957f2
override pigeonRegistrar type
bparrishMines May 20, 2024
6743d69
make platform classes base to be mockable
bparrishMines May 20, 2024
3edc221
separate some logic
bparrishMines May 20, 2024
3893efe
separate class implementations
bparrishMines May 20, 2024
1c5fac7
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 20, 2024
a30c9fc
doc improvements
bparrishMines May 20, 2024
8fa430b
lower meta version to 1.12.0
bparrishMines May 20, 2024
220e2f0
move meta to 1.10.0
bparrishMines May 20, 2024
f55805f
only null ad duration on stop and error
bparrishMines May 21, 2024
284098a
stop any ad tracking before starting a new one
bparrishMines May 21, 2024
69e088c
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 21, 2024
48828e3
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 22, 2024
891f4d4
stop ad progress tracking on video completion
bparrishMines May 22, 2024
9ada3ef
change generated kotlin library name
bparrishMines May 30, 2024
84d1ff5
docs for kotlin classes
bparrishMines May 30, 2024
1abcabc
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 30, 2024
b4b2152
variable docs
bparrishMines May 31, 2024
519c68e
beef up docs and some formatting
bparrishMines May 31, 2024
f7d25c6
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines May 31, 2024
8923d5f
uncomment pigeon file
bparrishMines Jun 1, 2024
9145273
an
bparrishMines Jun 2, 2024
c3ce374
add an unknown value for enum
bparrishMines Jun 3, 2024
5e11462
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines Jun 3, 2024
24f0baa
Merge branch 'main' of github.com:flutter/packages into ima_android
bparrishMines Jun 25, 2024
dc6f38a
comment pigeon
bparrishMines Jun 25, 2024
819441a
add flutter request agent
bparrishMines Jun 25, 2024
eda9cac
request agent test
bparrishMines Jun 25, 2024
6a18fac
formatting and lint
bparrishMines Jun 25, 2024
4829c85
only run example on Android
bparrishMines Jun 25, 2024
463bfe4
small nits
bparrishMines Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
on prepared test
  • Loading branch information
bparrishMines committed May 19, 2024
commit e2fb27e547d7708a9824bf0dca9e78509957dc30
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ final class AndroidAdDisplayContainer extends PlatformAdDisplayContainer {
removeCallback: (_, ima.VideoAdPlayerCallback callback) {
weakThis.target?._videoAdPlayerCallbacks.remove(callback);
},
loadAd: (_, ima.AdMediaInfo adMediaInfo, ima.AdPodInfo adPodInfo) {
loadAd: (_, ima.AdMediaInfo adMediaInfo, __) {
weakThis.target?._loadedAdMediaInfo = adMediaInfo;
},
pauseAd: (_, ima.AdMediaInfo adMediaInfo) async {
pauseAd: (_, __) async {
final AndroidAdDisplayContainer? container = weakThis.target;
if (container != null) {
await container._mediaPlayer!.pause();
Expand All @@ -219,7 +219,7 @@ final class AndroidAdDisplayContainer extends PlatformAdDisplayContainer {
weakThis.target?._videoView.setVideoUri(adMediaInfo.url);
},
release: (_) {},
stopAd: (_, ima.AdMediaInfo adMediaInfo) {
stopAd: (_, __) {
final AndroidAdDisplayContainer? container = weakThis.target;
if (container != null) {
container._stopAdTracking();
Expand All @@ -239,7 +239,7 @@ final class AndroidAdsLoaderCreationParams
required super.container,
required super.onAdsLoaded,
required super.onAdsLoadError,
InteractiveMediaAdsProxy? proxy,
@visibleForTesting InteractiveMediaAdsProxy? proxy,
}) : _proxy = proxy ?? const InteractiveMediaAdsProxy(),
super();

Expand Down Expand Up @@ -349,9 +349,10 @@ final class AndroidAdsLoader extends PlatformAdsLoader {
/// Android implementation of [PlatformAdsManager].
class AndroidAdsManager extends PlatformAdsManager {
/// Constructs an [AndroidAdsManager].
@visibleForTesting
AndroidAdsManager(
ima.AdsManager manager, {
InteractiveMediaAdsProxy? proxy,
@visibleForTesting InteractiveMediaAdsProxy? proxy,
}) : _manager = manager,
_proxy = proxy ?? const InteractiveMediaAdsProxy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'ad_display_container_test.mocks.dart';
MockSpec<ima.MediaPlayer>(),
MockSpec<ima.VideoAdPlayer>(),
MockSpec<ima.VideoAdPlayerCallback>(),
MockSpec<ima.VideoProgressUpdate>(),
MockSpec<ima.VideoView>(),
MockSpec<SurfaceAndroidViewController>(),
MockSpec<PlatformViewsServiceProxy>(),
Expand Down Expand Up @@ -106,10 +107,12 @@ void main() {
builder: (BuildContext context) => container.build(context),
));

(verify(mockAndroidViewController
final void Function(int) onPlatformCreatedCallback = verify(
mockAndroidViewController
.addOnPlatformViewCreatedListener(captureAny))
.captured[0] as void Function(int))
.call(platformViewId);
.captured[0] as void Function(int);

onPlatformCreatedCallback(platformViewId);

await tester.pumpAndSettle();
});
Expand Down Expand Up @@ -180,7 +183,6 @@ void main() {
);

final ima.AdMediaInfo mockAdMediaInfo = MockAdMediaInfo();

loadAdCallback(MockVideoAdPlayer(), mockAdMediaInfo, MockAdPodInfo());

final MockVideoAdPlayerCallback mockPlayerCallback =
Expand Down Expand Up @@ -262,7 +264,6 @@ void main() {
);

final ima.AdMediaInfo mockAdMediaInfo = MockAdMediaInfo();

loadAdCallback(MockVideoAdPlayer(), mockAdMediaInfo, MockAdPodInfo());

final MockVideoAdPlayerCallback mockPlayerCallback =
Expand All @@ -273,5 +274,107 @@ void main() {

verify(mockPlayerCallback.onError(mockAdMediaInfo));
});

test('play ad once when it is prepared', () async {
late final void Function(
ima.VideoAdPlayer,
ima.AdMediaInfo,
ima.AdPodInfo,
) loadAdCallback;

late final void Function(
ima.VideoAdPlayer,
ima.VideoAdPlayerCallback,
) addCallbackCallback;

late final Future<void> Function(
ima.VideoView,
ima.MediaPlayer,
) onPreparedCallback;

const int adDuration = 100;
const int adProgress = 10;

final InteractiveMediaAdsProxy imaProxy = InteractiveMediaAdsProxy(
newFrameLayout: () => MockFrameLayout(),
newVideoView: ({
dynamic onError,
void Function(
ima.VideoView,
ima.MediaPlayer,
)? onPrepared,
dynamic onCompletion,
}) {
// VideoView.onPrepared returns void, but the implementation uses an
// async callback method.
onPreparedCallback = onPrepared! as Future<void> Function(
ima.VideoView,
ima.MediaPlayer,
);
final MockVideoView mockVideoView = MockVideoView();
when(mockVideoView.getCurrentPosition()).thenAnswer(
(_) async => adProgress,
);
return mockVideoView;
},
createAdDisplayContainerImaSdkFactory: (_, __) async {
return MockAdDisplayContainer();
},
newVideoAdPlayer: ({
required void Function(
ima.VideoAdPlayer,
ima.VideoAdPlayerCallback,
) addCallback,
required void Function(
ima.VideoAdPlayer,
ima.AdMediaInfo,
ima.AdPodInfo,
) loadAd,
required dynamic pauseAd,
required dynamic playAd,
required dynamic release,
required dynamic removeCallback,
required dynamic stopAd,
}) {
loadAdCallback = loadAd;
addCallbackCallback = addCallback;
return MockVideoAdPlayer();
},
newVideoProgressUpdate: ({
required int currentTimeMs,
required int durationMs,
}) {
expect(currentTimeMs, adProgress);
expect(durationMs, adDuration);
return MockVideoProgressUpdate();
},
);

AndroidAdDisplayContainer(
AndroidAdDisplayContainerCreationParams(
onContainerAdded: (_) {},
imaProxy: imaProxy,
),
);

final ima.AdMediaInfo mockAdMediaInfo = MockAdMediaInfo();
loadAdCallback(MockVideoAdPlayer(), mockAdMediaInfo, MockAdPodInfo());

final MockVideoAdPlayerCallback mockPlayerCallback =
MockVideoAdPlayerCallback();
addCallbackCallback(MockVideoAdPlayer(), mockPlayerCallback);

final MockMediaPlayer mockMediaPlayer = MockMediaPlayer();
when(mockMediaPlayer.getDuration()).thenAnswer((_) async => adDuration);

await onPreparedCallback(MockVideoView(), mockMediaPlayer);

verify(mockMediaPlayer.start());

// Ad progress is updated with a reoccurring timer, so this waits for
// at least one update.
await Future<void>.delayed(const Duration(milliseconds: 300));
verify(mockPlayerCallback.onAdProgress(mockAdMediaInfo, any));
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ class _FakeVideoAdPlayerCallback_7 extends _i1.SmartFake
);
}

class _FakeVideoView_8 extends _i1.SmartFake implements _i2.VideoView {
_FakeVideoView_8(
class _FakeVideoProgressUpdate_8 extends _i1.SmartFake
implements _i2.VideoProgressUpdate {
_FakeVideoProgressUpdate_8(
Object parent,
Invocation parentInvocation,
) : super(
Expand All @@ -120,8 +121,8 @@ class _FakeVideoView_8 extends _i1.SmartFake implements _i2.VideoView {
);
}

class _FakeOffset_9 extends _i1.SmartFake implements _i3.Offset {
_FakeOffset_9(
class _FakeVideoView_9 extends _i1.SmartFake implements _i2.VideoView {
_FakeVideoView_9(
Object parent,
Invocation parentInvocation,
) : super(
Expand All @@ -130,8 +131,8 @@ class _FakeOffset_9 extends _i1.SmartFake implements _i3.Offset {
);
}

class _FakeSize_10 extends _i1.SmartFake implements _i3.Size {
_FakeSize_10(
class _FakeOffset_10 extends _i1.SmartFake implements _i3.Offset {
_FakeOffset_10(
Object parent,
Invocation parentInvocation,
) : super(
Expand All @@ -140,9 +141,19 @@ class _FakeSize_10 extends _i1.SmartFake implements _i3.Size {
);
}

class _FakeExpensiveAndroidViewController_11 extends _i1.SmartFake
class _FakeSize_11 extends _i1.SmartFake implements _i3.Size {
_FakeSize_11(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}

class _FakeExpensiveAndroidViewController_12 extends _i1.SmartFake
implements _i4.ExpensiveAndroidViewController {
_FakeExpensiveAndroidViewController_11(
_FakeExpensiveAndroidViewController_12(
Object parent,
Invocation parentInvocation,
) : super(
Expand All @@ -151,9 +162,9 @@ class _FakeExpensiveAndroidViewController_11 extends _i1.SmartFake
);
}

class _FakeSurfaceAndroidViewController_12 extends _i1.SmartFake
class _FakeSurfaceAndroidViewController_13 extends _i1.SmartFake
implements _i4.SurfaceAndroidViewController {
_FakeSurfaceAndroidViewController_12(
_FakeSurfaceAndroidViewController_13(
Object parent,
Invocation parentInvocation,
) : super(
Expand Down Expand Up @@ -822,6 +833,47 @@ class MockVideoAdPlayerCallback extends _i1.Mock
) as _i2.VideoAdPlayerCallback);
}

/// A class which mocks [VideoProgressUpdate].
///
/// See the documentation for Mockito's code generation for more information.
class MockVideoProgressUpdate extends _i1.Mock
implements _i2.VideoProgressUpdate {
@override
_i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod(
Invocation.getter(#pigeon_instanceManager),
returnValue: _FakePigeonInstanceManager_0(
this,
Invocation.getter(#pigeon_instanceManager),
),
returnValueForMissingStub: _FakePigeonInstanceManager_0(
this,
Invocation.getter(#pigeon_instanceManager),
),
) as _i2.PigeonInstanceManager);

@override
_i2.VideoProgressUpdate pigeon_copy() => (super.noSuchMethod(
Invocation.method(
#pigeon_copy,
[],
),
returnValue: _FakeVideoProgressUpdate_8(
this,
Invocation.method(
#pigeon_copy,
[],
),
),
returnValueForMissingStub: _FakeVideoProgressUpdate_8(
this,
Invocation.method(
#pigeon_copy,
[],
),
),
) as _i2.VideoProgressUpdate);
}

/// A class which mocks [VideoView].
///
/// See the documentation for Mockito's code generation for more information.
Expand Down Expand Up @@ -892,14 +944,14 @@ class MockVideoView extends _i1.Mock implements _i2.VideoView {
#pigeon_copy,
[],
),
returnValue: _FakeVideoView_8(
returnValue: _FakeVideoView_9(
this,
Invocation.method(
#pigeon_copy,
[],
),
),
returnValueForMissingStub: _FakeVideoView_8(
returnValueForMissingStub: _FakeVideoView_9(
this,
Invocation.method(
#pigeon_copy,
Expand Down Expand Up @@ -938,11 +990,11 @@ class MockSurfaceAndroidViewController extends _i1.Mock
@override
_i4.PointTransformer get pointTransformer => (super.noSuchMethod(
Invocation.getter(#pointTransformer),
returnValue: (_i3.Offset position) => _FakeOffset_9(
returnValue: (_i3.Offset position) => _FakeOffset_10(
this,
Invocation.getter(#pointTransformer),
),
returnValueForMissingStub: (_i3.Offset position) => _FakeOffset_9(
returnValueForMissingStub: (_i3.Offset position) => _FakeOffset_10(
this,
Invocation.getter(#pointTransformer),
),
Expand Down Expand Up @@ -1006,14 +1058,14 @@ class MockSurfaceAndroidViewController extends _i1.Mock
#setSize,
[size],
),
returnValue: _i6.Future<_i3.Size>.value(_FakeSize_10(
returnValue: _i6.Future<_i3.Size>.value(_FakeSize_11(
this,
Invocation.method(
#setSize,
[size],
),
)),
returnValueForMissingStub: _i6.Future<_i3.Size>.value(_FakeSize_10(
returnValueForMissingStub: _i6.Future<_i3.Size>.value(_FakeSize_11(
this,
Invocation.method(
#setSize,
Expand Down Expand Up @@ -1126,7 +1178,7 @@ class MockPlatformViewsServiceProxy extends _i1.Mock
#onFocus: onFocus,
},
),
returnValue: _FakeExpensiveAndroidViewController_11(
returnValue: _FakeExpensiveAndroidViewController_12(
this,
Invocation.method(
#initExpensiveAndroidView,
Expand All @@ -1141,7 +1193,7 @@ class MockPlatformViewsServiceProxy extends _i1.Mock
},
),
),
returnValueForMissingStub: _FakeExpensiveAndroidViewController_11(
returnValueForMissingStub: _FakeExpensiveAndroidViewController_12(
this,
Invocation.method(
#initExpensiveAndroidView,
Expand Down Expand Up @@ -1180,7 +1232,7 @@ class MockPlatformViewsServiceProxy extends _i1.Mock
#onFocus: onFocus,
},
),
returnValue: _FakeSurfaceAndroidViewController_12(
returnValue: _FakeSurfaceAndroidViewController_13(
this,
Invocation.method(
#initSurfaceAndroidView,
Expand All @@ -1195,7 +1247,7 @@ class MockPlatformViewsServiceProxy extends _i1.Mock
},
),
),
returnValueForMissingStub: _FakeSurfaceAndroidViewController_12(
returnValueForMissingStub: _FakeSurfaceAndroidViewController_13(
this,
Invocation.method(
#initSurfaceAndroidView,
Expand Down