Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

ListenersHolder collaborator #30

Merged
merged 8 commits into from
Jun 2, 2017
Merged

Conversation

Mecharyry
Copy link
Contributor

Problem

PlayerListenersHolder was the super of ExoPlayerImpl that held all of the listeners and exposed them through protected method to the ExoPlayerImpl. The protected methods made it difficult to test the ExoPlayerImpl because we were unable to mock this dependency.

Solution

Extract PlayerListenersHolder as a collaborator so that we can mock it and test more thoroughly the ExoPlayerImpl.

Test(s) added

😱 YES! More tests for the ExoPlayerImpl.

Screenshots

No UI changes.

Paired with

@juankysoriano and 🍵

@@ -242,6 +246,11 @@ public void selectAudioTrack(PlayerAudioTrack audioTrack) {
return trackSelector.getAudioTracks();
}

@Override
public PlayerListenersHolder getListenerHolder() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getListenersHolder?

Copy link
Contributor

@joetimmins joetimmins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about leaving the add / remove listener methods on the Player implementations themselves, so you don't end up with code like player.getListenersHolder().addPreparedListener() which I guess would be more law of demeter compliant..... but those interfaces are huge already, so I'm fine with doing it this way.

@Mecharyry
Copy link
Contributor Author

Mecharyry commented Jun 2, 2017

Yea we considered it too @joetimmins, interfaces are already too large 😢 I'm glad you agree 😄

@ouchadam ouchadam merged commit 790740f into exo-player-2 Jun 2, 2017
@ouchadam ouchadam deleted the exoplayer2_unit_tests_two branch June 2, 2017 11:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants