-
Notifications
You must be signed in to change notification settings - Fork 894
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
Remove "Ask Brave for suggestions" from context menu spellcheck section #682
Conversation
@mkarolin would it be possible to make a browser test for this? I'm not 100% sure context menu items can be tested, but it would be cool to check 😄. If it was possible, a great test would be to ensure this item never shows up when right clicking a text field |
Yes, I believe it’s possible. I think I saw a menu observer browser test in
chrome/browser/renderer_context_menu that tests for the presence of this menu item. Will add tomorrow.
… On Oct 18, 2018, at 02:44, Brian Clifton ***@***.***> wrote:
@mkarolin would it be possible to make a browser test for this? I'm not 100% sure context menu items can be tested, but it would be cool to check 😄. If it was possible, a great test would be to ensure this item never shows up when right clicking a text field
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
1d53a44
to
caf6b4f
Compare
caf6b4f
to
e4eef6b
Compare
Updated. There were 2 places where "Ask Brave for suggestions" could show up:
Updated test plan to check for both cases. |
DCHECK(submenu_model_.GetItemCount()); | ||
|
||
// Special accommodations for gtest. | ||
if (gtest_mode_ != GTEST_MODE_DISABLED) { |
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.
Just a thought for the future (I'm curious too) - you might check if unit/browser tests expose a #define
that you can check for with preprocessors? ex: you could wrap this section (and potentially the definition/setting of gtest_mode_
) with #ifdef
/#endif
guards. I'm not sure if there's a best practice? ex: a common way to check. But you could check like this:
#ifdef IN_PROC_BROWSER_TEST_
#endif
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 was looking for something like this as well but didn't see any additional definitions in the tests build in our build setup. gtest itself doesn't seem to add any (https://stackoverflow.com/questions/6077833/how-to-check-if-google-test-is-running-in-my-code). Ideally, I wouldn't want to have a different code path for tests in the first place, but in this case it would mean creating a more complex mock object (the current one was taken from Chromium and slightly modified).
int index = submenu_model_.GetItemCount() - 1; | ||
if (index >= 0 && | ||
submenu_model_.GetTypeAt(index) == ui::MenuModel::TYPE_SEPARATOR) | ||
submenu_model_.RemoveItemAt(index); |
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.
nitpick: when a comparison is multiple lines (or has weird spacing, enclosing the block within {
and }
can make it more readable (clearly capturing the start/end)
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.
Really well done! 😄👍 I ran through the manual test plans, automated tests, and then reviewed the code. Left a few comments (nitpicks 😛- no action needed; just food for thought). Great job 😄
Basically ready for merge - just going to verify tests work great on macOS, since this option isn't available there (build in progress...) |
Getting some compile errors (likely need platform preprocessor guards around this):
|
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.
Looks like we'll need to put some preprocessors around this functionality. I think we can subclass SpellingOptionsSubMenuObserver
wrapped in a #if !defined(OS_MACOSX)
The tests may need that same guard checked too
d77639f
to
69d1689
Compare
Updated with ifdefs for Mac. One curious thing: in the original render_view_context_menu.cc code the header inclusion is predicated on |
one in BraveRenderViewContextMenu that does not add Ask Brave menu item. Fixes brave/brave-browser#1623 Also, overrides SpellingMenuObserver to remove a possible dangling menu separator. Adds browser tests for spelling menu and spelling options submenu that check that the "Ask Brave for suggestions" menu item is not present.
69d1689
to
c82efbc
Compare
Built great on macOS and all unit/browser tests passed; waiting for Windows to finish... |
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.
Works great on Windows (ran through each test plan) and compiles/tests pass/etc on macOS 😄 👍
Remove "Ask Brave for suggestions" from context menu spellcheck section
Remove "Ask Brave for suggestions" from context menu spellcheck section
Hides RenderViewContextMenu::AddSpellCheckServiceItem method with one in BraveRenderViewContextMenu that does not add Ask Brave menu item.
Fixes brave/brave-browser#1623
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests
) ongit rebase master
(if needed).git rebase -i
to squash commits (if needed).Automated Test Plan:
On all platforms:
npm run test -- brave_browser_tests --filter=BraveSpellingMenuObserverTest.*
On Windows and Linux:
npm run test -- brave_browser_tests --filter=BraveSpellingOptionsSubMenuObserverTest.*
Test Plan:
Reviewer Checklist: