Skip to content

Commit

Permalink
Fix ads not shown if a background tab is playing video
Browse files Browse the repository at this point in the history
  • Loading branch information
tmancey authored Jun 4, 2019
1 parent 793b567 commit 1567127
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ void AdsImpl::OnMediaStopped(const int32_t tab_id) {
}

bool AdsImpl::IsMediaPlaying() const {
if (media_playing_.empty()) {
auto tab = media_playing_.find(last_shown_tab_id_);
if (tab == media_playing_.end()) {
// Media is not playing in the last shown tab
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class AdsTabsTest : public ::testing::Test {

TEST_F(AdsTabsTest, Media_IsPlaying) {
// Arrange
ads_->TabUpdated(1, "https://brave.com", true, false);
ads_->OnMediaPlaying(1);

// Act
Expand All @@ -151,6 +152,8 @@ TEST_F(AdsTabsTest, Media_IsPlaying) {

TEST_F(AdsTabsTest, Media_NotPlaying) {
// Arrange
ads_->TabUpdated(1, "https://brave.com", true, false);

ads_->OnMediaPlaying(1);
ads_->OnMediaPlaying(2);

Expand Down

0 comments on commit 1567127

Please sign in to comment.