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

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

Issue 1909413002: Site Settings: Implement dialog for adding site exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 8 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 | « chrome/browser/ui/webui/settings/site_settings_handler.cc ('k') | 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 fd388022fd7548e4e337a23ebcc9d01b81ffe0c1..4640cacfa3d85e4a2a733ee5e8e14b66572860e2 100644
--- a/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
+++ b/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
@@ -103,6 +103,25 @@ class SiteSettingsHandlerTest : public testing::Test {
EXPECT_EQ(0U, exceptions->GetSize());
}
+ void ValidatePattern(bool expected_validity, size_t expected_total_calls) {
+ EXPECT_EQ(expected_total_calls, web_ui()->call_data().size());
+
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIResponse", data.function_name());
+
+ std::string callback_id;
+ ASSERT_TRUE(data.arg1()->GetAsString(&callback_id));
+ EXPECT_EQ(kCallbackId, callback_id);
+
+ bool success = false;
+ ASSERT_TRUE(data.arg2()->GetAsBoolean(&success));
+ ASSERT_TRUE(success);
+
+ bool valid;
+ ASSERT_TRUE(data.arg3()->GetAsBoolean(&valid));
+ EXPECT_EQ(expected_validity, valid);
+ }
+
private:
content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
@@ -172,4 +191,23 @@ TEST_F(SiteSettingsHandlerTest, Origins) {
ValidateNoOrigin(4U);
}
+TEST_F(SiteSettingsHandlerTest, Patterns) {
+ SiteSettingsHandler handler(profile());
+ handler.set_web_ui(web_ui());
+
+ base::ListValue args;
+ std::string pattern("[*.]google.com");
+ args.Append(new base::StringValue(kCallbackId));
+ args.Append(new base::StringValue(pattern));
+ handler.HandleIsPatternValid(&args);
+ ValidatePattern(true, 1U);
+
+ base::ListValue invalid;
+ std::string bad_pattern(";");
+ invalid.Append(new base::StringValue(kCallbackId));
+ invalid.Append(new base::StringValue(bad_pattern));
+ handler.HandleIsPatternValid(&invalid);
+ ValidatePattern(false, 2U);
+}
+
} // namespace settings
« no previous file with comments | « chrome/browser/ui/webui/settings/site_settings_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698