| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/loader/resource/MockImageResourceClient.h" | |
| 6 | |
| 7 #include "core/loader/resource/ImageResource.h" | |
| 8 #include "core/loader/resource/ImageResourceContent.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 MockImageResourceClient::MockImageResourceClient(ImageResource* resource) | |
| 14 : MockResourceClient(resource), | |
| 15 m_imageChangedCount(0), | |
| 16 m_encodedSizeOnLastImageChanged(0), | |
| 17 m_imageNotifyFinishedCount(0), | |
| 18 m_encodedSizeOnImageNotifyFinished(0) { | |
| 19 toImageResource(m_resource)->getContent()->addObserver(this); | |
| 20 } | |
| 21 | |
| 22 MockImageResourceClient::~MockImageResourceClient() {} | |
| 23 | |
| 24 void MockImageResourceClient::removeAsClient() { | |
| 25 toImageResource(m_resource)->getContent()->removeObserver(this); | |
| 26 MockResourceClient::removeAsClient(); | |
| 27 } | |
| 28 | |
| 29 void MockImageResourceClient::dispose() { | |
| 30 if (m_resource) | |
| 31 toImageResource(m_resource)->getContent()->removeObserver(this); | |
| 32 MockResourceClient::dispose(); | |
| 33 } | |
| 34 | |
| 35 void MockImageResourceClient::imageChanged(ImageResourceContent* image, | |
| 36 const IntRect*) { | |
| 37 m_imageChangedCount++; | |
| 38 m_encodedSizeOnLastImageChanged = m_resource->encodedSize(); | |
| 39 } | |
| 40 | |
| 41 void MockImageResourceClient::imageNotifyFinished(ImageResourceContent* image) { | |
| 42 ASSERT_EQ(0, m_imageNotifyFinishedCount); | |
| 43 m_imageNotifyFinishedCount++; | |
| 44 m_encodedSizeOnImageNotifyFinished = m_resource->encodedSize(); | |
| 45 } | |
| 46 | |
| 47 bool MockImageResourceClient::notifyFinishedCalled() const { | |
| 48 return m_notifyFinishedCalled; | |
| 49 } | |
| 50 | |
| 51 } // namespace blink | |
| OLD | NEW |