Chromium Code Reviews| 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 78% |
| rename from chrome/browser/geolocation/geolocation_settings_state_unittest.cc |
| rename to chrome/browser/content_settings/content_settings_usages_state_unittest.cc |
| index b6b5f8f41bba6a9206066ba3a4c9e898e8cb3347..ade20d42eac5420cafbac3ba0a5dd4fee615fdc6 100644 |
| --- a/chrome/browser/geolocation/geolocation_settings_state_unittest.cc |
| +++ b/chrome/browser/content_settings/content_settings_usages_state_unittest.cc |
| @@ -1,12 +1,12 @@ |
| -// 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 <string> |
| #include "base/message_loop.h" |
| +#include "chrome/browser/content_settings/content_settings_usages_state.h" |
|
bulach
2013/07/18 08:56:50
nit: this should actually be up there, before <str
Takashi Toyoshima
2013/07/22 12:59:18
Done.
|
| #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 +18,9 @@ using content::NavigationEntry; |
| namespace { |
| -class GeolocationSettingsStateTests : public testing::Test { |
| +class ContentSettingsUsagesStateTests : public testing::Test { |
| public: |
| - GeolocationSettingsStateTests() |
| + ContentSettingsUsagesStateTests() |
| : ui_thread_(BrowserThread::UI, &message_loop_) { |
| } |
| @@ -29,9 +29,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, CONTENT_SETTINGS_TYPE_GEOLOCATION); |
|
bulach
2013/07/18 08:56:50
nit: CONTENT_SETTINGS_TYPE_GEOLOCATION is hard-cod
Takashi Toyoshima
2013/07/22 12:59:18
Using a named constant is done.
On testing with o
|
| GURL url_0("http://www.example.com"); |
| scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
| @@ -46,7 +46,7 @@ TEST_F(GeolocationSettingsStateTests, ClearOnNewOrigin) { |
| CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 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( |
| @@ -55,26 +55,26 @@ TEST_F(GeolocationSettingsStateTests, ClearOnNewOrigin) { |
| CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| std::string(), |
| CONTENT_SETTING_BLOCK); |
| - state.OnGeolocationPermissionSet(url_1, false); |
| + state.OnPermissionSet(url_1, false); |
| - GeolocationSettingsState::StateMap state_map = |
| + 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 +86,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 +112,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 +134,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, CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| GURL url_0("http://www.example.com"); |
| scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
| @@ -151,7 +151,7 @@ TEST_F(GeolocationSettingsStateTests, ShowPortOnSameHost) { |
| CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 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( |
| @@ -160,7 +160,7 @@ TEST_F(GeolocationSettingsStateTests, ShowPortOnSameHost) { |
| CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 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( |
| @@ -169,13 +169,13 @@ TEST_F(GeolocationSettingsStateTests, ShowPortOnSameHost) { |
| CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 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 +190,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); |