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