Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / core / fetch / MockImageResourceClient.cpp
blob6c15a45a5d8e0d3ffd350d7e1856d51b0dc0e410
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
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "core/fetch/MockImageResourceClient.h"
8 #include "core/fetch/ImageResource.h"
9 #include "core/fetch/ResourcePtr.h"
11 #include <gtest/gtest.h>
13 namespace blink {
15 MockImageResourceClient::MockImageResourceClient(const ResourcePtr<Resource>& resource)
16 : m_resource(resource.get())
17 , m_imageChangedCount(0)
18 , m_notifyFinishedCalled(false)
20 m_resource->addClient(this);
23 MockImageResourceClient::~MockImageResourceClient()
25 if (m_resource)
26 m_resource->removeClient(this);
29 void MockImageResourceClient::notifyFinished(Resource*)
31 ASSERT_FALSE(m_notifyFinishedCalled);
32 m_notifyFinishedCalled = true;
35 void MockImageResourceClient::removeAsClient()
37 m_resource->removeClient(this);
38 m_resource = nullptr;
41 } // namespace blink