| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "public/web/WebFrameSerializer.h" | 31 #include "public/web/WebFrameSerializer.h" |
| 32 | 32 |
| 33 #include "platform/testing/URLTestHelpers.h" | 33 #include "platform/testing/URLTestHelpers.h" |
| 34 #include "platform/weborigin/KURL.h" | 34 #include "platform/weborigin/KURL.h" |
| 35 #include "public/platform/Platform.h" | 35 #include "public/platform/Platform.h" |
| 36 #include "public/platform/WebCString.h" | 36 #include "public/platform/WebCString.h" |
| 37 #include "public/platform/WebString.h" | 37 #include "public/platform/WebString.h" |
| 38 #include "public/platform/WebURL.h" | 38 #include "public/platform/WebURL.h" |
| 39 #include "public/platform/WebUnitTestSupport.h" | 39 #include "public/platform/WebURLLoaderMockFactory.h" |
| 40 #include "public/web/WebCache.h" |
| 40 #include "public/web/WebFrameSerializerClient.h" | 41 #include "public/web/WebFrameSerializerClient.h" |
| 41 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
| 42 #include "web/WebLocalFrameImpl.h" | 43 #include "web/WebLocalFrameImpl.h" |
| 43 #include "web/WebViewImpl.h" | 44 #include "web/WebViewImpl.h" |
| 44 #include "web/tests/FrameTestHelpers.h" | 45 #include "web/tests/FrameTestHelpers.h" |
| 45 #include "wtf/text/StringBuilder.h" | 46 #include "wtf/text/StringBuilder.h" |
| 46 | 47 |
| 47 namespace blink { | 48 namespace blink { |
| 48 | 49 |
| 49 namespace { | 50 namespace { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 64 | 65 |
| 65 class WebFrameSerializerTest : public testing::Test { | 66 class WebFrameSerializerTest : public testing::Test { |
| 66 protected: | 67 protected: |
| 67 WebFrameSerializerTest() | 68 WebFrameSerializerTest() |
| 68 { | 69 { |
| 69 m_helper.initialize(); | 70 m_helper.initialize(); |
| 70 } | 71 } |
| 71 | 72 |
| 72 ~WebFrameSerializerTest() override | 73 ~WebFrameSerializerTest() override |
| 73 { | 74 { |
| 74 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 75 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
| 76 WebCache::clear(); |
| 75 } | 77 } |
| 76 | 78 |
| 77 void registerMockedImageURL(const String& url) | 79 void registerMockedImageURL(const String& url) |
| 78 { | 80 { |
| 79 // Image resources need to be mocked, but irrelevant here what image the
y map to. | 81 // Image resources need to be mocked, but irrelevant here what image the
y map to. |
| 80 URLTestHelpers::registerMockedURLLoad(KURL(ParsedURLString, url), "frame
serialization/awesome.png"); | 82 URLTestHelpers::registerMockedURLLoad(KURL(ParsedURLString, url), "frame
serialization/awesome.png"); |
| 81 } | 83 } |
| 82 | 84 |
| 83 class SingleLinkRewritingDelegate : public WebFrameSerializer::LinkRewriting
Delegate { | 85 class SingleLinkRewritingDelegate : public WebFrameSerializer::LinkRewriting
Delegate { |
| 84 public: | 86 public: |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 EXPECT_EQ(expectedHTML, actualHTML); | 159 EXPECT_EQ(expectedHTML, actualHTML); |
| 158 } | 160 } |
| 159 | 161 |
| 160 TEST_F(WebFrameSerializerTest, FromUrlWithMinusMinus) | 162 TEST_F(WebFrameSerializerTest, FromUrlWithMinusMinus) |
| 161 { | 163 { |
| 162 String actualHTML = serializeFile("http://www.test.com?--x--", "text_only_pa
ge.html"); | 164 String actualHTML = serializeFile("http://www.test.com?--x--", "text_only_pa
ge.html"); |
| 163 EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", ac
tualHTML.substring(1, 60)); | 165 EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", ac
tualHTML.substring(1, 60)); |
| 164 } | 166 } |
| 165 | 167 |
| 166 } // namespace blink | 168 } // namespace blink |
| OLD | NEW |