Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSStyleImageValueTest.cpp

Issue 2903413002: Restructure type tracking in StyleValues to work better with new numeric types (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/css/cssom/CSSStyleImageValue.h" 5 #include "core/css/cssom/CSSStyleImageValue.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 namespace { 11 namespace {
12 12
13 class FakeCSSStyleImageValue : public CSSStyleImageValue { 13 class FakeCSSStyleImageValue : public CSSStyleImageValue {
14 public: 14 public:
15 FakeCSSStyleImageValue(CSSImageValue* image_value, 15 FakeCSSStyleImageValue(CSSImageValue* image_value,
16 bool cache_pending, 16 bool cache_pending,
17 LayoutSize layout_size) 17 LayoutSize layout_size)
18 : CSSStyleImageValue(image_value), 18 : CSSStyleImageValue(image_value),
19 cache_pending_(cache_pending), 19 cache_pending_(cache_pending),
20 layout_size_(layout_size) {} 20 layout_size_(layout_size) {}
21 21
22 bool IsCachePending() const override { return cache_pending_; } 22 bool IsCachePending() const override { return cache_pending_; }
23 LayoutSize ImageLayoutSize() const override { return layout_size_; } 23 LayoutSize ImageLayoutSize() const override { return layout_size_; }
24 24
25 CSSValue* ToCSSValue() const override { return nullptr; } 25 CSSValue* ToCSSValue() const override { return nullptr; }
26 StyleValueType GetType() const override { return kUnknown; } 26 StyleValueType GetType() const override { return kUnknownType; }
27 27
28 private: 28 private:
29 bool cache_pending_; 29 bool cache_pending_;
30 LayoutSize layout_size_; 30 LayoutSize layout_size_;
31 }; 31 };
32 32
33 } // namespace 33 } // namespace
34 34
35 TEST(CSSStyleImageValueTest, PendingCache) { 35 TEST(CSSStyleImageValueTest, PendingCache) {
36 FakeCSSStyleImageValue* style_image_value = new FakeCSSStyleImageValue( 36 FakeCSSStyleImageValue* style_image_value = new FakeCSSStyleImageValue(
37 CSSImageValue::Create(""), true, LayoutSize(100, 100)); 37 CSSImageValue::Create(""), true, LayoutSize(100, 100));
38 bool is_null; 38 bool is_null;
39 EXPECT_EQ(style_image_value->intrinsicWidth(is_null), 0); 39 EXPECT_EQ(style_image_value->intrinsicWidth(is_null), 0);
40 EXPECT_EQ(style_image_value->intrinsicHeight(is_null), 0); 40 EXPECT_EQ(style_image_value->intrinsicHeight(is_null), 0);
41 EXPECT_EQ(style_image_value->intrinsicRatio(is_null), 0); 41 EXPECT_EQ(style_image_value->intrinsicRatio(is_null), 0);
42 EXPECT_TRUE(is_null); 42 EXPECT_TRUE(is_null);
43 } 43 }
44 44
45 TEST(CSSStyleImageValueTest, ValidLoadedImage) { 45 TEST(CSSStyleImageValueTest, ValidLoadedImage) {
46 FakeCSSStyleImageValue* style_image_value = new FakeCSSStyleImageValue( 46 FakeCSSStyleImageValue* style_image_value = new FakeCSSStyleImageValue(
47 CSSImageValue::Create(""), false, LayoutSize(480, 120)); 47 CSSImageValue::Create(""), false, LayoutSize(480, 120));
48 bool is_null; 48 bool is_null;
49 EXPECT_EQ(style_image_value->intrinsicWidth(is_null), 480); 49 EXPECT_EQ(style_image_value->intrinsicWidth(is_null), 480);
50 EXPECT_EQ(style_image_value->intrinsicHeight(is_null), 120); 50 EXPECT_EQ(style_image_value->intrinsicHeight(is_null), 120);
51 EXPECT_EQ(style_image_value->intrinsicRatio(is_null), 4); 51 EXPECT_EQ(style_image_value->intrinsicRatio(is_null), 4);
52 EXPECT_FALSE(is_null); 52 EXPECT_FALSE(is_null);
53 } 53 }
54 54
55 } // namespace blink 55 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698