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 #include "core/loader/resource/MockFontResourceClient.h" | 5 #include "core/loader/resource/MockFontResourceClient.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 MockFontResourceClient::MockFontResourceClient(Resource* resource) | 11 MockFontResourceClient::MockFontResourceClient(Resource* resource) |
12 : m_resource(resource), | 12 : m_resource(resource), |
13 m_fontLoadShortLimitExceededCalled(false), | 13 m_fontLoadShortLimitExceededCalled(false), |
14 m_fontLoadLongLimitExceededCalled(false) { | 14 m_fontLoadLongLimitExceededCalled(false) { |
15 ThreadState::current()->registerPreFinalizer(this); | |
16 m_resource->addClient(this); | 15 m_resource->addClient(this); |
17 } | 16 } |
18 | 17 |
19 MockFontResourceClient::~MockFontResourceClient() {} | 18 MockFontResourceClient::~MockFontResourceClient() {} |
20 | 19 |
21 void MockFontResourceClient::fontLoadShortLimitExceeded(FontResource*) { | 20 void MockFontResourceClient::fontLoadShortLimitExceeded(FontResource*) { |
22 ASSERT_FALSE(m_fontLoadShortLimitExceededCalled); | 21 ASSERT_FALSE(m_fontLoadShortLimitExceededCalled); |
23 ASSERT_FALSE(m_fontLoadLongLimitExceededCalled); | 22 ASSERT_FALSE(m_fontLoadLongLimitExceededCalled); |
24 m_fontLoadShortLimitExceededCalled = true; | 23 m_fontLoadShortLimitExceededCalled = true; |
25 } | 24 } |
26 | 25 |
27 void MockFontResourceClient::fontLoadLongLimitExceeded(FontResource*) { | 26 void MockFontResourceClient::fontLoadLongLimitExceeded(FontResource*) { |
28 ASSERT_TRUE(m_fontLoadShortLimitExceededCalled); | 27 ASSERT_TRUE(m_fontLoadShortLimitExceededCalled); |
29 ASSERT_FALSE(m_fontLoadLongLimitExceededCalled); | 28 ASSERT_FALSE(m_fontLoadLongLimitExceededCalled); |
30 m_fontLoadLongLimitExceededCalled = true; | 29 m_fontLoadLongLimitExceededCalled = true; |
31 } | 30 } |
32 | 31 |
33 void MockFontResourceClient::dispose() { | 32 void MockFontResourceClient::dispose() { |
34 if (m_resource) { | 33 if (m_resource) { |
35 m_resource->removeClient(this); | 34 m_resource->removeClient(this); |
36 m_resource = nullptr; | 35 m_resource = nullptr; |
37 } | 36 } |
38 } | 37 } |
39 | 38 |
40 } // namespace blink | 39 } // namespace blink |
OLD | NEW |