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

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

Issue 2298283002: Site Settings Desktop: Support adding exceptions for incognito mode. (Closed)
Patch Set: Fix test Created 4 years, 3 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
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 24ce23af69da853fccf69a478b3addb24dca7c55..c0911b91fcf9a1912b4a2a4a79214f8136c909e7 100644
--- a/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
+++ b/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
@@ -130,9 +130,38 @@ class SiteSettingsHandlerTest : public testing::Test {
EXPECT_EQ(expected_validity, valid);
}
+ void ValidateIncognitoExists(
+ bool expected_incognito, 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.webUIListenerCallback", data.function_name());
+
+ std::string callback_id;
+ ASSERT_TRUE(data.arg1()->GetAsString(&callback_id));
+ EXPECT_EQ("onIncognitoStatusChanged", callback_id);
+
+ bool incognito;
+ ASSERT_TRUE(data.arg2()->GetAsBoolean(&incognito));
+ EXPECT_EQ(expected_incognito, incognito);
+
+ EXPECT_EQ(incognito, handler_.IsOurIncognitoProfile(incognito_profile_));
+ }
+
+ void CreateIncognitoProfile() {
+ incognito_profile_ = TestingProfile::Builder().BuildIncognito(&profile_);
+ }
+
+ void DestroyIncognitoProfile() {
+ profile_.DestroyOffTheRecordProfile();
+ ASSERT_FALSE(profile_.HasOffTheRecordProfile());
+ incognito_profile_ = nullptr;
+ }
+
private:
content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
+ TestingProfile* incognito_profile_;
content::TestWebUI web_ui_;
SiteSettingsHandler handler_;
};
@@ -167,6 +196,7 @@ TEST_F(SiteSettingsHandlerTest, Origins) {
setArgs.AppendString(google); // Secondary pattern.
setArgs.AppendString("notifications");
setArgs.AppendString("block");
+ setArgs.AppendBoolean(false); // Incognito.
handler()->HandleSetCategoryPermissionForOrigin(&setArgs);
EXPECT_EQ(1U, web_ui()->call_data().size());
@@ -182,6 +212,7 @@ TEST_F(SiteSettingsHandlerTest, Origins) {
resetArgs.AppendString(google);
resetArgs.AppendString(google);
resetArgs.AppendString("notifications");
+ resetArgs.AppendBoolean(false); // Incognito.
handler()->HandleResetCategoryPermissionForOrigin(&resetArgs);
EXPECT_EQ(3U, web_ui()->call_data().size());
@@ -206,4 +237,16 @@ TEST_F(SiteSettingsHandlerTest, Patterns) {
ValidatePattern(false, 2U);
}
+TEST_F(SiteSettingsHandlerTest, Incognito) {
+ base::ListValue args;
+ handler()->HandleUpdateIncognitoStatus(&args);
+ ValidateIncognitoExists(false, 1U);
+
+ CreateIncognitoProfile();
+ ValidateIncognitoExists(true, 2U);
+
+ DestroyIncognitoProfile();
+ ValidateIncognitoExists(false, 3U);
+}
+
} // namespace settings

Powered by Google App Engine
This is Rietveld 408576698