OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
6 #include "core/layout/LayoutTheme.h" | 6 #include "core/layout/LayoutTheme.h" |
7 | 7 |
8 #include "core/dom/NodeLayoutStyle.h" | 8 #include "core/dom/NodeLayoutStyle.h" |
9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
10 #include "core/html/HTMLDocument.h" | 10 #include "core/html/HTMLDocument.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 { | 54 { |
55 return element->layoutStyle()->outlineStyle(); | 55 return element->layoutStyle()->outlineStyle(); |
56 } | 56 } |
57 | 57 |
58 TEST_F(LayoutThemeTest, ChangeFocusRingColor) | 58 TEST_F(LayoutThemeTest, ChangeFocusRingColor) |
59 { | 59 { |
60 setHtmlInnerHTML("<span id=span tabIndex=0>Span</span>"); | 60 setHtmlInnerHTML("<span id=span tabIndex=0>Span</span>"); |
61 | 61 |
62 Element* span = document().getElementById(AtomicString("span")); | 62 Element* span = document().getElementById(AtomicString("span")); |
63 EXPECT_NE(nullptr, span); | 63 EXPECT_NE(nullptr, span); |
64 EXPECT_NE(nullptr, span->renderer()); | 64 EXPECT_NE(nullptr, span->layoutObject()); |
65 | 65 |
66 Color customColor = makeRGB(123, 145, 167); | 66 Color customColor = makeRGB(123, 145, 167); |
67 | 67 |
68 // Checking unfocused style. | 68 // Checking unfocused style. |
69 EXPECT_EQ(BNONE, outlineStyle(span)); | 69 EXPECT_EQ(BNONE, outlineStyle(span)); |
70 EXPECT_NE(customColor, outlineColor(span)); | 70 EXPECT_NE(customColor, outlineColor(span)); |
71 | 71 |
72 // Do focus. | 72 // Do focus. |
73 document().page()->focusController().setActive(true); | 73 document().page()->focusController().setActive(true); |
74 document().page()->focusController().setFocused(true); | 74 document().page()->focusController().setFocused(true); |
75 span->focus(); | 75 span->focus(); |
76 document().view()->updateLayoutAndStyleIfNeededRecursive(); | 76 document().view()->updateLayoutAndStyleIfNeededRecursive(); |
77 | 77 |
78 // Checking focused style. | 78 // Checking focused style. |
79 EXPECT_NE(BNONE, outlineStyle(span)); | 79 EXPECT_NE(BNONE, outlineStyle(span)); |
80 EXPECT_NE(customColor, outlineColor(span)); | 80 EXPECT_NE(customColor, outlineColor(span)); |
81 | 81 |
82 // Change focus ring color. | 82 // Change focus ring color. |
83 LayoutTheme::theme().setCustomFocusRingColor(customColor); | 83 LayoutTheme::theme().setCustomFocusRingColor(customColor); |
84 Page::platformColorsChanged(); | 84 Page::platformColorsChanged(); |
85 document().view()->updateLayoutAndStyleIfNeededRecursive(); | 85 document().view()->updateLayoutAndStyleIfNeededRecursive(); |
86 | 86 |
87 // Check that the focus ring color is updated. | 87 // Check that the focus ring color is updated. |
88 EXPECT_NE(BNONE, outlineStyle(span)); | 88 EXPECT_NE(BNONE, outlineStyle(span)); |
89 EXPECT_EQ(customColor, outlineColor(span)); | 89 EXPECT_EQ(customColor, outlineColor(span)); |
90 } | 90 } |
91 | 91 |
92 } | 92 } |
OLD | NEW |