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

Unified Diff: chrome/browser/content_settings/content_settings_usages_state_unittest.cc

Issue 19375002: Move GeolocationSettingsState to ContentSettingsUsagesState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review #6 Created 7 years, 5 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/content_settings/content_settings_usages_state_unittest.cc
diff --git a/chrome/browser/geolocation/geolocation_settings_state_unittest.cc b/chrome/browser/content_settings/content_settings_usages_state_unittest.cc
similarity index 72%
copy from chrome/browser/geolocation/geolocation_settings_state_unittest.cc
copy to chrome/browser/content_settings/content_settings_usages_state_unittest.cc
index bc489a803622b09b57ef7155d72ce363d4ff3636..9dd9eb13f50099518b08c6713df0b32fd45f0bfc 100644
--- a/chrome/browser/geolocation/geolocation_settings_state_unittest.cc
+++ b/chrome/browser/content_settings/content_settings_usages_state_unittest.cc
@@ -1,12 +1,13 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/content_settings/content_settings_usages_state.h"
+
#include <string>
#include "base/message_loop/message_loop.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
-#include "chrome/browser/geolocation/geolocation_settings_state.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
@@ -18,9 +19,15 @@ using content::NavigationEntry;
namespace {
-class GeolocationSettingsStateTests : public testing::Test {
+// ContentSettingsUsagesState class should work for any ContentSettingsType.
+// Here, following tests use |kTypeForTesting| as representation.
+// TODO(toyoshim): Add at least one test to verify the class works with other
markusheintz_ 2013/07/22 19:41:51 Can we file a bug for this please and add the issu
Takashi Toyoshima 2013/07/23 05:17:47 Done.
+// types.
+ContentSettingsType kTypeForTesting = CONTENT_SETTINGS_TYPE_GEOLOCATION;
+
+class ContentSettingsUsagesStateTests : public testing::Test {
public:
- GeolocationSettingsStateTests()
+ ContentSettingsUsagesStateTests()
: ui_thread_(BrowserThread::UI, &message_loop_) {
}
@@ -29,9 +36,9 @@ class GeolocationSettingsStateTests : public testing::Test {
content::TestBrowserThread ui_thread_;
};
-TEST_F(GeolocationSettingsStateTests, ClearOnNewOrigin) {
+TEST_F(ContentSettingsUsagesStateTests, ClearOnNewOrigin) {
TestingProfile profile;
- GeolocationSettingsState state(&profile);
+ ContentSettingsUsagesState state(&profile, kTypeForTesting);
GURL url_0("http://www.example.com");
scoped_ptr<NavigationEntry> entry(NavigationEntry::Create());
@@ -43,38 +50,38 @@ TEST_F(GeolocationSettingsStateTests, ClearOnNewOrigin) {
profile.GetHostContentSettingsMap()->SetContentSetting(
ContentSettingsPattern::FromURLNoWildcard(url_0),
ContentSettingsPattern::FromURLNoWildcard(url_0),
- CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ kTypeForTesting,
std::string(),
CONTENT_SETTING_ALLOW);
- state.OnGeolocationPermissionSet(url_0, true);
+ state.OnPermissionSet(url_0, true);
GURL url_1("http://www.example1.com");
profile.GetHostContentSettingsMap()->SetContentSetting(
- ContentSettingsPattern::FromURLNoWildcard(url_1),
- ContentSettingsPattern::FromURLNoWildcard(url_0),
- CONTENT_SETTINGS_TYPE_GEOLOCATION,
- std::string(),
- CONTENT_SETTING_BLOCK);
- state.OnGeolocationPermissionSet(url_1, false);
-
- GeolocationSettingsState::StateMap state_map =
+ ContentSettingsPattern::FromURLNoWildcard(url_1),
+ ContentSettingsPattern::FromURLNoWildcard(url_0),
+ kTypeForTesting,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
+ state.OnPermissionSet(url_1, false);
+
+ ContentSettingsUsagesState::StateMap state_map =
state.state_map();
EXPECT_EQ(2U, state_map.size());
- GeolocationSettingsState::FormattedHostsPerState formatted_host_per_state;
+ ContentSettingsUsagesState::FormattedHostsPerState formatted_host_per_state;
unsigned int tab_state_flags = 0;
state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags);
EXPECT_TRUE(tab_state_flags &
- GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED)
+ ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED)
<< tab_state_flags;
EXPECT_TRUE(tab_state_flags &
- GeolocationSettingsState::TABSTATE_HAS_EXCEPTION)
+ ContentSettingsUsagesState::TABSTATE_HAS_EXCEPTION)
<< tab_state_flags;
EXPECT_FALSE(tab_state_flags &
- GeolocationSettingsState::TABSTATE_HAS_CHANGED)
+ ContentSettingsUsagesState::TABSTATE_HAS_CHANGED)
<< tab_state_flags;
EXPECT_TRUE(tab_state_flags &
- GeolocationSettingsState::TABSTATE_HAS_ANY_ICON)
+ ContentSettingsUsagesState::TABSTATE_HAS_ANY_ICON)
<< tab_state_flags;
EXPECT_EQ(1U, formatted_host_per_state[CONTENT_SETTING_ALLOW].size());
EXPECT_EQ(1U,
@@ -86,22 +93,22 @@ TEST_F(GeolocationSettingsStateTests, ClearOnNewOrigin) {
formatted_host_per_state[CONTENT_SETTING_BLOCK].count(
url_1.host()));
- state.OnGeolocationPermissionSet(url_0, false);
+ state.OnPermissionSet(url_0, false);
formatted_host_per_state.clear();
tab_state_flags = 0;
state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags);
EXPECT_FALSE(tab_state_flags &
- GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED)
+ ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED)
<< tab_state_flags;
EXPECT_TRUE(tab_state_flags &
- GeolocationSettingsState::TABSTATE_HAS_EXCEPTION)
+ ContentSettingsUsagesState::TABSTATE_HAS_EXCEPTION)
<< tab_state_flags;
EXPECT_TRUE(tab_state_flags &
- GeolocationSettingsState::TABSTATE_HAS_CHANGED)
+ ContentSettingsUsagesState::TABSTATE_HAS_CHANGED)
<< tab_state_flags;
EXPECT_TRUE(tab_state_flags &
- GeolocationSettingsState::TABSTATE_HAS_ANY_ICON)
+ ContentSettingsUsagesState::TABSTATE_HAS_ANY_ICON)
<< tab_state_flags;
EXPECT_EQ(0U, formatted_host_per_state[CONTENT_SETTING_ALLOW].size());
EXPECT_EQ(2U, formatted_host_per_state[CONTENT_SETTING_BLOCK].size());
@@ -112,12 +119,12 @@ TEST_F(GeolocationSettingsStateTests, ClearOnNewOrigin) {
formatted_host_per_state[CONTENT_SETTING_BLOCK].count(
url_1.host()));
- state.OnGeolocationPermissionSet(url_0, true);
+ state.OnPermissionSet(url_0, true);
load_committed_details.previous_url = url_0;
state.DidNavigate(load_committed_details);
- GeolocationSettingsState::StateMap new_state_map =
+ ContentSettingsUsagesState::StateMap new_state_map =
state.state_map();
EXPECT_EQ(state_map.size(), new_state_map.size());
@@ -134,9 +141,9 @@ TEST_F(GeolocationSettingsStateTests, ClearOnNewOrigin) {
EXPECT_EQ(0U, tab_state_flags);
}
-TEST_F(GeolocationSettingsStateTests, ShowPortOnSameHost) {
+TEST_F(ContentSettingsUsagesStateTests, ShowPortOnSameHost) {
TestingProfile profile;
- GeolocationSettingsState state(&profile);
+ ContentSettingsUsagesState state(&profile, kTypeForTesting);
GURL url_0("http://www.example.com");
scoped_ptr<NavigationEntry> entry(NavigationEntry::Create());
@@ -148,34 +155,34 @@ TEST_F(GeolocationSettingsStateTests, ShowPortOnSameHost) {
profile.GetHostContentSettingsMap()->SetContentSetting(
ContentSettingsPattern::FromURLNoWildcard(url_0),
ContentSettingsPattern::FromURLNoWildcard(url_0),
- CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ kTypeForTesting,
std::string(),
CONTENT_SETTING_ALLOW);
- state.OnGeolocationPermissionSet(url_0, true);
+ state.OnPermissionSet(url_0, true);
GURL url_1("https://www.example.com");
profile.GetHostContentSettingsMap()->SetContentSetting(
ContentSettingsPattern::FromURLNoWildcard(url_1),
ContentSettingsPattern::FromURLNoWildcard(url_0),
- CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ kTypeForTesting,
std::string(),
CONTENT_SETTING_ALLOW);
- state.OnGeolocationPermissionSet(url_1, true);
+ state.OnPermissionSet(url_1, true);
GURL url_2("http://www.example1.com");
profile.GetHostContentSettingsMap()->SetContentSetting(
ContentSettingsPattern::FromURLNoWildcard(url_2),
ContentSettingsPattern::FromURLNoWildcard(url_0),
- CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ kTypeForTesting,
std::string(),
CONTENT_SETTING_ALLOW);
- state.OnGeolocationPermissionSet(url_2, true);
+ state.OnPermissionSet(url_2, true);
- GeolocationSettingsState::StateMap state_map =
+ ContentSettingsUsagesState::StateMap state_map =
state.state_map();
EXPECT_EQ(3U, state_map.size());
- GeolocationSettingsState::FormattedHostsPerState formatted_host_per_state;
+ ContentSettingsUsagesState::FormattedHostsPerState formatted_host_per_state;
unsigned int tab_state_flags = 0;
state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags);
@@ -190,7 +197,7 @@ TEST_F(GeolocationSettingsStateTests, ShowPortOnSameHost) {
formatted_host_per_state[CONTENT_SETTING_ALLOW].count(
url_2.host()));
- state.OnGeolocationPermissionSet(url_1, false);
+ state.OnPermissionSet(url_1, false);
formatted_host_per_state.clear();
tab_state_flags = 0;
state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags);

Powered by Google App Engine
This is Rietveld 408576698