-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(wallet): Added Show Test Networks Pref #13098
Conversation
28831e5
to
38006ee
Compare
A Storybook has been deployed to preview UI for the latest push |
@@ -512,6 +512,11 @@ void BraveWalletService::SetDefaultBaseCryptocurrency( | |||
} | |||
} | |||
|
|||
void BraveWalletService::GetShowWalletTestNetworks( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test for this method being backed by a pref.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant it should cover case when changing pref changes service method outcome;)
So please add smth like this
diff --git a/browser/brave_wallet/brave_wallet_service_unittest.cc b/browser/brave_wallet/brave_wallet_service_unittest.cc
index 93c5311959..7e686898b5 100644
--- a/browser/brave_wallet/brave_wallet_service_unittest.cc
+++ b/browser/brave_wallet/brave_wallet_service_unittest.cc
@@ -459,6 +459,18 @@ class BraveWalletServiceUnitTest : public testing::Test {
return default_cryptocurrency;
}
+ bool GetShowWalletTestNetworks() {
+ base::RunLoop run_loop;
+ bool show_wallet_test_networks;
+ service_->GetShowWalletTestNetworks(
+ base::BindLambdaForTesting([&](bool b) {
+ show_wallet_test_networks = b;
+ run_loop.Quit();
+ }));
+ run_loop.Run();
+ return show_wallet_test_networks;
+ }
+
void SimulateOnGetImportInfo(const std::string& new_password,
bool result,
const ImportInfo& info,
@@ -1084,7 +1096,10 @@ TEST_F(BraveWalletServiceUnitTest, GetAndSetDefaultBaseCryptocurrency) {
TEST_F(BraveWalletServiceUnitTest, GetShowWalletTestNetworks) {
// Default value for kShowWalletTestNetworks should be false
EXPECT_FALSE(GetPrefs()->GetBoolean(kShowWalletTestNetworks));
- EXPECT_FALSE(GetShowWalletTestNetworks(GetPrefs()));
+ EXPECT_FALSE(GetShowWalletTestNetworks());
+
+ GetPrefs()->SetBoolean(kShowWalletTestNetworks, true);
+ EXPECT_TRUE(GetShowWalletTestNetworks());
}
TEST_F(BraveWalletServiceUnitTest, EthAddRemoveSetUserAssetVisible) {
Marking as approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha!
Updated, thank you for the help! 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chromium_src
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeScript looks good to me 👍
38006ee
to
4498eb7
Compare
A Storybook has been deployed to preview UI for the latest push |
4498eb7
to
eafe2a1
Compare
A Storybook has been deployed to preview UI for the latest push |
eafe2a1
to
c76a0e7
Compare
A Storybook has been deployed to preview UI for the latest push |
@@ -512,6 +512,11 @@ void BraveWalletService::SetDefaultBaseCryptocurrency( | |||
} | |||
} | |||
|
|||
void BraveWalletService::GetShowWalletTestNetworks( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant it should cover case when changing pref changes service method outcome;)
So please add smth like this
diff --git a/browser/brave_wallet/brave_wallet_service_unittest.cc b/browser/brave_wallet/brave_wallet_service_unittest.cc
index 93c5311959..7e686898b5 100644
--- a/browser/brave_wallet/brave_wallet_service_unittest.cc
+++ b/browser/brave_wallet/brave_wallet_service_unittest.cc
@@ -459,6 +459,18 @@ class BraveWalletServiceUnitTest : public testing::Test {
return default_cryptocurrency;
}
+ bool GetShowWalletTestNetworks() {
+ base::RunLoop run_loop;
+ bool show_wallet_test_networks;
+ service_->GetShowWalletTestNetworks(
+ base::BindLambdaForTesting([&](bool b) {
+ show_wallet_test_networks = b;
+ run_loop.Quit();
+ }));
+ run_loop.Run();
+ return show_wallet_test_networks;
+ }
+
void SimulateOnGetImportInfo(const std::string& new_password,
bool result,
const ImportInfo& info,
@@ -1084,7 +1096,10 @@ TEST_F(BraveWalletServiceUnitTest, GetAndSetDefaultBaseCryptocurrency) {
TEST_F(BraveWalletServiceUnitTest, GetShowWalletTestNetworks) {
// Default value for kShowWalletTestNetworks should be false
EXPECT_FALSE(GetPrefs()->GetBoolean(kShowWalletTestNetworks));
- EXPECT_FALSE(GetShowWalletTestNetworks(GetPrefs()));
+ EXPECT_FALSE(GetShowWalletTestNetworks());
+
+ GetPrefs()->SetBoolean(kShowWalletTestNetworks, true);
+ EXPECT_TRUE(GetShowWalletTestNetworks());
}
TEST_F(BraveWalletServiceUnitTest, EthAddRemoveSetUserAssetVisible) {
Marking as approved.
c76a0e7
to
93ceba5
Compare
93ceba5
to
352a4ea
Compare
A Storybook has been deployed to preview UI for the latest push |
feat(wallet): Added Show Test Networks Pref
Verification for |
Description
Added a
Show test networks
pref inbrave://setting/wallet
and passed toWallet
UIResolves brave/brave-browser#21650
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Screen.Recording.2022-04-20.at.10.31.55.AM.mov