Chromium Code Reviews| Index: third_party/WebKit/Source/core/fetch/ResourceTest.cpp |
| diff --git a/third_party/WebKit/Source/core/fetch/ResourceTest.cpp b/third_party/WebKit/Source/core/fetch/ResourceTest.cpp |
| index f0a77a9c9d097b8b299f2a5cafc8b616b953c9bc..b9a547e55a4f369f743640bc7ac5688cd7f6f919 100644 |
| --- a/third_party/WebKit/Source/core/fetch/ResourceTest.cpp |
| +++ b/third_party/WebKit/Source/core/fetch/ResourceTest.cpp |
| @@ -51,6 +51,25 @@ void createTestResourceAndSetCachedMetadata(const ResourceResponse& response) { |
| return; |
| } |
| +class TestProhibitAddRemoveClientResource : public Resource { |
|
hiroshige
2016/10/05 08:37:25
optional: I'd like to avoid creating new test-only
hiroshige
2016/10/05 08:37:25
Add "final".
Shao-Chuan Lee
2016/10/05 09:04:53
Done.
|
| + public: |
| + static TestProhibitAddRemoveClientResource* create() { |
| + return new TestProhibitAddRemoveClientResource( |
| + ResourceRequest(), Resource::Raw, ResourceLoaderOptions()); |
|
kouhei (in TOK)
2016/10/05 08:29:42
We can just pass these to Resource ctor in line 70
Shao-Chuan Lee
2016/10/05 09:04:53
Done.
|
| + } |
| + void test() { |
|
kouhei (in TOK)
2016/10/05 08:29:42
We should have this logic in line 112 func.
Shao-Chuan Lee
2016/10/05 09:04:53
Moving EXPECT_DEATH()s to test function.
|
| + ProhibitAddRemoveClientInScope prohibitAddRemoveClient(this); |
| + EXPECT_DEATH(addClient(nullptr), "!m_isAddRemoveClientProhibited"); |
|
hiroshige
2016/10/05 08:37:25
addClient(nullptr) is invalid even outside Prohibi
Shao-Chuan Lee
2016/10/05 08:51:20
Since MockResourceClient calls addClient in ctor,
Shao-Chuan Lee
2016/10/05 09:04:53
Done.
|
| + EXPECT_DEATH(removeClient(nullptr), "!m_isAddRemoveClientProhibited"); |
|
hiroshige
2016/10/05 08:37:26
ditto.
Shao-Chuan Lee
2016/10/05 09:04:53
Done.
|
| + } |
| + |
| + private: |
| + TestProhibitAddRemoveClientResource(const ResourceRequest& request, |
|
hiroshige
2016/10/05 08:37:25
We can remove these parameters as they receive onl
Shao-Chuan Lee
2016/10/05 09:04:53
Done.
|
| + Type type, |
| + const ResourceLoaderOptions& options) |
| + : Resource(request, type, options) {} |
| +}; |
| + |
| } // anonymous namespace |
| TEST(ResourceTest, SetCachedMetadata_SendsMetadataToPlatform) { |
| @@ -89,4 +108,8 @@ TEST(ResourceTest, RevalidateWithFragment) { |
| resource->responseReceived(revalidatingResponse, nullptr); |
| } |
| +TEST(ResourceTest, ProhibitAddRemoveClientInScope) { |
| + TestProhibitAddRemoveClientResource::create()->test(); |
| +} |
| + |
| } // namespace blink |