| OLD | NEW |
| 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/dom/StyleEngine.h" | 5 #include "core/dom/StyleEngine.h" |
| 6 | 6 |
| 7 #include "core/css/StyleSheetContents.h" | 7 #include "core/css/StyleSheetContents.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/NodeComputedStyle.h" | 9 #include "core/dom/NodeComputedStyle.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| 11 #include "core/html/HTMLElement.h" | 11 #include "core/html/HTMLElement.h" |
| 12 #include "core/testing/DummyPageHolder.h" | 12 #include "core/testing/DummyPageHolder.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include <memory> |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 class StyleEngineTest : public ::testing::Test { | 18 class StyleEngineTest : public ::testing::Test { |
| 18 protected: | 19 protected: |
| 19 void SetUp() override; | 20 void SetUp() override; |
| 20 | 21 |
| 21 Document& document() { return m_dummyPageHolder->document(); } | 22 Document& document() { return m_dummyPageHolder->document(); } |
| 22 StyleEngine& styleEngine() { return document().styleEngine(); } | 23 StyleEngine& styleEngine() { return document().styleEngine(); } |
| 23 | 24 |
| 24 bool isDocumentStyleSheetCollectionClean() { return !styleEngine().shouldUpd
ateDocumentStyleSheetCollection(AnalyzedStyleUpdate); } | 25 bool isDocumentStyleSheetCollectionClean() { return !styleEngine().shouldUpd
ateDocumentStyleSheetCollection(AnalyzedStyleUpdate); } |
| 25 | 26 |
| 26 private: | 27 private: |
| 27 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 28 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 void StyleEngineTest::SetUp() | 31 void StyleEngineTest::SetUp() |
| 31 { | 32 { |
| 32 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | 33 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| 33 } | 34 } |
| 34 | 35 |
| 35 TEST_F(StyleEngineTest, DocumentDirtyAfterInject) | 36 TEST_F(StyleEngineTest, DocumentDirtyAfterInject) |
| 36 { | 37 { |
| 37 StyleSheetContents* parsedSheet = StyleSheetContents::create(CSSParserContex
t(document(), nullptr)); | 38 StyleSheetContents* parsedSheet = StyleSheetContents::create(CSSParserContex
t(document(), nullptr)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 60 document().view()->updateAllLifecyclePhases(); | 61 document().view()->updateAllLifecyclePhases(); |
| 61 | 62 |
| 62 unsigned afterCount = styleEngine().styleForElementCount(); | 63 unsigned afterCount = styleEngine().styleForElementCount(); |
| 63 EXPECT_EQ(1u, afterCount - beforeCount); | 64 EXPECT_EQ(1u, afterCount - beforeCount); |
| 64 | 65 |
| 65 ASSERT_TRUE(t1->computedStyle()); | 66 ASSERT_TRUE(t1->computedStyle()); |
| 66 EXPECT_EQ(makeRGB(0, 128, 0), t1->computedStyle()->visitedDependentColor(CSS
PropertyColor)); | 67 EXPECT_EQ(makeRGB(0, 128, 0), t1->computedStyle()->visitedDependentColor(CSS
PropertyColor)); |
| 67 } | 68 } |
| 68 | 69 |
| 69 } // namespace blink | 70 } // namespace blink |
| OLD | NEW |