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

Side by Side Diff: components/content_settings/core/browser/content_settings_registry_unittest.cc

Issue 1991623005: Only Register() platform specific content settings types on different platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include <vector> 6 #include <vector>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "components/content_settings/core/browser/content_settings_info.h" 10 #include "components/content_settings/core/browser/content_settings_info.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 info->website_settings_info(); 55 info->website_settings_info();
56 EXPECT_EQ("cookies", website_settings_info->name()); 56 EXPECT_EQ("cookies", website_settings_info->name());
57 EXPECT_EQ("profile.content_settings.exceptions.cookies", 57 EXPECT_EQ("profile.content_settings.exceptions.cookies",
58 website_settings_info->pref_name()); 58 website_settings_info->pref_name());
59 EXPECT_EQ("profile.default_content_setting_values.cookies", 59 EXPECT_EQ("profile.default_content_setting_values.cookies",
60 website_settings_info->default_value_pref_name()); 60 website_settings_info->default_value_pref_name());
61 int setting; 61 int setting;
62 ASSERT_TRUE( 62 ASSERT_TRUE(
63 website_settings_info->initial_default_value()->GetAsInteger(&setting)); 63 website_settings_info->initial_default_value()->GetAsInteger(&setting));
64 EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); 64 EXPECT_EQ(CONTENT_SETTING_ALLOW, setting);
65 #if defined(OS_IOS)
66 EXPECT_EQ(PrefRegistry::NO_REGISTRATION_FLAGS,
67 website_settings_info->GetPrefRegistrationFlags());
68 #else
65 EXPECT_EQ(user_prefs::PrefRegistrySyncable::SYNCABLE_PREF, 69 EXPECT_EQ(user_prefs::PrefRegistrySyncable::SYNCABLE_PREF,
66 website_settings_info->GetPrefRegistrationFlags()); 70 website_settings_info->GetPrefRegistrationFlags());
71 #endif
67 72
68 // Check the WebsiteSettingsInfo is registered correctly. 73 // Check the WebsiteSettingsInfo is registered correctly.
69 EXPECT_EQ(website_settings_registry()->Get(CONTENT_SETTINGS_TYPE_COOKIES), 74 EXPECT_EQ(website_settings_registry()->Get(CONTENT_SETTINGS_TYPE_COOKIES),
70 website_settings_info); 75 website_settings_info);
71 } 76 }
72 77
73 TEST_F(ContentSettingsRegistryTest, Iteration) { 78 TEST_F(ContentSettingsRegistryTest, Iteration) {
74 // Check that plugins and cookies settings appear once during iteration. 79 // Check that plugins and cookies settings appear once during iteration.
75 bool plugins_found = false; 80 bool plugins_found = false;
76 bool cookies_found = false; 81 bool cookies_found = false;
77 for (const ContentSettingsInfo* info : *registry()) { 82 for (const ContentSettingsInfo* info : *registry()) {
78 ContentSettingsType type = info->website_settings_info()->type(); 83 ContentSettingsType type = info->website_settings_info()->type();
79 EXPECT_EQ(registry()->Get(type), info); 84 EXPECT_EQ(registry()->Get(type), info);
80 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) { 85 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
81 EXPECT_FALSE(plugins_found); 86 EXPECT_FALSE(plugins_found);
82 plugins_found = true; 87 plugins_found = true;
83 } else if (type == CONTENT_SETTINGS_TYPE_COOKIES) { 88 } else if (type == CONTENT_SETTINGS_TYPE_COOKIES) {
84 EXPECT_FALSE(cookies_found); 89 EXPECT_FALSE(cookies_found);
85 cookies_found = true; 90 cookies_found = true;
86 } 91 }
87 } 92 }
88 93
94 #if defined(OS_ANDROID) || defined(OS_IOS)
95 EXPECT_FALSE(plugins_found);
96 #else
89 EXPECT_TRUE(plugins_found); 97 EXPECT_TRUE(plugins_found);
98 #endif
99
90 EXPECT_TRUE(cookies_found); 100 EXPECT_TRUE(cookies_found);
91 } 101 }
92 102
93 } // namespace content_settings 103 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698