forked from brave/brave-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes brave/brave-browser#2245, monthly donation functionality
- Loading branch information
Showing
22 changed files
with
349 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
components/brave_rewards/browser/extension_rewards_service_observer_browsertest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/components/brave_rewards/browser/rewards_service.h" | ||
#include "brave/components/brave_rewards/browser/rewards_service_factory.h" | ||
#include "brave/components/brave_rewards/browser/extension_rewards_service_observer.h" | ||
#include "chrome/browser/ui/browser.h" | ||
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "chrome/test/base/ui_test_utils.h" | ||
#include "content/public/test/browser_test_utils.h" | ||
|
||
using namespace brave_rewards; | ||
|
||
class ExtensionRewardsServiceObserverBrowserTest | ||
: public InProcessBrowserTest, | ||
public RewardsServiceObserver { | ||
public: | ||
|
||
void SetUpOnMainThread() override { | ||
InProcessBrowserTest::SetUpOnMainThread(); | ||
rewards_service_ = RewardsServiceFactory::GetForProfile(browser()->profile()); | ||
} | ||
|
||
void TearDown() override { | ||
InProcessBrowserTest::TearDown(); | ||
} | ||
|
||
void OnRecurringDonations( | ||
RewardsService* rewards_service, | ||
const ledger::PublisherInfoList& list) override { | ||
|
||
ledger::PublisherInfo firstPublisher = list.front(); | ||
EXPECT_STREQ(firstPublisher.id.c_str(), "brave.com"); | ||
EXPECT_STREQ(std::to_string(firstPublisher.weight).c_str(), "10"); | ||
|
||
on_recurring_notifications_callback_was_called_ = true; | ||
} | ||
|
||
void WaitForOnRecurringDonationsCallback() { | ||
if (on_recurring_notifications_callback_was_called_) { | ||
return; | ||
} | ||
|
||
base::RunLoop run_loop; | ||
run_loop.Run(); | ||
} | ||
|
||
RewardsService* rewards_service_; | ||
bool on_recurring_notifications_callback_was_called_ = false; | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(ExtensionRewardsServiceObserverBrowserTest, SaveARecurringDonation) { | ||
rewards_service_->AddObserver(this); | ||
|
||
rewards_service_->AddRecurringPayment("brave.com", 10); | ||
WaitForOnRecurringDonationsCallback(); | ||
|
||
rewards_service_->RemoveObserver(this); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.