| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "public/platform/WebURLResponse.h" | 31 #include "public/platform/WebURLResponse.h" |
| 32 | 32 |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 namespace { |
| 38 |
| 37 class TestExtraData : public WebURLResponse::ExtraData { | 39 class TestExtraData : public WebURLResponse::ExtraData { |
| 38 public: | 40 public: |
| 39 explicit TestExtraData(bool* alive) | 41 explicit TestExtraData(bool* alive) |
| 40 : m_alive(alive) | 42 : m_alive(alive) |
| 41 { | 43 { |
| 42 *alive = true; | 44 *alive = true; |
| 43 } | 45 } |
| 44 | 46 |
| 45 ~TestExtraData() override { *m_alive = false; } | 47 ~TestExtraData() override { *m_alive = false; } |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 bool* m_alive; | 50 bool* m_alive; |
| 49 }; | 51 }; |
| 50 | 52 |
| 53 } // anonymous namespace |
| 54 |
| 51 TEST(WebURLResponseTest, ExtraData) | 55 TEST(WebURLResponseTest, ExtraData) |
| 52 { | 56 { |
| 53 bool alive = false; | 57 bool alive = false; |
| 54 { | 58 { |
| 55 WebURLResponse urlResponse; | 59 WebURLResponse urlResponse; |
| 56 TestExtraData* extraData = new TestExtraData(&alive); | 60 TestExtraData* extraData = new TestExtraData(&alive); |
| 57 EXPECT_TRUE(alive); | 61 EXPECT_TRUE(alive); |
| 58 | 62 |
| 59 urlResponse.initialize(); | 63 urlResponse.initialize(); |
| 60 urlResponse.setExtraData(extraData); | 64 urlResponse.setExtraData(extraData); |
| 61 EXPECT_EQ(extraData, urlResponse.getExtraData()); | 65 EXPECT_EQ(extraData, urlResponse.getExtraData()); |
| 62 { | 66 { |
| 63 WebURLResponse otherUrlResponse = urlResponse; | 67 WebURLResponse otherUrlResponse = urlResponse; |
| 64 EXPECT_TRUE(alive); | 68 EXPECT_TRUE(alive); |
| 65 EXPECT_EQ(extraData, otherUrlResponse.getExtraData()); | 69 EXPECT_EQ(extraData, otherUrlResponse.getExtraData()); |
| 66 EXPECT_EQ(extraData, urlResponse.getExtraData()); | 70 EXPECT_EQ(extraData, urlResponse.getExtraData()); |
| 67 } | 71 } |
| 68 EXPECT_TRUE(alive); | 72 EXPECT_TRUE(alive); |
| 69 EXPECT_EQ(extraData, urlResponse.getExtraData()); | 73 EXPECT_EQ(extraData, urlResponse.getExtraData()); |
| 70 } | 74 } |
| 71 EXPECT_FALSE(alive); | 75 EXPECT_FALSE(alive); |
| 72 } | 76 } |
| 73 | 77 |
| 74 } // namespace blink | 78 } // namespace blink |
| OLD | NEW |