| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/fetch/MockResourceClients.h" | 5 #include "core/fetch/MockResourceClients.h" |
| 6 | 6 |
| 7 #include "core/fetch/ImageResource.h" | 7 #include "core/fetch/ImageResource.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 void MockResourceClient::removeAsClient() | 30 void MockResourceClient::removeAsClient() |
| 31 { | 31 { |
| 32 m_resource->removeClient(this); | 32 m_resource->removeClient(this); |
| 33 m_resource = nullptr; | 33 m_resource = nullptr; |
| 34 } | 34 } |
| 35 | 35 |
| 36 MockImageResourceClient::MockImageResourceClient(PassRefPtrWillBeRawPtr<ImageRes
ource> resource) | 36 MockImageResourceClient::MockImageResourceClient(PassRefPtrWillBeRawPtr<ImageRes
ource> resource) |
| 37 : MockResourceClient(resource) | 37 : MockResourceClient(resource) |
| 38 , m_imageChangedCount(0) | 38 , m_imageChangedCount(0) |
| 39 , m_imageChangedNotifyingFinishCount(0) |
| 39 { | 40 { |
| 40 toImageResource(m_resource.get())->addObserver(this); | 41 toImageResource(m_resource.get())->addObserver(this); |
| 41 } | 42 } |
| 42 | 43 |
| 43 MockImageResourceClient::~MockImageResourceClient() | 44 MockImageResourceClient::~MockImageResourceClient() |
| 44 { | 45 { |
| 45 if (m_resource) | 46 if (m_resource) |
| 46 toImageResource(m_resource.get())->removeObserver(this); | 47 toImageResource(m_resource.get())->removeObserver(this); |
| 47 } | 48 } |
| 48 | 49 |
| 49 void MockImageResourceClient::removeAsClient() | 50 void MockImageResourceClient::removeAsClient() |
| 50 { | 51 { |
| 51 toImageResource(m_resource.get())->removeObserver(this); | 52 toImageResource(m_resource.get())->removeObserver(this); |
| 52 MockResourceClient::removeAsClient(); | 53 MockResourceClient::removeAsClient(); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void MockImageResourceClient::imageChanged(ImageResource*, const IntRect*) | 56 void MockImageResourceClient::imageChanged(bool isNotifyingFinish, ImageResource
*, const IntRect*) |
| 56 { | 57 { |
| 58 if (isNotifyingFinish) { |
| 59 ASSERT_EQ(0, m_imageChangedNotifyingFinishCount); |
| 60 m_imageChangedNotifyingFinishCount++; |
| 61 } |
| 57 m_imageChangedCount++; | 62 m_imageChangedCount++; |
| 58 } | 63 } |
| 59 | 64 |
| 65 bool MockImageResourceClient::notifyFinishedCalled() const |
| 66 { |
| 67 EXPECT_EQ(m_notifyFinishedCalled ? 1 : 0, m_imageChangedNotifyingFinishCount
); |
| 68 |
| 69 return m_notifyFinishedCalled; |
| 70 } |
| 71 |
| 60 } // namespace blink | 72 } // namespace blink |
| OLD | NEW |