| 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 "chrome/common/content_settings_component.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 10 |
| 10 using options::MediaException; | 11 using options::MediaException; |
| 11 using options::MediaExceptions; | 12 using options::MediaExceptions; |
| 12 using options::PepperFlashContentSettingsUtils; | 13 using options::PepperFlashContentSettingsUtils; |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 MediaExceptions ConvertAndSort(const MediaException* items, size_t count) { | 17 MediaExceptions ConvertAndSort(const MediaException* items, size_t count) { |
| 17 MediaExceptions result(items, items + count); | 18 MediaExceptions result(items, items + count); |
| 18 PepperFlashContentSettingsUtils::SortMediaExceptions(&result); | 19 PepperFlashContentSettingsUtils::SortMediaExceptions(&result); |
| 19 return result; | 20 return result; |
| 20 } | 21 } |
| 21 | 22 |
| 22 } // namespace | 23 } // namespace |
| 23 | 24 |
| 24 TEST(PepperFlashContentSettingsUtilsTest, SortMediaExceptions) { | 25 TEST(PepperFlashContentSettingsUtilsTest, SortMediaExceptions) { |
| 26 InitContentSettingsComponent(); |
| 25 MediaException entry_1(ContentSettingsPattern::FromString("www.google.com"), | 27 MediaException entry_1(ContentSettingsPattern::FromString("www.google.com"), |
| 26 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ASK); | 28 CONTENT_SETTING_ALLOW, CONTENT_SETTING_ASK); |
| 27 MediaException entry_2(ContentSettingsPattern::FromString("www.youtube.com"), | 29 MediaException entry_2(ContentSettingsPattern::FromString("www.youtube.com"), |
| 28 CONTENT_SETTING_BLOCK, CONTENT_SETTING_DEFAULT); | 30 CONTENT_SETTING_BLOCK, CONTENT_SETTING_DEFAULT); |
| 29 MediaException entry_3(ContentSettingsPattern::Wildcard(), | 31 MediaException entry_3(ContentSettingsPattern::Wildcard(), |
| 30 CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK); | 32 CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK); |
| 31 MediaException entry_4(ContentSettingsPattern(), | 33 MediaException entry_4(ContentSettingsPattern(), |
| 32 CONTENT_SETTING_SESSION_ONLY, CONTENT_SETTING_ALLOW); | 34 CONTENT_SETTING_SESSION_ONLY, CONTENT_SETTING_ALLOW); |
| 33 | 35 |
| 34 MediaExceptions list_1; | 36 MediaExceptions list_1; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 55 | 57 |
| 56 PepperFlashContentSettingsUtils::SortMediaExceptions(&list_1); | 58 PepperFlashContentSettingsUtils::SortMediaExceptions(&list_1); |
| 57 PepperFlashContentSettingsUtils::SortMediaExceptions(&list_2); | 59 PepperFlashContentSettingsUtils::SortMediaExceptions(&list_2); |
| 58 PepperFlashContentSettingsUtils::SortMediaExceptions(&list_3); | 60 PepperFlashContentSettingsUtils::SortMediaExceptions(&list_3); |
| 59 | 61 |
| 60 EXPECT_EQ(list_1, list_2); | 62 EXPECT_EQ(list_1, list_2); |
| 61 EXPECT_EQ(list_2, list_3); | 63 EXPECT_EQ(list_2, list_3); |
| 62 } | 64 } |
| 63 | 65 |
| 64 TEST(PepperFlashContentSettingsUtilsTest, AreMediaExceptionsEqual) { | 66 TEST(PepperFlashContentSettingsUtilsTest, AreMediaExceptionsEqual) { |
| 67 InitContentSettingsComponent(); |
| 65 { | 68 { |
| 66 // Empty lists are equal. | 69 // Empty lists are equal. |
| 67 // Default settings are not compared directly, so it is possible to return | 70 // Default settings are not compared directly, so it is possible to return |
| 68 // true when they are different. | 71 // true when they are different. |
| 69 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 72 EXPECT_TRUE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 70 CONTENT_SETTING_BLOCK, | 73 CONTENT_SETTING_BLOCK, |
| 71 MediaExceptions(), | 74 MediaExceptions(), |
| 72 CONTENT_SETTING_ASK, | 75 CONTENT_SETTING_ASK, |
| 73 MediaExceptions(), | 76 MediaExceptions(), |
| 74 false, | 77 false, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 false)); | 197 false)); |
| 195 EXPECT_FALSE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( | 198 EXPECT_FALSE(PepperFlashContentSettingsUtils::AreMediaExceptionsEqual( |
| 196 CONTENT_SETTING_ASK, | 199 CONTENT_SETTING_ASK, |
| 197 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), | 200 ConvertAndSort(exceptions_1, arraysize(exceptions_1)), |
| 198 CONTENT_SETTING_ASK, | 201 CONTENT_SETTING_ASK, |
| 199 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), | 202 ConvertAndSort(exceptions_2, arraysize(exceptions_2)), |
| 200 false, | 203 false, |
| 201 false)); | 204 false)); |
| 202 } | 205 } |
| 203 } | 206 } |
| OLD | NEW |