| 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 15 matching lines...) Expand all Loading... |
| 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/CachedImage.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" | |
| 37 #include "core/loader/cache/CachedResourceHandle.h" | 36 #include "core/loader/cache/CachedResourceHandle.h" |
| 38 #include "core/loader/cache/MemoryCache.h" | 37 #include "core/loader/cache/MemoryCache.h" |
| 38 #include "core/loader/cache/MockCachedImageClient.h" |
| 39 #include "core/loader/cache/ResourceFetcher.h" | 39 #include "core/loader/cache/ResourceFetcher.h" |
| 40 #include "core/page/Frame.h" | 40 #include "core/page/Frame.h" |
| 41 #include "core/page/FrameView.h" | 41 #include "core/page/FrameView.h" |
| 42 #include "core/page/Page.h" | 42 #include "core/page/Page.h" |
| 43 #include "core/platform/SharedBuffer.h" | 43 #include "core/platform/SharedBuffer.h" |
| 44 #include "core/platform/graphics/Image.h" | |
| 45 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
| 46 #include "public/platform/WebThread.h" | 45 #include "public/platform/WebThread.h" |
| 47 #include "public/platform/WebURL.h" | 46 #include "public/platform/WebURL.h" |
| 48 #include "public/platform/WebURLResponse.h" | 47 #include "public/platform/WebURLResponse.h" |
| 49 #include "public/platform/WebUnitTestSupport.h" | 48 #include "public/platform/WebUnitTestSupport.h" |
| 50 #include <gtest/gtest.h> | |
| 51 | 49 |
| 52 using namespace WebCore; | 50 using namespace WebCore; |
| 53 | 51 |
| 54 namespace { | 52 namespace { |
| 55 | 53 |
| 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 { | 54 class QuitTask : public WebKit::WebThread::Task { |
| 85 public: | 55 public: |
| 86 virtual void run() | 56 virtual void run() |
| 87 { | 57 { |
| 88 WebKit::Platform::current()->currentThread()->exitRunLoop(); | 58 WebKit::Platform::current()->currentThread()->exitRunLoop(); |
| 89 } | 59 } |
| 90 }; | 60 }; |
| 91 | 61 |
| 92 void runPendingTasks() | 62 void runPendingTasks() |
| 93 { | 63 { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 147 |
| 178 // Trigger the cancel timer, ensure the load was cancelled and the resource
was evicted from the cache. | 148 // Trigger the cancel timer, ensure the load was cancelled and the resource
was evicted from the cache. |
| 179 runPendingTasks(); | 149 runPendingTasks(); |
| 180 EXPECT_EQ(CachedResource::LoadError, cachedImage->status()); | 150 EXPECT_EQ(CachedResource::LoadError, cachedImage->status()); |
| 181 EXPECT_EQ(reinterpret_cast<CachedResource*>(0), memoryCache()->resourceForUR
L(testURL)); | 151 EXPECT_EQ(reinterpret_cast<CachedResource*>(0), memoryCache()->resourceForUR
L(testURL)); |
| 182 | 152 |
| 183 WebKit::Platform::current()->unitTestSupport()->unregisterMockedURL(testURL)
; | 153 WebKit::Platform::current()->unitTestSupport()->unregisterMockedURL(testURL)
; |
| 184 } | 154 } |
| 185 | 155 |
| 186 } // namespace | 156 } // namespace |
| OLD | NEW |