OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
9 #include "chrome/browser/geolocation/geolocation_settings_state.h" | 9 #include "chrome/browser/geolocation/geolocation_settings_state.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
11 #include "content/public/browser/navigation_details.h" | 11 #include "content/public/browser/navigation_details.h" |
12 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
13 #include "content/test/test_browser_thread.h" | 13 #include "content/test/test_browser_thread.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 using content::BrowserThread; | 16 using content::BrowserThread; |
| 17 using content::NavigationEntry; |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 class GeolocationSettingsStateTests : public testing::Test { | 21 class GeolocationSettingsStateTests : public testing::Test { |
21 public: | 22 public: |
22 GeolocationSettingsStateTests() | 23 GeolocationSettingsStateTests() |
23 : ui_thread_(BrowserThread::UI, &message_loop_) { | 24 : ui_thread_(BrowserThread::UI, &message_loop_) { |
24 } | 25 } |
25 | 26 |
26 protected: | 27 protected: |
27 MessageLoop message_loop_; | 28 MessageLoop message_loop_; |
28 content::TestBrowserThread ui_thread_; | 29 content::TestBrowserThread ui_thread_; |
29 }; | 30 }; |
30 | 31 |
31 TEST_F(GeolocationSettingsStateTests, ClearOnNewOrigin) { | 32 TEST_F(GeolocationSettingsStateTests, ClearOnNewOrigin) { |
32 TestingProfile profile; | 33 TestingProfile profile; |
33 GeolocationSettingsState state(&profile); | 34 GeolocationSettingsState state(&profile); |
34 GURL url_0("http://www.example.com"); | 35 GURL url_0("http://www.example.com"); |
35 | 36 |
36 scoped_ptr<content::NavigationEntry> entry( | 37 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
37 content::NavigationEntry::Create()); | |
38 entry->SetURL(url_0); | 38 entry->SetURL(url_0); |
39 content::LoadCommittedDetails load_committed_details; | 39 content::LoadCommittedDetails load_committed_details; |
40 load_committed_details.entry = entry.get(); | 40 load_committed_details.entry = entry.get(); |
41 state.DidNavigate(load_committed_details); | 41 state.DidNavigate(load_committed_details); |
42 | 42 |
43 profile.GetHostContentSettingsMap()->SetContentSetting( | 43 profile.GetHostContentSettingsMap()->SetContentSetting( |
44 ContentSettingsPattern::FromURLNoWildcard(url_0), | 44 ContentSettingsPattern::FromURLNoWildcard(url_0), |
45 ContentSettingsPattern::FromURLNoWildcard(url_0), | 45 ContentSettingsPattern::FromURLNoWildcard(url_0), |
46 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 46 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
47 std::string(), | 47 std::string(), |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); | 132 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); |
133 EXPECT_TRUE(formatted_host_per_state.empty()); | 133 EXPECT_TRUE(formatted_host_per_state.empty()); |
134 EXPECT_EQ(0U, tab_state_flags); | 134 EXPECT_EQ(0U, tab_state_flags); |
135 } | 135 } |
136 | 136 |
137 TEST_F(GeolocationSettingsStateTests, ShowPortOnSameHost) { | 137 TEST_F(GeolocationSettingsStateTests, ShowPortOnSameHost) { |
138 TestingProfile profile; | 138 TestingProfile profile; |
139 GeolocationSettingsState state(&profile); | 139 GeolocationSettingsState state(&profile); |
140 GURL url_0("http://www.example.com"); | 140 GURL url_0("http://www.example.com"); |
141 | 141 |
142 scoped_ptr<content::NavigationEntry> entry( | 142 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
143 content::NavigationEntry::Create()); | |
144 entry->SetURL(url_0); | 143 entry->SetURL(url_0); |
145 content::LoadCommittedDetails load_committed_details; | 144 content::LoadCommittedDetails load_committed_details; |
146 load_committed_details.entry = entry.get(); | 145 load_committed_details.entry = entry.get(); |
147 state.DidNavigate(load_committed_details); | 146 state.DidNavigate(load_committed_details); |
148 | 147 |
149 profile.GetHostContentSettingsMap()->SetContentSetting( | 148 profile.GetHostContentSettingsMap()->SetContentSetting( |
150 ContentSettingsPattern::FromURLNoWildcard(url_0), | 149 ContentSettingsPattern::FromURLNoWildcard(url_0), |
151 ContentSettingsPattern::FromURLNoWildcard(url_0), | 150 ContentSettingsPattern::FromURLNoWildcard(url_0), |
152 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 151 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
153 std::string(), | 152 std::string(), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 formatted_host_per_state[CONTENT_SETTING_ALLOW].count( | 203 formatted_host_per_state[CONTENT_SETTING_ALLOW].count( |
205 url_2.host())); | 204 url_2.host())); |
206 EXPECT_EQ(1U, formatted_host_per_state[CONTENT_SETTING_BLOCK].size()); | 205 EXPECT_EQ(1U, formatted_host_per_state[CONTENT_SETTING_BLOCK].size()); |
207 EXPECT_EQ(1U, | 206 EXPECT_EQ(1U, |
208 formatted_host_per_state[CONTENT_SETTING_BLOCK].count( | 207 formatted_host_per_state[CONTENT_SETTING_BLOCK].count( |
209 url_1.spec())); | 208 url_1.spec())); |
210 } | 209 } |
211 | 210 |
212 | 211 |
213 } // namespace | 212 } // namespace |
OLD | NEW |