OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/string16.h" | 5 #include "base/string16.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
10 #include "content/public/test/test_browser_thread.h" | 10 #include "content/public/test/test_browser_thread.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 MOCK_METHOD0(OnSiteDataAccessed, void()); | 31 MOCK_METHOD0(OnSiteDataAccessed, void()); |
32 | 32 |
33 private: | 33 private: |
34 DISALLOW_COPY_AND_ASSIGN(MockSiteDataObserver); | 34 DISALLOW_COPY_AND_ASSIGN(MockSiteDataObserver); |
35 }; | 35 }; |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 class TabSpecificContentSettingsTest : public ChromeRenderViewHostTestHarness { | 39 class TabSpecificContentSettingsTest : public ChromeRenderViewHostTestHarness { |
40 public: | 40 public: |
41 TabSpecificContentSettingsTest() | |
42 : browser_thread_(BrowserThread::UI, &message_loop_) {} | |
43 | |
44 virtual void SetUp() OVERRIDE { | 41 virtual void SetUp() OVERRIDE { |
45 ChromeRenderViewHostTestHarness::SetUp(); | 42 ChromeRenderViewHostTestHarness::SetUp(); |
46 TabSpecificContentSettings::CreateForWebContents(web_contents()); | 43 TabSpecificContentSettings::CreateForWebContents(web_contents()); |
47 } | 44 } |
48 | |
49 private: | |
50 content::TestBrowserThread browser_thread_; | |
51 | |
52 DISALLOW_COPY_AND_ASSIGN(TabSpecificContentSettingsTest); | |
53 }; | 45 }; |
54 | 46 |
55 TEST_F(TabSpecificContentSettingsTest, BlockedContent) { | 47 TEST_F(TabSpecificContentSettingsTest, BlockedContent) { |
56 TabSpecificContentSettings* content_settings = | 48 TabSpecificContentSettings* content_settings = |
57 TabSpecificContentSettings::FromWebContents(web_contents()); | 49 TabSpecificContentSettings::FromWebContents(web_contents()); |
58 net::CookieOptions options; | 50 net::CookieOptions options; |
59 | 51 |
60 // Check that after initializing, nothing is blocked. | 52 // Check that after initializing, nothing is blocked. |
61 EXPECT_FALSE( | 53 EXPECT_FALSE( |
62 content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES)); | 54 content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES)); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 TabSpecificContentSettings* content_settings = | 271 TabSpecificContentSettings* content_settings = |
280 TabSpecificContentSettings::FromWebContents(web_contents()); | 272 TabSpecificContentSettings::FromWebContents(web_contents()); |
281 ContentSettingsType type = CONTENT_SETTINGS_TYPE_MEDIASTREAM; | 273 ContentSettingsType type = CONTENT_SETTINGS_TYPE_MEDIASTREAM; |
282 content_settings->OnContentAllowed(type); | 274 content_settings->OnContentAllowed(type); |
283 EXPECT_TRUE(content_settings->IsContentAllowed(type)); | 275 EXPECT_TRUE(content_settings->IsContentAllowed(type)); |
284 EXPECT_FALSE(content_settings->IsContentBlocked(type)); | 276 EXPECT_FALSE(content_settings->IsContentBlocked(type)); |
285 content_settings->OnContentBlocked(type, std::string()); | 277 content_settings->OnContentBlocked(type, std::string()); |
286 EXPECT_TRUE(content_settings->IsContentBlocked(type)); | 278 EXPECT_TRUE(content_settings->IsContentBlocked(type)); |
287 EXPECT_FALSE(content_settings->IsContentAllowed(type)); | 279 EXPECT_FALSE(content_settings->IsContentAllowed(type)); |
288 } | 280 } |
OLD | NEW |