OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, 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 11 matching lines...) Expand all Loading... |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 "config.h" | 31 #include "config.h" |
32 #include "core/loader/cache/CachedImage.h" | 32 #include "core/loader/cache/CachedImageTest.h" |
33 | 33 |
34 #include "core/loader/DocumentLoader.h" | 34 #include "core/loader/DocumentLoader.h" |
35 #include "core/loader/EmptyClients.h" | 35 #include "core/loader/EmptyClients.h" |
36 #include "core/loader/cache/CachedImageClient.h" | 36 #include "core/loader/cache/CachedImage.h" |
37 #include "core/loader/cache/CachedResourceHandle.h" | 37 #include "core/loader/cache/CachedResourceHandle.h" |
38 #include "core/loader/cache/CachedResourceLoader.h" | 38 #include "core/loader/cache/CachedResourceLoader.h" |
39 #include "core/loader/cache/MemoryCache.h" | 39 #include "core/loader/cache/MemoryCache.h" |
40 #include "core/page/Frame.h" | |
41 #include "core/page/FrameView.h" | 40 #include "core/page/FrameView.h" |
42 #include "core/page/Page.h" | 41 #include "core/page/Page.h" |
43 #include "core/platform/SharedBuffer.h" | 42 #include "core/platform/SharedBuffer.h" |
44 #include "core/platform/graphics/Image.h" | |
45 #include "public/platform/Platform.h" | 43 #include "public/platform/Platform.h" |
46 #include "public/platform/WebThread.h" | 44 #include "public/platform/WebThread.h" |
47 #include "public/platform/WebURL.h" | 45 #include "public/platform/WebURL.h" |
48 #include "public/platform/WebURLResponse.h" | 46 #include "public/platform/WebURLResponse.h" |
49 #include "public/platform/WebUnitTestSupport.h" | 47 #include "public/platform/WebUnitTestSupport.h" |
50 #include <gtest/gtest.h> | |
51 | 48 |
52 using namespace WebCore; | 49 using namespace WebCore; |
53 | 50 |
54 namespace { | 51 namespace { |
55 | 52 |
56 class MockCachedImageClient : public WebCore::CachedImageClient { | |
57 public: | |
58 MockCachedImageClient() | |
59 : m_imageChangedCount(0) | |
60 , m_notifyFinishedCalled(false) | |
61 { | |
62 } | |
63 | |
64 virtual ~MockCachedImageClient() { } | |
65 virtual void imageChanged(CachedImage*, const IntRect*) | |
66 { | |
67 m_imageChangedCount++; | |
68 } | |
69 | |
70 virtual void notifyFinished(CachedResource*) | |
71 { | |
72 ASSERT_FALSE(m_notifyFinishedCalled); | |
73 m_notifyFinishedCalled = true; | |
74 } | |
75 | |
76 int imageChangedCount() const { return m_imageChangedCount; } | |
77 bool notifyFinishedCalled() const { return m_notifyFinishedCalled; } | |
78 | |
79 private: | |
80 int m_imageChangedCount; | |
81 bool m_notifyFinishedCalled; | |
82 }; | |
83 | |
84 class QuitTask : public WebKit::WebThread::Task { | 53 class QuitTask : public WebKit::WebThread::Task { |
85 public: | 54 public: |
86 virtual void run() | 55 virtual void run() |
87 { | 56 { |
88 WebKit::Platform::current()->currentThread()->exitRunLoop(); | 57 WebKit::Platform::current()->currentThread()->exitRunLoop(); |
89 } | 58 } |
90 }; | 59 }; |
91 | 60 |
92 void runPendingTasks() | 61 void runPendingTasks() |
93 { | 62 { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 146 |
178 // Trigger the cancel timer, ensure the load was cancelled and the resource
was evicted from the cache. | 147 // Trigger the cancel timer, ensure the load was cancelled and the resource
was evicted from the cache. |
179 runPendingTasks(); | 148 runPendingTasks(); |
180 EXPECT_EQ(CachedResource::LoadError, cachedImage->status()); | 149 EXPECT_EQ(CachedResource::LoadError, cachedImage->status()); |
181 EXPECT_EQ(reinterpret_cast<CachedResource*>(0), memoryCache()->resourceForUR
L(testURL)); | 150 EXPECT_EQ(reinterpret_cast<CachedResource*>(0), memoryCache()->resourceForUR
L(testURL)); |
182 | 151 |
183 WebKit::Platform::current()->unitTestSupport()->unregisterMockedURL(testURL)
; | 152 WebKit::Platform::current()->unitTestSupport()->unregisterMockedURL(testURL)
; |
184 } | 153 } |
185 | 154 |
186 } // namespace | 155 } // namespace |
OLD | NEW |