diff --git a/components/brave_rewards/browser/rewards_service_browsertest.cc b/components/brave_rewards/browser/test/rewards_browsertest.cc similarity index 94% rename from components/brave_rewards/browser/rewards_service_browsertest.cc rename to components/brave_rewards/browser/test/rewards_browsertest.cc index e6122184f8b1..600112266e56 100644 --- a/components/brave_rewards/browser/rewards_service_browsertest.cc +++ b/components/brave_rewards/browser/test/rewards_browsertest.cc @@ -8,29 +8,29 @@ #include #include +#include "base/memory/weak_ptr.h" #include "base/path_service.h" #include "base/run_loop.h" #include "base/strings/string_split.h" #include "base/strings/stringprintf.h" -#include "base/memory/weak_ptr.h" #include "base/test/bind_test_util.h" #include "bat/ledger/internal/bat_helper.h" -#include "bat/ledger/internal/uphold/uphold_util.h" #include "bat/ledger/internal/request/request_util.h" #include "bat/ledger/internal/static_values.h" +#include "bat/ledger/internal/uphold/uphold_util.h" #include "bat/ledger/ledger.h" #include "brave/browser/extensions/api/brave_action_api.h" +#include "brave/browser/ui/views/brave_actions/brave_actions_container.h" +#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h" #include "brave/common/brave_paths.h" #include "brave/common/extensions/extension_constants.h" -#include "brave/components/brave_rewards/browser/rewards_service_browsertest_utils.h" +#include "brave/components/brave_rewards/browser/test/rewards_browsertest_context_utils.h" // NOLINT +#include "brave/components/brave_rewards/browser/rewards_notification_service_impl.h" // NOLINT +#include "brave/components/brave_rewards/browser/rewards_notification_service_observer.h" // NOLINT #include "brave/browser/brave_rewards/rewards_service_factory.h" #include "brave/components/brave_rewards/browser/rewards_service_impl.h" #include "brave/components/brave_rewards/browser/rewards_service_observer.h" -#include "brave/components/brave_rewards/browser/rewards_notification_service_impl.h" // NOLINT -#include "brave/components/brave_rewards/browser/rewards_notification_service_observer.h" // NOLINT #include "brave/components/brave_rewards/common/pref_names.h" -#include "brave/browser/ui/views/brave_actions/brave_actions_container.h" -#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/common/chrome_paths.h" @@ -273,7 +273,7 @@ class BraveRewardsBrowserTest std::vector GetSiteBannerTipOptions( content::WebContents* site_banner) { - rewards_service_browsertest_utils::WaitForElementToAppear( + rewards_browsertest_utils::WaitForElementToAppear( site_banner, "[data-test-id=amount-wrapper] div span"); auto options = content::EvalJs( @@ -297,7 +297,7 @@ class BraveRewardsBrowserTest static std::vector GetRewardsPopupTipOptions( content::WebContents* popup) { - rewards_service_browsertest_utils::WaitForElementToAppear( + rewards_browsertest_utils::WaitForElementToAppear( popup, "option:not(:disabled)"); auto options = content::EvalJs( @@ -616,7 +616,7 @@ class BraveRewardsBrowserTest // Wait for the popup to load popup_observer.Wait(); - rewards_service_browsertest_utils::WaitForElementToAppear( + rewards_browsertest_utils::WaitForElementToAppear( popup_contents, "[data-test-id='rewards-panel']"); @@ -753,10 +753,10 @@ class BraveRewardsBrowserTest ui_test_utils::NavigateToURL(browser(), page_url); WaitForLoadStop(contents()); // Opt in and create wallet to enable rewards - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "[data-test-id='optInAction']"); - rewards_service_browsertest_utils::WaitForElementToAppear( + rewards_browsertest_utils::WaitForElementToAppear( contents(), "[data-test-id2='enableMain']"); } @@ -794,21 +794,21 @@ class BraveRewardsBrowserTest // Claim promotion via settings page or panel, as instructed if (use_panel) { - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents, "button"); } else { - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents, "[data-test-id='claimGrant']"); } // Wait for CAPTCHA - rewards_service_browsertest_utils::WaitForElementToAppear( + rewards_browsertest_utils::WaitForElementToAppear( contents, "[data-test-id='captcha']"); - rewards_service_browsertest_utils::DragAndDrop( + rewards_browsertest_utils::DragAndDrop( contents, "[data-test-id=\"captcha-triangle\"]", "[data-test-id=\"captcha-drop\"]"); @@ -825,18 +825,18 @@ class BraveRewardsBrowserTest // Check that promotion notification shows the appropriate amount const std::string selector = use_panel ? "[id='root']" : "[data-test-id='newTokenGrant']"; - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents, selector, "Free Token Grant"); - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents, selector, "30.0 BAT"); // Dismiss the promotion notification if (use_panel) { - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents, "#" "grant-completed-ok"); } @@ -879,7 +879,7 @@ class BraveRewardsBrowserTest WaitForPublisherListNormalized(); // Make sure site appears in auto-contribute table - rewards_service_browsertest_utils::WaitForElementToEqual( + rewards_browsertest_utils::WaitForElementToEqual( contents(), "[data-test-id='ac_link_" + publisher + "']", publisher); @@ -913,7 +913,7 @@ class BraveRewardsBrowserTest std::string RewardsPageTipSummaryAmount() const { const std::string amount = - rewards_service_browsertest_utils::WaitForElementThenGetContent( + rewards_browsertest_utils::WaitForElementThenGetContent( contents(), "[data-test-id=summary-tips] [color=contribute] span span"); return amount + " BAT"; @@ -932,7 +932,7 @@ class BraveRewardsBrowserTest } void RefreshPublisherListUsingRewardsPopup() const { - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( OpenRewardsPopup(), "[data-test-id='unverified-check-button']"); } @@ -951,7 +951,7 @@ class BraveRewardsBrowserTest : "[type='tip']"; // Click button to initiate sending a tip. - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( popup_contents, buttonSelector); @@ -1000,12 +1000,12 @@ class BraveRewardsBrowserTest std::string amount_selector = base::StringPrintf( "div:nth-of-type(%u)>[data-test-id=amount-wrapper]", selection + 1); - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( site_banner_contents, amount_selector); // Send the tip - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( site_banner_contents, "[data-test-id='send-tip-button']"); @@ -1051,19 +1051,19 @@ class BraveRewardsBrowserTest // Make sure that thank you banner shows correct publisher data // (domain and amount) { - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( site_banner_contents, "body", confirmationText); - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( site_banner_contents, "body", amount_str + " BAT"); - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( site_banner_contents, "body", "Share the good news:"); - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( site_banner_contents, "body", "" + GetBalance() + " BAT"); @@ -1093,7 +1093,7 @@ class BraveRewardsBrowserTest ? "[data-test-id='summary-monthly']" : "[data-test-id='summary-tips']"; - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents(), selector, "-" + BalanceDoubleToString(amount) + "BAT"); @@ -1107,7 +1107,7 @@ class BraveRewardsBrowserTest // amount IsPendingBalanceCorrect(); - rewards_service_browsertest_utils::WaitForElementToEqual( + rewards_browsertest_utils::WaitForElementToEqual( contents(), "#tip-box-total", "0.0BAT0.00 USD"); @@ -1115,7 +1115,7 @@ class BraveRewardsBrowserTest void IsBalanceCorrect() { const std::string balance = GetBalance() + " BAT"; - rewards_service_browsertest_utils::WaitForElementToEqual( + rewards_browsertest_utils::WaitForElementToEqual( contents(), "[data-test-id='balance']", balance); @@ -1123,7 +1123,7 @@ class BraveRewardsBrowserTest void IsPendingBalanceCorrect() { const std::string balance = GetPendingBalance() + " BAT"; - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents(), "[data-test-id='pending-contribution-box']", balance); @@ -1434,21 +1434,21 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ToggleRewards) { EnableRewards(); // Toggle rewards off - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "[data-test-id2='enableMain']"); std::string value = - rewards_service_browsertest_utils::WaitForElementThenGetAttribute( + rewards_browsertest_utils::WaitForElementThenGetAttribute( contents(), "[data-test-id2='enableMain']", "data-toggled"); ASSERT_STREQ(value.c_str(), "false"); // Toggle rewards back on - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "[data-test-id2='enableMain']"); - value = rewards_service_browsertest_utils::WaitForElementThenGetAttribute( + value = rewards_browsertest_utils::WaitForElementThenGetAttribute( contents(), "[data-test-id2='enableMain']", "data-toggled"); @@ -1463,21 +1463,21 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ToggleAutoContribute) { EXPECT_TRUE(WaitForLoadStop(contents())); // toggle auto contribute off - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "[data-test-id2='autoContribution']"); std::string value = - rewards_service_browsertest_utils::WaitForElementThenGetAttribute( + rewards_browsertest_utils::WaitForElementThenGetAttribute( contents(), "[data-test-id2='autoContribution']", "data-toggled"); ASSERT_STREQ(value.c_str(), "false"); // toggle auto contribute back on - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "[data-test-id2='autoContribution']"); - value = rewards_service_browsertest_utils::WaitForElementThenGetAttribute( + value = rewards_browsertest_utils::WaitForElementThenGetAttribute( contents(), "[data-test-id2='autoContribution']", "data-toggled"); @@ -1487,10 +1487,10 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ToggleAutoContribute) { IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ActivateSettingsModal) { EnableRewards(); - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "[data-test-id='settingsButton']"); - rewards_service_browsertest_utils::WaitForElementToAppear( + rewards_browsertest_utils::WaitForElementToAppear( contents(), "#modal"); } @@ -1727,11 +1727,11 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, // Retrieve the inner text of the wallet panel and verify that it // looks as expected - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( popup_contents, "[id='wallet-panel']", "Brave Verified Creator"); - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( popup_contents, "[id='wallet-panel']", publisher); @@ -1741,7 +1741,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, { const std::string favicon = "chrome://favicon/size/64@1x/https://" + publisher; - rewards_service_browsertest_utils::WaitForElementToContainHTML( + rewards_browsertest_utils::WaitForElementToContainHTML( popup_contents, "#wallet-panel", favicon); @@ -1790,7 +1790,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, AutoContribution) { IsBalanceCorrect(); // Check that summary table shows the appropriate contribution - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents(), "[color=contribute]", "-20.0BAT"); @@ -1806,11 +1806,11 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, AutoContributeWhenACOff) { VisitPublisher("duckduckgo.com", verified); // toggle auto contribute off - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "[data-test-id2='autoContribution']"); std::string value = - rewards_service_browsertest_utils::WaitForElementThenGetAttribute( + rewards_browsertest_utils::WaitForElementThenGetAttribute( contents(), "[data-test-id2='autoContribution']", "data-toggled"); @@ -1878,7 +1878,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, TwitterTipsInjectedOnTwitter) { ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media tips injection is active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), true); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), true); } // Brave tip icon is not injected when visiting Twitter while Brave @@ -1892,7 +1892,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media tips injection is not active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), false); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), false); } // Brave tip icon is injected when visiting old Twitter @@ -1908,7 +1908,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media tips injection is active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), true); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), true); } // Brave tip icon is not injected when visiting old Twitter while @@ -1922,7 +1922,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media tips injection is not active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), false); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), false); } // Brave tip icon is not injected into non-Twitter sites @@ -1938,7 +1938,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media tips injection is not active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), false); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), false); } // Brave tip icon is injected when visiting Reddit @@ -1953,7 +1953,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, RedditTipsInjectedOnReddit) { ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media Tips injection is active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), true); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), true); } // Brave tip icon is not injected when visiting Reddit @@ -1966,7 +1966,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media Tips injection is not active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), false); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), false); } // Brave tip icon is not injected when visiting Reddit @@ -1982,7 +1982,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media Tips injection is not active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), false); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), false); } // Brave tip icon is injected when visiting GitHub @@ -1997,7 +1997,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, GitHubTipsInjectedOnGitHub) { ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media Tips injection is active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), true); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), true); } // Brave tip icon is not injected when visiting GitHub while Brave @@ -2011,7 +2011,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media Tips injection is not active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), false); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), false); } // Brave tip icon is not injected when not visiting GitHub @@ -2027,7 +2027,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP); // Ensure that Media Tips injection is not active - rewards_service_browsertest_utils::IsMediaTipsInjected(contents(), false); + rewards_browsertest_utils::IsMediaTipsInjected(contents(), false); } // Check pending contributions @@ -2044,12 +2044,12 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, TipPublisher(publisher, ContributionType::OneTimeTip); // Check that link for pending is shown and open modal - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "[data-test-id='reservedAllLink']"); // Make sure that table is populated - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents(), "[id='pendingContributionTable'] a", publisher); @@ -2232,7 +2232,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ProcessPendingContributions) { IsBalanceCorrect(); // Check that wallet summary shows the appropriate tip amount - rewards_service_browsertest_utils::WaitForElementToEqual( + rewards_browsertest_utils::WaitForElementToEqual( contents(), "[data-test-id=summary-tips] [color=contribute] span span", ExpectedTipSummaryAmountString()); @@ -2246,18 +2246,18 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ProcessPendingContributions) { ASSERT_TRUE(popup_contents); // Check if verified notification is shown - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( popup_contents, "#root", "3zsistemi.si"); // Close notification - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( popup_contents, "[data-test-id=notification-close]"); // Check if insufficient funds notification is shown - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( popup_contents, "#root", "Insufficient Funds"); @@ -2327,12 +2327,12 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, NotVerifiedWallet) { EnableRewards(); // Click on verify button - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "#verify-wallet-button"); // Click on verify button in on boarding - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "#on-boarding-verify-button"); @@ -2477,7 +2477,7 @@ IN_PROC_BROWSER_TEST_F( IsBalanceCorrect(); // Make sure that tips table is empty - rewards_service_browsertest_utils::WaitForElementToEqual( + rewards_browsertest_utils::WaitForElementToEqual( contents(), "#tips-table > div > div", "Have you tipped your favorite content creator today?"); @@ -2507,7 +2507,7 @@ IN_PROC_BROWSER_TEST_F( IsBalanceCorrect(); // Make sure that tips table is empty - rewards_service_browsertest_utils::WaitForElementToEqual( + rewards_browsertest_utils::WaitForElementToEqual( contents(), "#tips-table > div > div", "Have you tipped your favorite content creator today?"); @@ -2580,7 +2580,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, IsBalanceCorrect(); // Check that summary table shows the appropriate contribution - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents(), "[color='contribute']", "-5.0BAT"); @@ -2642,7 +2642,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, // Check that summary table shows the appropriate contribution // Check that summary table shows the appropriate contribution - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents(), "[color='contribute']", "-5.0BAT"); @@ -2676,7 +2676,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ShowMonthlyIfACOff) { content::WebContents *popup_contents = OpenRewardsPopup(); ASSERT_TRUE(popup_contents); - rewards_service_browsertest_utils::WaitForElementToAppear( + rewards_browsertest_utils::WaitForElementToAppear( popup_contents, "#panel-donate-monthly"); } @@ -2696,7 +2696,7 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsBrowserTest, ShowACPercentInThePanel) { ASSERT_TRUE(popup_contents); const std::string score = - rewards_service_browsertest_utils::WaitForElementThenGetContent( + rewards_browsertest_utils::WaitForElementThenGetContent( popup_contents, "[data-test-id='attention-score']"); EXPECT_NE(score.find("100%"), std::string::npos); @@ -2724,26 +2724,26 @@ IN_PROC_BROWSER_TEST_F( ASSERT_EQ(multiple_ac_reconcile_status_[0], ledger::Result::LEDGER_OK); ASSERT_EQ(multiple_ac_reconcile_status_[1], ledger::Result::LEDGER_OK); - rewards_service_browsertest_utils::WaitForElementThenClick( + rewards_browsertest_utils::WaitForElementThenClick( contents(), "[data-test-id='showMonthlyReport']"); - rewards_service_browsertest_utils::WaitForElementToAppear( + rewards_browsertest_utils::WaitForElementToAppear( contents(), "#transactionTable"); - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents(), "#transactionTable", "-30.0BAT"); - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents(), "#transactionTable", "-20.0BAT"); // Check that summary table shows the appropriate contribution - rewards_service_browsertest_utils::WaitForElementToContain( + rewards_browsertest_utils::WaitForElementToContain( contents(), "[color=contribute]", "-50.0BAT"); diff --git a/components/brave_rewards/browser/rewards_service_browsertest_utils.cc b/components/brave_rewards/browser/test/rewards_browsertest_context_utils.cc similarity index 98% rename from components/brave_rewards/browser/rewards_service_browsertest_utils.cc rename to components/brave_rewards/browser/test/rewards_browsertest_context_utils.cc index 323575ee3e27..85c924b439a5 100644 --- a/components/brave_rewards/browser/rewards_service_browsertest_utils.cc +++ b/components/brave_rewards/browser/test/rewards_browsertest_context_utils.cc @@ -3,11 +3,10 @@ * 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_browsertest_utils.h" - +#include "brave/components/brave_rewards/browser/test/rewards_browsertest_context_utils.h" // NOLINT #include "content/public/test/browser_test_utils.h" -namespace rewards_service_browsertest_utils { +namespace rewards_browsertest_utils { static const char kWaitForElementToAppearScript[] = R"( const waitForElementToAppear = (selector) => { @@ -394,4 +393,4 @@ void IsMediaTipsInjected(content::WebContents* context, bool should_appear) { WaitForElementToAppear(context, ".action-brave-tip", should_appear); } -} // namespace rewards_service_browsertest_utils +} // namespace rewards_browsertest_utils diff --git a/components/brave_rewards/browser/rewards_service_browsertest_utils.h b/components/brave_rewards/browser/test/rewards_browsertest_context_utils.h similarity index 80% rename from components/brave_rewards/browser/rewards_service_browsertest_utils.h rename to components/brave_rewards/browser/test/rewards_browsertest_context_utils.h index e9cf9952c897..edc9d5c4afd6 100644 --- a/components/brave_rewards/browser/rewards_service_browsertest_utils.h +++ b/components/brave_rewards/browser/test/rewards_browsertest_context_utils.h @@ -3,17 +3,18 @@ * 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/. */ -#ifndef BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_REWARDS_SERVICE_BROWSERTEST_UTILS_H_ -#define BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_REWARDS_SERVICE_BROWSERTEST_UTILS_H_ +#ifndef BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_REWARDS_BROWSERTEST_CONTEXT_UTILS_H_ +#define BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_REWARDS_BROWSERTEST_CONTEXT_UTILS_H_ #include + #include "build/build_config.h" namespace content { class WebContents; } // namespace content -namespace rewards_service_browsertest_utils { +namespace rewards_browsertest_utils { void WaitForElementToAppear( content::WebContents* context, @@ -55,6 +56,6 @@ void DragAndDrop( void IsMediaTipsInjected(content::WebContents* contents, bool should_appear); -} // namespace rewards_service_browsertest_utils +} // namespace rewards_browsertest_utils -#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_REWARDS_SERVICE_BROWSERTEST_UTILS_H_ +#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_REWARDS_BROWSERTEST_CONTEXT_UTILS_H_ diff --git a/components/brave_rewards/browser/rewards_database_browsertest.cc b/components/brave_rewards/browser/test/rewards_database_browsertest.cc similarity index 99% rename from components/brave_rewards/browser/rewards_database_browsertest.cc rename to components/brave_rewards/browser/test/rewards_database_browsertest.cc index 3ac4162e83ba..173cb1ec3a38 100644 --- a/components/brave_rewards/browser/rewards_database_browsertest.cc +++ b/components/brave_rewards/browser/test/rewards_database_browsertest.cc @@ -8,11 +8,11 @@ #include #include +#include "base/memory/weak_ptr.h" #include "base/path_service.h" #include "base/run_loop.h" #include "base/strings/string_split.h" #include "base/strings/stringprintf.h" -#include "base/memory/weak_ptr.h" #include "base/test/bind_test_util.h" #include "bat/ledger/internal/bat_helper.h" #include "bat/ledger/internal/database/database_util.h" @@ -20,21 +20,21 @@ #include "bat/ledger/internal/static_values.h" #include "bat/ledger/ledger.h" #include "brave/browser/extensions/api/brave_action_api.h" +#include "brave/browser/ui/views/brave_actions/brave_actions_container.h" +#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h" #include "brave/common/brave_paths.h" #include "brave/common/extensions/extension_constants.h" -#include "brave/browser/brave_rewards/rewards_service_factory.h" -#include "brave/components/brave_rewards/browser/rewards_service_impl.h" -#include "brave/components/brave_rewards/browser/rewards_service_observer.h" -#include "brave/components/brave_rewards/browser/rewards_notification_service_impl.h" // NOLINT -#include "brave/components/brave_rewards/browser/rewards_notification_service_observer.h" // NOLINT -#include "brave/components/brave_rewards/common/pref_names.h" #include "brave/components/brave_ads/browser/ads_service_factory.h" #include "brave/components/brave_ads/browser/ads_service_impl.h" -#include "brave/components/brave_ads/common/pref_names.h" #include "brave/components/brave_ads/browser/locale_helper_mock.h" #include "brave/components/brave_ads/browser/notification_helper_mock.h" -#include "brave/browser/ui/views/brave_actions/brave_actions_container.h" -#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h" +#include "brave/components/brave_ads/common/pref_names.h" +#include "brave/components/brave_rewards/browser/rewards_notification_service_impl.h" // NOLINT +#include "brave/components/brave_rewards/browser/rewards_notification_service_observer.h" // NOLINT +#include "brave/components/brave_rewards/browser/rewards_service_factory.h" +#include "brave/components/brave_rewards/browser/rewards_service_impl.h" +#include "brave/components/brave_rewards/browser/rewards_service_observer.h" +#include "brave/components/brave_rewards/common/pref_names.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/common/chrome_constants.h" @@ -49,11 +49,11 @@ #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_response.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" #include "sql/database.h" #include "sql/meta_table.h" #include "sql/statement.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" // npm run test -- brave_browser_tests --filter=RewardsDatabaseBrowserTest.* diff --git a/test/BUILD.gn b/test/BUILD.gn index c7c7f7055287..1fed30798f86 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -689,10 +689,10 @@ test("brave_browser_tests") { if (brave_rewards_enabled) { sources += [ "//brave/components/brave_rewards/browser/rewards_notification_service_browsertest.cc", - "//brave/components/brave_rewards/browser/rewards_database_browsertest.cc", - "//brave/components/brave_rewards/browser/rewards_service_browsertest.cc", - "//brave/components/brave_rewards/browser/rewards_service_browsertest_utils.cc", - "//brave/components/brave_rewards/browser/rewards_service_browsertest_utils.h", + "//brave/components/brave_rewards/browser/test/rewards_database_browsertest.cc", + "//brave/components/brave_rewards/browser/test/rewards_browsertest.cc", + "//brave/components/brave_rewards/browser/test/rewards_browsertest_context_utils.cc", + "//brave/components/brave_rewards/browser/test/rewards_browsertest_context_utils.h", "//brave/components/brave_ads/browser/ads_service_browsertest.cc", "//brave/components/brave_ads/browser/locale_helper_mock.cc", "//brave/components/brave_ads/browser/locale_helper_mock.h",