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

Side by Side Diff: chrome/browser/content_settings/host_content_settings_map_unittest.cc

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h"
15 #include "chrome/browser/content_settings/content_settings_mock_observer.h" 14 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
16 #include "chrome/browser/content_settings/cookie_settings_factory.h" 15 #include "chrome/browser/content_settings/cookie_settings_factory.h"
17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
18 #include "chrome/browser/content_settings/mock_settings_observer.h" 17 #include "chrome/browser/content_settings/mock_settings_observer.h"
19 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
20 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
21 #include "components/content_settings/core/browser/content_settings_details.h" 20 #include "components/content_settings/core/browser/content_settings_details.h"
22 #include "components/content_settings/core/browser/cookie_settings.h" 21 #include "components/content_settings/core/browser/cookie_settings.h"
23 #include "components/content_settings/core/browser/host_content_settings_map.h" 22 #include "components/content_settings/core/browser/host_content_settings_map.h"
24 #include "components/content_settings/core/browser/website_settings_info.h" 23 #include "components/content_settings/core/browser/website_settings_info.h"
25 #include "components/content_settings/core/browser/website_settings_registry.h" 24 #include "components/content_settings/core/browser/website_settings_registry.h"
26 #include "components/content_settings/core/common/pref_names.h" 25 #include "components/content_settings/core/common/pref_names.h"
27 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
28 #include "components/prefs/scoped_user_pref_update.h" 27 #include "components/prefs/scoped_user_pref_update.h"
29 #include "components/sync_preferences/testing_pref_service_syncable.h" 28 #include "components/sync_preferences/testing_pref_service_syncable.h"
30 #include "content/public/test/test_browser_thread.h" 29 #include "content/public/test/test_browser_thread_bundle.h"
31 #include "net/base/static_cookie_policy.h" 30 #include "net/base/static_cookie_policy.h"
32 #include "ppapi/features/features.h" 31 #include "ppapi/features/features.h"
33 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
34 #include "url/gurl.h" 33 #include "url/gurl.h"
35 34
36 using content::BrowserThread;
37
38 using ::testing::_; 35 using ::testing::_;
39 36
40 namespace { 37 namespace {
41 38
42 bool MatchPrimaryPattern(const ContentSettingsPattern& expected_primary, 39 bool MatchPrimaryPattern(const ContentSettingsPattern& expected_primary,
43 const ContentSettingsPattern& primary_pattern, 40 const ContentSettingsPattern& primary_pattern,
44 const ContentSettingsPattern& secondary_pattern) { 41 const ContentSettingsPattern& secondary_pattern) {
45 return expected_primary == primary_pattern; 42 return expected_primary == primary_pattern;
46 } 43 }
47 44
48 } // namespace 45 } // namespace
49 46
50 class HostContentSettingsMapTest : public testing::Test { 47 class HostContentSettingsMapTest : public testing::Test {
51 public: 48 public:
52 HostContentSettingsMapTest() : ui_thread_(BrowserThread::UI, &message_loop_) { 49 HostContentSettingsMapTest() = default;
53 }
54 50
55 protected: 51 protected:
56 const std::string& GetPrefName(ContentSettingsType type) { 52 const std::string& GetPrefName(ContentSettingsType type) {
57 return content_settings::WebsiteSettingsRegistry::GetInstance() 53 return content_settings::WebsiteSettingsRegistry::GetInstance()
58 ->Get(type) 54 ->Get(type)
59 ->pref_name(); 55 ->pref_name();
60 } 56 }
61 57
62 base::MessageLoop message_loop_; 58 content::TestBrowserThreadBundle test_browser_thread_bundle_;
63 content::TestBrowserThread ui_thread_;
64 }; 59 };
65 60
66 // Wrapper to TestingProfile to reduce test boilerplates, by keeping a fixed 61 // Wrapper to TestingProfile to reduce test boilerplates, by keeping a fixed
67 // |content_type| so caller only need to specify it once. 62 // |content_type| so caller only need to specify it once.
68 class TesterForType { 63 class TesterForType {
69 public: 64 public:
70 TesterForType(TestingProfile *profile, ContentSettingsType content_type) 65 TesterForType(TestingProfile *profile, ContentSettingsType content_type)
71 : prefs_(profile->GetTestingPrefService()), 66 : prefs_(profile->GetTestingPrefService()),
72 host_content_settings_map_( 67 host_content_settings_map_(
73 HostContentSettingsMapFactory::GetForProfile(profile)), 68 HostContentSettingsMapFactory::GetForProfile(profile)),
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 GURL valid_url("http://google.com"); 1745 GURL valid_url("http://google.com");
1751 EXPECT_TRUE(map->CanSetNarrowestContentSetting( 1746 EXPECT_TRUE(map->CanSetNarrowestContentSetting(
1752 valid_url, valid_url, 1747 valid_url, valid_url,
1753 CONTENT_SETTINGS_TYPE_POPUPS)); 1748 CONTENT_SETTINGS_TYPE_POPUPS));
1754 1749
1755 GURL invalid_url("about:blank"); 1750 GURL invalid_url("about:blank");
1756 EXPECT_FALSE(map->CanSetNarrowestContentSetting( 1751 EXPECT_FALSE(map->CanSetNarrowestContentSetting(
1757 invalid_url, invalid_url, 1752 invalid_url, invalid_url,
1758 CONTENT_SETTINGS_TYPE_POPUPS)); 1753 CONTENT_SETTINGS_TYPE_POPUPS));
1759 } 1754 }
1760
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698