Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/cssom/CSSResourceValueTest.cpp |
| diff --git a/third_party/WebKit/Source/core/css/cssom/CSSResourceValueTest.cpp b/third_party/WebKit/Source/core/css/cssom/CSSResourceValueTest.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0312599db5aae7175117969c5dc39a69d60a3a6c |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/css/cssom/CSSResourceValueTest.cpp |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/css/cssom/CSSResourceValue.h" |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace blink { |
| + |
| +namespace { |
| + |
| +class FakeCSSResourceValue : public CSSResourceValue { |
| +public: |
| + ~FakeCSSResourceValue() { } |
| + |
| + FakeCSSResourceValue(Resource* resource) |
|
meade_UTC10
2016/08/02 00:58:14
Since you've made CSSResourceValue not store a res
anthonyhkf
2016/08/02 01:16:15
Done.
|
| + { |
| + m_resource = resource; |
| + } |
| + |
| + FakeCSSResourceValue(KURL url, Resource::Type type) |
| + { |
| + m_resource = Resource::create(url, type); |
| + } |
| + |
| + CSSValue* toCSSValue() const override { return nullptr; } |
| + |
| + DEFINE_INLINE_TRACE() |
| + { |
| + visitor->trace(m_resource); |
| + CSSStyleValue::trace(visitor); |
| + } |
| + |
| + Resource::Status status() const override { return m_resource->getStatus(); } |
| + |
| +private: |
| + Member<Resource> m_resource; |
| +}; |
| + |
| +class FakeResource : public Resource { |
| +public: |
| + FakeResource(Resource::Status status): Resource(ResourceRequest(), Resource::Image, ResourceLoaderOptions()) |
| + { |
| + setStatus(status); |
| + } |
| +}; |
| + |
| +TEST(CSSResourceValueTest, CheckResourceFromURL) |
| +{ |
| + FakeCSSResourceValue* test = new FakeCSSResourceValue(KURL(ParsedURLString, ""), Resource::Raw); |
| + EXPECT_EQ(test->state(), "unloaded"); |
| +} |
| + |
| +TEST(CSSResourceValueTest, TestStatus) |
| +{ |
| + EXPECT_EQ((new FakeCSSResourceValue(new FakeResource(Resource::NotStarted)))->state(), "unloaded"); |
| + EXPECT_EQ((new FakeCSSResourceValue(new FakeResource(Resource::Pending)))->state(), "loading"); |
| + EXPECT_EQ((new FakeCSSResourceValue(new FakeResource(Resource::Cached)))->state(), "loaded"); |
| + EXPECT_EQ((new FakeCSSResourceValue(new FakeResource(Resource::LoadError)))->state(), "error"); |
| + EXPECT_EQ((new FakeCSSResourceValue(new FakeResource(Resource::DecodeError)))->state(), "error"); |
| +} |
| + |
| +} // namespace |
| + |
| +} // namespace blink |