OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "core/css/cssom/CSSResourceValue.h" | |
6 | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 namespace blink { | |
10 | |
11 namespace { | |
12 | |
13 class FakeCSSResourceValue : public CSSResourceValue { | |
14 public: | |
15 ~FakeCSSResourceValue() { } | |
16 | |
17 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.
| |
18 { | |
19 m_resource = resource; | |
20 } | |
21 | |
22 FakeCSSResourceValue(KURL url, Resource::Type type) | |
23 { | |
24 m_resource = Resource::create(url, type); | |
25 } | |
26 | |
27 CSSValue* toCSSValue() const override { return nullptr; } | |
28 | |
29 DEFINE_INLINE_TRACE() | |
30 { | |
31 visitor->trace(m_resource); | |
32 CSSStyleValue::trace(visitor); | |
33 } | |
34 | |
35 Resource::Status status() const override { return m_resource->getStatus(); } | |
36 | |
37 private: | |
38 Member<Resource> m_resource; | |
39 }; | |
40 | |
41 class FakeResource : public Resource { | |
42 public: | |
43 FakeResource(Resource::Status status): Resource(ResourceRequest(), Resource: :Image, ResourceLoaderOptions()) | |
44 { | |
45 setStatus(status); | |
46 } | |
47 }; | |
48 | |
49 TEST(CSSResourceValueTest, CheckResourceFromURL) | |
50 { | |
51 FakeCSSResourceValue* test = new FakeCSSResourceValue(KURL(ParsedURLString, ""), Resource::Raw); | |
52 EXPECT_EQ(test->state(), "unloaded"); | |
53 } | |
54 | |
55 TEST(CSSResourceValueTest, TestStatus) | |
56 { | |
57 EXPECT_EQ((new FakeCSSResourceValue(new FakeResource(Resource::NotStarted))) ->state(), "unloaded"); | |
58 EXPECT_EQ((new FakeCSSResourceValue(new FakeResource(Resource::Pending)))->s tate(), "loading"); | |
59 EXPECT_EQ((new FakeCSSResourceValue(new FakeResource(Resource::Cached)))->st ate(), "loaded"); | |
60 EXPECT_EQ((new FakeCSSResourceValue(new FakeResource(Resource::LoadError)))- >state(), "error"); | |
61 EXPECT_EQ((new FakeCSSResourceValue(new FakeResource(Resource::DecodeError)) )->state(), "error"); | |
62 } | |
63 | |
64 } // namespace | |
65 | |
66 } // namespace blink | |
OLD | NEW |