| 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 { |
| 11 | 11 |
| 12 MockResourceClient::MockResourceClient(PassRefPtrWillBeRawPtr<Resource> resource
) | 12 MockResourceClient::MockResourceClient(RawPtr<Resource> resource) |
| 13 : m_resource(resource.get()) | 13 : m_resource(resource.get()) |
| 14 , m_notifyFinishedCalled(false) | 14 , m_notifyFinishedCalled(false) |
| 15 { | 15 { |
| 16 m_resource->addClient(this); | 16 m_resource->addClient(this); |
| 17 } | 17 } |
| 18 | 18 |
| 19 MockResourceClient::~MockResourceClient() | 19 MockResourceClient::~MockResourceClient() |
| 20 { | 20 { |
| 21 if (m_resource) | 21 if (m_resource) |
| 22 m_resource->removeClient(this); | 22 m_resource->removeClient(this); |
| 23 } | 23 } |
| 24 void MockResourceClient::notifyFinished(Resource*) | 24 void MockResourceClient::notifyFinished(Resource*) |
| 25 { | 25 { |
| 26 ASSERT_FALSE(m_notifyFinishedCalled); | 26 ASSERT_FALSE(m_notifyFinishedCalled); |
| 27 m_notifyFinishedCalled = true; | 27 m_notifyFinishedCalled = true; |
| 28 } | 28 } |
| 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(RawPtr<ImageResource> resource) |
| 37 : MockResourceClient(resource) | 37 : MockResourceClient(resource) |
| 38 , m_imageChangedCount(0) | 38 , m_imageChangedCount(0) |
| 39 , m_imageNotifyFinishedCount(0) | 39 , m_imageNotifyFinishedCount(0) |
| 40 { | 40 { |
| 41 toImageResource(m_resource.get())->addObserver(this); | 41 toImageResource(m_resource.get())->addObserver(this); |
| 42 } | 42 } |
| 43 | 43 |
| 44 MockImageResourceClient::~MockImageResourceClient() | 44 MockImageResourceClient::~MockImageResourceClient() |
| 45 { | 45 { |
| 46 if (m_resource) | 46 if (m_resource) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool MockImageResourceClient::notifyFinishedCalled() const | 67 bool MockImageResourceClient::notifyFinishedCalled() const |
| 68 { | 68 { |
| 69 EXPECT_EQ(m_notifyFinishedCalled ? 1 : 0, m_imageNotifyFinishedCount); | 69 EXPECT_EQ(m_notifyFinishedCalled ? 1 : 0, m_imageNotifyFinishedCount); |
| 70 | 70 |
| 71 return m_notifyFinishedCalled; | 71 return m_notifyFinishedCalled; |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace blink | 74 } // namespace blink |
| OLD | NEW |