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

Unified Diff: chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc

Issue 2946393002: MD Settings: Amend SiteSettingsHandlerTest.Origins to test "Site Details" code. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
diff --git a/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc b/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
index 53be2fd2283a1fc2f71d51d8d4a308f371392e3d..8613ecc6579e774536cd7a5675d56ee04ecb5ef0 100644
--- a/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
+++ b/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
@@ -99,11 +99,15 @@ class SiteSettingsHandlerTest : public testing::Test {
ASSERT_TRUE(data.arg2()->GetAsBoolean(&success));
ASSERT_TRUE(success);
- const base::ListValue* exceptions;
- ASSERT_TRUE(data.arg3()->GetAsList(&exceptions));
- EXPECT_EQ(1U, exceptions->GetSize());
const base::DictionaryValue* exception;
- ASSERT_TRUE(exceptions->GetDictionary(0, &exception));
+ if (data.arg3()->is_list()) {
+ const base::ListValue* exceptions;
+ ASSERT_TRUE(data.arg3()->GetAsList(&exceptions));
+ EXPECT_EQ(1U, exceptions->GetSize());
+ ASSERT_TRUE(exceptions->GetDictionary(0, &exception));
+ } else {
+ data.arg3()->GetAsDictionary(&exception);
raymes 2017/06/26 04:12:27 Could you add a comment describing these 2 cases?
Patti Lor 2017/06/26 08:10:54 Done.
+ }
std::string origin, embedding_origin, display_name, setting, source;
ASSERT_TRUE(exception->GetString(site_settings::kOrigin, &origin));
ASSERT_EQ(expected_origin, origin);
@@ -272,13 +276,23 @@ TEST_F(SiteSettingsHandlerTest, Origins) {
histograms.ExpectTotalCount(kUmaBase + ".Reset", 0);
}
- // Verify the change was successful.
- base::ListValue listArgs;
- listArgs.AppendString(kCallbackId);
- listArgs.AppendString("notifications");
- handler()->HandleGetExceptionList(&listArgs);
+ // If the change was successful, it should show up as an exception as well as
+ // in the response for a specific request to getCategoryPermissionForOrigin.
+ // Check getCategoryPermissionForOrigin.
+ base::ListValue getCategoryPermissionArgs;
+ getCategoryPermissionArgs.AppendString(kCallbackId);
+ getCategoryPermissionArgs.AppendString("notifications");
+ getCategoryPermissionArgs.AppendString(google);
+ handler()->HandleGetCategoryPermissionForOrigin(&getCategoryPermissionArgs);
ValidateOrigin(google, google, google, "block", "preference", 2U);
+ // Check getExceptionList.
+ base::ListValue getExceptionListArgs;
+ getExceptionListArgs.AppendString(kCallbackId);
+ getExceptionListArgs.AppendString("notifications");
+ handler()->HandleGetExceptionList(&getExceptionListArgs);
+ ValidateOrigin(google, google, google, "block", "preference", 3U);
+
{
// Reset things back to how they were.
base::ListValue reset_args;
@@ -288,7 +302,7 @@ TEST_F(SiteSettingsHandlerTest, Origins) {
reset_args.AppendBoolean(false); // Incognito.
base::HistogramTester histograms;
handler()->HandleResetCategoryPermissionForOrigin(&reset_args);
- EXPECT_EQ(3U, web_ui()->call_data().size());
+ EXPECT_EQ(4U, web_ui()->call_data().size());
histograms.ExpectTotalCount(kUmaBase, 1);
histograms.ExpectTotalCount(kUmaBase + ".Allowed", 0);
histograms.ExpectTotalCount(kUmaBase + ".Blocked", 0);
@@ -296,8 +310,12 @@ TEST_F(SiteSettingsHandlerTest, Origins) {
}
// Verify the reset was successful.
- handler()->HandleGetExceptionList(&listArgs);
- ValidateNoOrigin(4U);
+ handler()->HandleGetExceptionList(&getExceptionListArgs);
+ ValidateNoOrigin(5U);
+
+ handler()->HandleGetCategoryPermissionForOrigin(&getCategoryPermissionArgs);
+ // Ask is the currently the built-in Chrome default for notifications.
+ ValidateOrigin(google, google, google, "ask", "preference", 6U);
}
TEST_F(SiteSettingsHandlerTest, ExceptionHelpers) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698