Chromium Code Reviews| Index: chrome/browser/content_settings/permission_context_base_unittest.cc |
| diff --git a/chrome/browser/content_settings/permission_context_base_unittest.cc b/chrome/browser/content_settings/permission_context_base_unittest.cc |
| index ab3a31d46fa7c5705908ad1ebe00fe021919bc09..aea214d165e063b55fe2476eac357e9a254a2805 100644 |
| --- a/chrome/browser/content_settings/permission_context_base_unittest.cc |
| +++ b/chrome/browser/content_settings/permission_context_base_unittest.cc |
| @@ -178,6 +178,42 @@ class PermissionContextBaseTests : public ChromeRenderViewHostTestHarness { |
| EXPECT_EQ(CONTENT_SETTING_ASK, setting); |
| } |
| + void TestGrantAndRevoke_TestContent(ContentSettingsType type, |
| + ContentSetting expected_default) { |
| + TestPermissionContext permission_context(profile(), type); |
| + GURL url("http://www.google.com"); |
| + content::WebContentsTester::For(web_contents())->NavigateAndCommit(url); |
| + |
| + const PermissionRequestID id( |
| + web_contents()->GetRenderProcessHost()->GetID(), |
| + web_contents()->GetRenderViewHost()->GetRoutingID(), |
| + -1, GURL()); |
| + permission_context.RequestPermission( |
| + web_contents(), |
| + id, url, true, |
| + base::Bind(&TestPermissionContext::TrackPermissionDecision, |
| + base::Unretained(&permission_context))); |
| + |
| + RespondToPermission(&permission_context, id, url, true); |
| + EXPECT_TRUE(permission_context.permission_set()); |
| + EXPECT_TRUE(permission_context.permission_granted()); |
| + EXPECT_TRUE(permission_context.tab_context_updated()); |
| + |
| + ContentSetting setting = |
| + profile()->GetHostContentSettingsMap()->GetContentSetting( |
| + url.GetOrigin(), url.GetOrigin(), |
| + type, std::string()); |
| + EXPECT_EQ(CONTENT_SETTING_ALLOW , setting); |
| + |
| + // Try to reset permission. |
| + permission_context.ResetPermission(url.GetOrigin(), url.GetOrigin()); |
| + ContentSetting setting_after_reset = |
| + profile()->GetHostContentSettingsMap()->GetContentSetting( |
| + url.GetOrigin(), url.GetOrigin(), |
| + type, std::string()); |
| + EXPECT_EQ(expected_default, setting_after_reset); |
| + } |
| + |
| private: |
| // ChromeRenderViewHostTestHarness: |
| void SetUp() override { |
| @@ -217,3 +253,28 @@ TEST_F(PermissionContextBaseTests, TestNonValidRequestingUrl) { |
| CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); |
| #endif |
| } |
| + |
| +// Simulates granting and revoking of permissions. |
| +TEST_F(PermissionContextBaseTests, TestGrantAndRevoke) { |
| + TestGrantAndRevoke_TestContent(CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| + CONTENT_SETTING_ASK); |
| + TestGrantAndRevoke_TestContent(CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
| + CONTENT_SETTING_ASK); |
| +} |
| + |
| +// Simulates granting and revoking of permissions using permission bubbles. |
| +TEST_F(PermissionContextBaseTests, TestGrantAndRevokeWithBubbles) { |
| + StartUsingPermissionBubble(); |
| + TestGrantAndRevoke_TestContent(CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| + CONTENT_SETTING_ASK); |
| + TestGrantAndRevoke_TestContent(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| + CONTENT_SETTING_ASK); |
| + TestGrantAndRevoke_TestContent(CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
| + CONTENT_SETTING_ASK); |
| + TestGrantAndRevoke_TestContent(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, |
| + CONTENT_SETTING_ASK); |
|
mlamouri (slow - plz ping)
2015/01/26 10:38:17
Is there a reason why we run more tests with bubbl
timvolodine
2015/01/30 14:07:47
I've added protected media permission, but there a
|
| +#if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| + TestGrantAndRevoke_TestContent( |
| + CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, CONTENT_SETTING_ASK); |
| +#endif |
| +} |