Skip to content

Commit

Permalink
Merge pull request #8845 from brave/rewards-fix-ads-upgrade-browser-t…
Browse files Browse the repository at this point in the history
…est-crash

Only wait for OnRewardsInitialized if it didn't already fire
  • Loading branch information
emerick authored May 19, 2021
2 parents 36de5d0 + 937d0c5 commit 5fc68f6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion components/brave_ads/browser/ads_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,25 @@ class TestRewardsServiceObserver
~TestRewardsServiceObserver() override = default;

void WaitForRewardsInitialization() {
if (rewards_initialized_) {
return;
}

run_loop_ = std::make_unique<base::RunLoop>();
run_loop_->Run();
}

// RewardsServiceObserver implementation
void OnRewardsInitialized(brave_rewards::RewardsService* service) override {
run_loop_->Quit();
rewards_initialized_ = true;
if (run_loop_) {
run_loop_->Quit();
}
}

private:
std::unique_ptr<base::RunLoop> run_loop_;
bool rewards_initialized_ = false;
};

class BraveAdsBrowserTest : public InProcessBrowserTest,
Expand Down

0 comments on commit 5fc68f6

Please sign in to comment.