| 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 "chrome/browser/ui/webui/options/pepper_flash_content_settings_utils.h" | 5 #include "chrome/browser/ui/webui/options/pepper_flash_content_settings_utils.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 using options::MediaException; | 10 using options::MediaException; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 EXPECT_EQ(list_2, list_3); | 61 EXPECT_EQ(list_2, list_3); |
| 62 } | 62 } |
| 63 | 63 |
| 64 TEST(PepperFlashContentSettingsUtilsTest, AreMediaExceptionsEqual) { | 64 TEST(PepperFlashContentSettingsUtilsTest, AreMediaExceptionsEqual) { |
| 65 { | 65 { |
| 66 // Empty lists are equal. | 66 // Empty lists are equal. |
| 67 // Default settings are not compared directly, so it is possible to return | 67 // Default settings are not compared directly, so it is possible to return |
| 68 // true when they are different. | 68 // true when they are different. |
| 69 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 69 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 70 CONTENT_SETTING_BLOCK, | 70 CONTENT_SETTING_BLOCK, |
| 71 CONTENT_SETTING_ASK, |
| 71 MediaExceptions(), | 72 MediaExceptions(), |
| 73 CONTENT_SETTING_BLOCK, |
| 72 CONTENT_SETTING_ASK, | 74 CONTENT_SETTING_ASK, |
| 73 MediaExceptions(), | 75 MediaExceptions(), |
| 74 false, | 76 false, |
| 75 false)); | 77 false)); |
| 76 } | 78 } |
| 77 | 79 |
| 78 { | 80 { |
| 79 MediaException exceptions_1[] = { | 81 MediaException exceptions_1[] = { |
| 80 MediaException(ContentSettingsPattern::FromString("www.google.com"), | 82 MediaException(ContentSettingsPattern::FromString("www.google.com"), |
| 81 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW), | 83 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW), |
| 82 MediaException(ContentSettingsPattern::FromString("www.youtube.com"), | 84 MediaException(ContentSettingsPattern::FromString("www.youtube.com"), |
| 83 CONTENT_SETTING_ASK, CONTENT_SETTING_ASK) | 85 CONTENT_SETTING_ASK, CONTENT_SETTING_ASK) |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 MediaException exceptions_2[] = { | 88 MediaException exceptions_2[] = { |
| 87 MediaException(ContentSettingsPattern::FromString("www.google.com"), | 89 MediaException(ContentSettingsPattern::FromString("www.google.com"), |
| 88 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW) | 90 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW) |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 // The exception of "www.youtube.com" in |exceptions_1| should not affect | 93 // The exception of "www.youtube.com" in |exceptions_1| should not affect |
| 92 // the result, because it has the same settings as |default_setting_2|. | 94 // the result, because it has the same settings as |default_setting_2|. |
| 93 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 95 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 94 CONTENT_SETTING_ALLOW, | 96 CONTENT_SETTING_ALLOW, |
| 97 CONTENT_SETTING_ALLOW, |
| 95 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), | 98 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), |
| 96 CONTENT_SETTING_ASK, | 99 CONTENT_SETTING_ASK, |
| 100 CONTENT_SETTING_ASK, |
| 97 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), | 101 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), |
| 98 false, | 102 false, |
| 99 false)); | 103 false)); |
| 100 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 104 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 101 CONTENT_SETTING_ASK, | 105 CONTENT_SETTING_ASK, |
| 106 CONTENT_SETTING_ASK, |
| 102 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), | 107 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), |
| 103 CONTENT_SETTING_ALLOW, | 108 CONTENT_SETTING_ALLOW, |
| 109 CONTENT_SETTING_ALLOW, |
| 104 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), | 110 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), |
| 105 false, | 111 false, |
| 106 false)); | 112 false)); |
| 107 // Changing |default_setting_2| should change the result. | 113 // Changing |default_setting_2| should change the result. |
| 108 EXPECT_FALSE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 114 EXPECT_FALSE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 109 CONTENT_SETTING_ALLOW, | 115 CONTENT_SETTING_ALLOW, |
| 116 CONTENT_SETTING_ALLOW, |
| 110 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), | 117 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), |
| 111 CONTENT_SETTING_ALLOW, | 118 CONTENT_SETTING_ALLOW, |
| 119 CONTENT_SETTING_ALLOW, |
| 112 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), | 120 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), |
| 113 false, | 121 false, |
| 114 false)); | 122 false)); |
| 115 } | 123 } |
| 116 | 124 |
| 117 { | 125 { |
| 118 // Similar to the previous block, but reoder the exceptions. The outcome | 126 // Similar to the previous block, but reoder the exceptions. The outcome |
| 119 // should be the same. | 127 // should be the same. |
| 120 MediaException exceptions_1[] = { | 128 MediaException exceptions_1[] = { |
| 121 MediaException(ContentSettingsPattern::FromString("www.youtube.com"), | 129 MediaException(ContentSettingsPattern::FromString("www.youtube.com"), |
| 122 CONTENT_SETTING_ASK, CONTENT_SETTING_ASK), | 130 CONTENT_SETTING_ASK, CONTENT_SETTING_ASK), |
| 123 MediaException(ContentSettingsPattern::FromString("www.google.com"), | 131 MediaException(ContentSettingsPattern::FromString("www.google.com"), |
| 124 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW) | 132 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW) |
| 125 }; | 133 }; |
| 126 | 134 |
| 127 MediaException exceptions_2[] = { | 135 MediaException exceptions_2[] = { |
| 128 MediaException(ContentSettingsPattern::FromString("www.google.com"), | 136 MediaException(ContentSettingsPattern::FromString("www.google.com"), |
| 129 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW) | 137 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW) |
| 130 }; | 138 }; |
| 131 | 139 |
| 132 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 140 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 133 CONTENT_SETTING_ALLOW, | 141 CONTENT_SETTING_ALLOW, |
| 142 CONTENT_SETTING_ALLOW, |
| 134 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), | 143 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), |
| 135 CONTENT_SETTING_ASK, | 144 CONTENT_SETTING_ASK, |
| 145 CONTENT_SETTING_ASK, |
| 136 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), | 146 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), |
| 137 false, | 147 false, |
| 138 false)); | 148 false)); |
| 139 EXPECT_FALSE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 149 EXPECT_FALSE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 140 CONTENT_SETTING_ALLOW, | 150 CONTENT_SETTING_ALLOW, |
| 151 CONTENT_SETTING_ALLOW, |
| 141 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), | 152 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), |
| 142 CONTENT_SETTING_ALLOW, | 153 CONTENT_SETTING_ALLOW, |
| 154 CONTENT_SETTING_ALLOW, |
| 143 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), | 155 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), |
| 144 false, | 156 false, |
| 145 false)); | 157 false)); |
| 146 } | 158 } |
| 147 | 159 |
| 148 { | 160 { |
| 149 MediaException exceptions_1[] = { | 161 MediaException exceptions_1[] = { |
| 150 MediaException(ContentSettingsPattern::FromString("www.google.com"), | 162 MediaException(ContentSettingsPattern::FromString("www.google.com"), |
| 151 CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK) | 163 CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK) |
| 152 }; | 164 }; |
| 153 | 165 |
| 154 MediaException exceptions_2[] = { | 166 MediaException exceptions_2[] = { |
| 155 MediaException(ContentSettingsPattern::FromString("www.google.com"), | 167 MediaException(ContentSettingsPattern::FromString("www.google.com"), |
| 156 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW) | 168 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW) |
| 157 }; | 169 }; |
| 158 | 170 |
| 159 // Test that |ignore_video_setting| works. | 171 // Test that |ignore_video_setting| works. |
| 160 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 172 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 161 CONTENT_SETTING_ASK, | 173 CONTENT_SETTING_ASK, |
| 174 CONTENT_SETTING_ASK, |
| 162 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), | 175 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), |
| 163 CONTENT_SETTING_ASK, | 176 CONTENT_SETTING_ASK, |
| 177 CONTENT_SETTING_BLOCK, |
| 164 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), | 178 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), |
| 165 false, | 179 false, |
| 166 true)); | 180 true)); |
| 167 EXPECT_FALSE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 181 EXPECT_FALSE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 168 CONTENT_SETTING_ASK, | 182 CONTENT_SETTING_ASK, |
| 183 CONTENT_SETTING_ASK, |
| 169 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), | 184 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), |
| 170 CONTENT_SETTING_ASK, | 185 CONTENT_SETTING_ASK, |
| 186 CONTENT_SETTING_ASK, |
| 171 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), | 187 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), |
| 172 false, | 188 false, |
| 173 false)); | 189 false)); |
| 174 } | 190 } |
| 175 | 191 |
| 176 { | 192 { |
| 177 MediaException exceptions_1[] = { | 193 MediaException exceptions_1[] = { |
| 178 MediaException(ContentSettingsPattern::FromString("www.google.com"), | 194 MediaException(ContentSettingsPattern::FromString("www.google.com"), |
| 179 CONTENT_SETTING_BLOCK, CONTENT_SETTING_ALLOW) | 195 CONTENT_SETTING_BLOCK, CONTENT_SETTING_ALLOW) |
| 180 }; | 196 }; |
| 181 | 197 |
| 182 MediaException exceptions_2[] = { | 198 MediaException exceptions_2[] = { |
| 183 MediaException(ContentSettingsPattern::FromString("www.google.com"), | 199 MediaException(ContentSettingsPattern::FromString("www.google.com"), |
| 184 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW) | 200 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW) |
| 185 }; | 201 }; |
| 186 | 202 |
| 187 // Test that |ignore_audio_setting| works. | 203 // Test that |ignore_audio_setting| works. |
| 188 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 204 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 205 CONTENT_SETTING_BLOCK, |
| 189 CONTENT_SETTING_ASK, | 206 CONTENT_SETTING_ASK, |
| 190 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), | 207 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), |
| 191 CONTENT_SETTING_ASK, | 208 CONTENT_SETTING_ASK, |
| 209 CONTENT_SETTING_ASK, |
| 192 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), | 210 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), |
| 193 true, | 211 true, |
| 194 false)); | 212 false)); |
| 195 EXPECT_FALSE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 213 EXPECT_FALSE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 196 CONTENT_SETTING_ASK, | 214 CONTENT_SETTING_ASK, |
| 215 CONTENT_SETTING_ASK, |
| 197 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), | 216 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), |
| 198 CONTENT_SETTING_ASK, | 217 CONTENT_SETTING_ASK, |
| 218 CONTENT_SETTING_ASK, |
| 199 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), | 219 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), |
| 200 false, | 220 false, |
| 201 false)); | 221 false)); |
| 202 } | 222 } |
| 203 } | 223 } |
| OLD | NEW |