OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MockImageResourceClient_h | 5 #ifndef MockImageResourceObserver_h |
6 #define MockImageResourceClient_h | 6 #define MockImageResourceObserver_h |
7 | 7 |
8 #include "core/fetch/MockResourceClient.h" | |
9 #include "core/loader/resource/ImageResource.h" | 8 #include "core/loader/resource/ImageResource.h" |
10 #include "core/loader/resource/ImageResourceContent.h" | 9 #include "core/loader/resource/ImageResourceContent.h" |
11 #include "core/loader/resource/ImageResourceObserver.h" | 10 #include "core/loader/resource/ImageResourceObserver.h" |
| 11 #include <memory> |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class MockImageResourceClient final : public MockResourceClient, | 15 class MockImageResourceObserver final : public ImageResourceObserver { |
16 public ImageResourceObserver { | |
17 public: | 16 public: |
18 explicit MockImageResourceClient(ImageResource*); | 17 static std::unique_ptr<MockImageResourceObserver> create( |
19 ~MockImageResourceClient() override; | 18 ImageResourceContent* content) { |
| 19 return WTF::wrapUnique(new MockImageResourceObserver(content)); |
| 20 } |
| 21 ~MockImageResourceObserver() override; |
20 | 22 |
21 void imageNotifyFinished(ImageResourceContent*) override; | 23 void removeAsObserver(); |
22 void imageChanged(ImageResourceContent*, const IntRect*) override; | |
23 | |
24 String debugName() const override { return "MockImageResourceClient"; } | |
25 | |
26 bool notifyFinishedCalled() const override; | |
27 | |
28 void removeAsClient() override; | |
29 void dispose() override; | |
30 | 24 |
31 int imageChangedCount() const { return m_imageChangedCount; } | 25 int imageChangedCount() const { return m_imageChangedCount; } |
32 int imageNotifyFinishedCount() const { return m_imageNotifyFinishedCount; } | 26 bool imageNotifyFinishedCalled() const; |
33 | 27 |
34 size_t encodedSizeOnLastImageChanged() const { | 28 int imageWidthOnLastImageChanged() const { |
35 return m_encodedSizeOnLastImageChanged; | 29 return m_imageWidthOnLastImageChanged; |
36 } | 30 } |
37 size_t encodedSizeOnImageNotifyFinished() const { | 31 int imageWidthOnImageNotifyFinished() const { |
38 return m_encodedSizeOnImageNotifyFinished; | 32 return m_imageWidthOnImageNotifyFinished; |
39 } | 33 } |
40 | 34 |
41 private: | 35 private: |
| 36 explicit MockImageResourceObserver(ImageResourceContent*); |
| 37 |
| 38 // ImageResourceObserver overrides. |
| 39 void imageNotifyFinished(ImageResourceContent*) override; |
| 40 void imageChanged(ImageResourceContent*, const IntRect*) override; |
| 41 String debugName() const override { return "MockImageResourceObserver"; } |
| 42 |
| 43 Persistent<ImageResourceContent> m_content; |
42 int m_imageChangedCount; | 44 int m_imageChangedCount; |
43 size_t m_encodedSizeOnLastImageChanged; | 45 int m_imageWidthOnLastImageChanged; |
44 int m_imageNotifyFinishedCount; | 46 int m_imageNotifyFinishedCount; |
45 size_t m_encodedSizeOnImageNotifyFinished; | 47 int m_imageWidthOnImageNotifyFinished; |
46 }; | 48 }; |
47 | 49 |
48 } // namespace blink | 50 } // namespace blink |
49 | 51 |
50 #endif // MockImageResourceClient_h | 52 #endif // MockImageResourceObserver_h |
OLD | NEW |