Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Issue 1845253002: Add unit test for Site Settings Handler. (Closed)

Created:
4 years, 8 months ago by Finnur
Modified:
4 years, 8 months ago
Reviewers:
michaelpg
CC:
chromium-reviews, michaelpg+watch-md-settings_chromium.org, dbeam+watch-settings_chromium.org, stevenjb+watch-md-settings_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Add unit test for Site Settings Handler. BUG=543635 Committed: https://crrev.com/f5ca600dbd28d6c3c8e528e35b0fb84efdcd309e Cr-Commit-Position: refs/heads/master@{#385296}

Patch Set 1 #

Total comments: 16

Patch Set 2 : Address feedback #

Total comments: 1

Patch Set 3 : Address feedback #

Unified diffs Side-by-side diffs Delta from patch set Stats (+178 lines, -0 lines) Patch
M chrome/browser/ui/webui/settings/site_settings_handler.h View 1 chunk +3 lines, -0 lines 0 comments Download
A chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc View 1 2 1 chunk +174 lines, -0 lines 0 comments Download
M chrome/chrome_tests_unit.gypi View 1 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 15 (5 generated)
Finnur
Michael, mind taking this?
4 years, 8 months ago (2016-03-31 13:41:54 UTC) #2
michaelpg
https://codereview.chromium.org/1845253002/diff/1/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc File chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc (right): https://codereview.chromium.org/1845253002/diff/1/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc#newcode38 chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc:38: EXPECT_EQ("test-callback-id", callback_id); opt. nit: make the callback id a ...
4 years, 8 months ago (2016-04-01 09:08:29 UTC) #3
Finnur
https://codereview.chromium.org/1845253002/diff/1/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc File chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc (right): https://codereview.chromium.org/1845253002/diff/1/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc#newcode38 chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc:38: EXPECT_EQ("test-callback-id", callback_id); On 2016/04/01 09:08:28, michaelpg wrote: > opt. ...
4 years, 8 months ago (2016-04-05 10:22:31 UTC) #5
michaelpg
lgtm https://codereview.chromium.org/1845253002/diff/1/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc File chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc (right): https://codereview.chromium.org/1845253002/diff/1/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc#newcode118 chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc:118: EXPECT_EQ(2U, web_ui()->call_data().size()); On 2016/04/05 10:22:31, Finnur wrote: > ...
4 years, 8 months ago (2016-04-05 19:33:36 UTC) #6
Finnur
Updated and checking in. I'll respond to the callback question in a bit.
4 years, 8 months ago (2016-04-05 21:08:45 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1845253002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1845253002/60001
4 years, 8 months ago (2016-04-05 21:09:29 UTC) #10
Finnur
Attempting to clarify: https://codereview.chromium.org/1845253002/diff/1/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc File chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc (right): https://codereview.chromium.org/1845253002/diff/1/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc#newcode110 chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc:110: ValidateDefault(true, 1U); This validates that we've ...
4 years, 8 months ago (2016-04-05 21:24:38 UTC) #11
commit-bot: I haz the power
Committed patchset #3 (id:60001)
4 years, 8 months ago (2016-04-05 22:06:50 UTC) #12
commit-bot: I haz the power
Patchset 3 (id:??) landed as https://crrev.com/f5ca600dbd28d6c3c8e528e35b0fb84efdcd309e Cr-Commit-Position: refs/heads/master@{#385296}
4 years, 8 months ago (2016-04-05 22:08:59 UTC) #14
michaelpg
4 years, 8 months ago (2016-04-05 23:16:05 UTC) #15
Message was sent while issue was closed.
https://codereview.chromium.org/1845253002/diff/1/chrome/browser/ui/webui/set...
File chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc (right):

https://codereview.chromium.org/1845253002/diff/1/chrome/browser/ui/webui/set...
chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc:118:
EXPECT_EQ(2U, web_ui()->call_data().size());
On 2016/04/05 21:24:37, Finnur wrote:
> This validates that we've had 2 calls from JS into web_ui (first a call to get
a
> default value and now another, to set the default value). If SetDefault were
to
> result in a callback call back into to js (which it doesn't) then I would have
> created a helper that runs line 118 and then also validates the result of the
> callback. But since there is no callback, it suffices to check the number of
> calls into web_ui.
> 
> To clarify: The term callback, that I use, is referring only to web_ui
> communicating back to js with what the result of the web_ui call was.
> 
> Another way to think about it: If GetDefault on line 109 did not return a
> callback then I'd replace the ValidateDefault function on line 110 with:
> 
> EXPECT_EQ(1U, web_ui()->call_data().size());
> 
> 
> Does this answer your question? Happy to do a follow-up if you think something
> needs clarification/improvement.

So, you're verifying that Get calls WebUI (via the cr.webUIResponse callback)
and that the callback itself is invoked correctly (the arguments to
ResolveJavascriptCallback which get used in cr.webUIResponse).

You're also verifying that Set results in a WebUI call (from the content
observer), but you aren't verifying the arguments of that call (the
webUIListenerCallback for contentSettingCategoryChanged).

Is my understanding correct? If so, I wasn't misunderstanding what was
happening, just don't know why you didn't test the listener callback when you
did test the response callback. No need to update the test though, it's fine.

Powered by Google App Engine
This is Rietveld 408576698