| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "core/fetch/ResourceLoaderOptions.h" | 5 #include "core/fetch/ResourceLoaderOptions.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include <type_traits> | 8 #include <type_traits> |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 TEST(ResourceLoaderOptionsTest, DeepCopy) { | 14 TEST(ResourceLoaderOptionsTest, DeepCopy) { |
| 15 // Check that the fields of ResourceLoaderOptions are enums, | 15 // Check that the fields of ResourceLoaderOptions are enums, except for |
| 16 // except for initiatorInfo and securityOrigin. | 16 // initiatorInfo and securityOrigin. |
| 17 static_assert(std::is_enum<DataBufferingPolicy>::value, | 17 static_assert(std::is_enum<DataBufferingPolicy>::value, |
| 18 "DataBufferingPolicy should be an enum"); | 18 "DataBufferingPolicy should be an enum"); |
| 19 static_assert(std::is_enum<StoredCredentials>::value, | 19 static_assert(std::is_enum<StoredCredentials>::value, |
| 20 "StoredCredentials should be an enum"); | 20 "StoredCredentials should be an enum"); |
| 21 static_assert(std::is_enum<CredentialRequest>::value, | 21 static_assert(std::is_enum<CredentialRequest>::value, |
| 22 "CredentialRequest should be an enum"); | 22 "CredentialRequest should be an enum"); |
| 23 static_assert(std::is_enum<ContentSecurityPolicyDisposition>::value, | 23 static_assert(std::is_enum<ContentSecurityPolicyDisposition>::value, |
| 24 "ContentSecurityPolicyDisposition should be an enum"); | 24 "ContentSecurityPolicyDisposition should be an enum"); |
| 25 static_assert(std::is_enum<RequestInitiatorContext>::value, | 25 static_assert(std::is_enum<RequestInitiatorContext>::value, |
| 26 "RequestInitiatorContext should be an enum"); | 26 "RequestInitiatorContext should be an enum"); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 EXPECT_EQ(original.requestInitiatorContext, copy.requestInitiatorContext); | 80 EXPECT_EQ(original.requestInitiatorContext, copy.requestInitiatorContext); |
| 81 EXPECT_EQ(original.synchronousPolicy, copy.synchronousPolicy); | 81 EXPECT_EQ(original.synchronousPolicy, copy.synchronousPolicy); |
| 82 EXPECT_EQ(original.corsEnabled, copy.corsEnabled); | 82 EXPECT_EQ(original.corsEnabled, copy.corsEnabled); |
| 83 EXPECT_EQ(original.securityOrigin->protocol(), | 83 EXPECT_EQ(original.securityOrigin->protocol(), |
| 84 copy.securityOrigin->protocol()); | 84 copy.securityOrigin->protocol()); |
| 85 EXPECT_EQ(original.securityOrigin->host(), copy.securityOrigin->host()); | 85 EXPECT_EQ(original.securityOrigin->host(), copy.securityOrigin->host()); |
| 86 EXPECT_EQ(original.securityOrigin->domain(), copy.securityOrigin->domain()); | 86 EXPECT_EQ(original.securityOrigin->domain(), copy.securityOrigin->domain()); |
| 87 | 87 |
| 88 // Check that pointers are different between |original| and |copy| | 88 // Check that pointers are different between |original| and |copy| |
| 89 // FIXME: When |original| and |copy| are in different threads, then | 89 // FIXME: When |original| and |copy| are in different threads, then |
| 90 // EXPECT_NE(original.initiatorInfo.name.impl(), copy.initiatorInfo.name.impl(
)); | 90 // EXPECT_NE(original.initiatorInfo.name.impl(), |
| 91 // copy.initiatorInfo.name.impl()); |
| 91 // should pass. However, in the unit test here, these two pointers are the | 92 // should pass. However, in the unit test here, these two pointers are the |
| 92 // same, because initiatorInfo.name is AtomicString. | 93 // same, because initiatorInfo.name is AtomicString. |
| 93 EXPECT_NE(original.securityOrigin.get(), copy.securityOrigin.get()); | 94 EXPECT_NE(original.securityOrigin.get(), copy.securityOrigin.get()); |
| 94 EXPECT_NE(original.securityOrigin->protocol().impl(), | 95 EXPECT_NE(original.securityOrigin->protocol().impl(), |
| 95 copy.securityOrigin->protocol().impl()); | 96 copy.securityOrigin->protocol().impl()); |
| 96 EXPECT_NE(original.securityOrigin->host().impl(), | 97 EXPECT_NE(original.securityOrigin->host().impl(), |
| 97 copy.securityOrigin->host().impl()); | 98 copy.securityOrigin->host().impl()); |
| 98 EXPECT_NE(original.securityOrigin->domain().impl(), | 99 EXPECT_NE(original.securityOrigin->domain().impl(), |
| 99 copy.securityOrigin->domain().impl()); | 100 copy.securityOrigin->domain().impl()); |
| 100 | 101 |
| 101 // FIXME: The checks for content equality/pointer inequality for | 102 // FIXME: The checks for content equality/pointer inequality for |
| 102 // securityOrigin here is not complete (i.e. m_filePath is not checked). | 103 // securityOrigin here is not complete (i.e. m_filePath is not checked). A |
| 103 // A unit test for SecurityOrigin::isolatedCopy() that covers these checks | 104 // unit test for SecurityOrigin::isolatedCopy() that covers these checks |
| 104 // should be added. | 105 // should be added. |
| 105 } | 106 } |
| 106 | 107 |
| 107 } // namespace | 108 } // namespace |
| 108 | 109 |
| 109 } // namespace blink | 110 } // namespace blink |
| OLD | NEW |