Commit 6203ef45 authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

Fix flaky paint property test that relied on static state

PaintPropertyNodeTest.InitialStateAndReset had an expectation that the
initial root paint property state was changed. This could fail if the
test was run after another test that modified the root node's state.
This patch initializes the root node state to be unchanged.

Bug: 879017
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: If30731871ac8bffb66f8b3a387510e7e2d6fea56
Reviewed-on: https://chromium-review.googlesource.com/1196824Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587733}
parent d1a600a1
...@@ -91,7 +91,8 @@ class PaintPropertyNode : public RefCounted<NodeType> { ...@@ -91,7 +91,8 @@ class PaintPropertyNode : public RefCounted<NodeType> {
#endif #endif
protected: protected:
PaintPropertyNode(const NodeType* parent) : parent_(parent) {} PaintPropertyNode(const NodeType* parent)
: parent_(parent), changed_(!!parent) {}
bool SetParent(const NodeType* parent) { bool SetParent(const NodeType* parent) {
DCHECK(!IsRoot()); DCHECK(!IsRoot());
...@@ -104,14 +105,17 @@ class PaintPropertyNode : public RefCounted<NodeType> { ...@@ -104,14 +105,17 @@ class PaintPropertyNode : public RefCounted<NodeType> {
return true; return true;
} }
void SetChanged() { changed_ = true; } void SetChanged() {
DCHECK(!IsRoot());
changed_ = true;
}
bool NodeChanged() const { return changed_; } bool NodeChanged() const { return changed_; }
private: private:
friend class PaintPropertyNodeTest; friend class PaintPropertyNodeTest;
scoped_refptr<const NodeType> parent_; scoped_refptr<const NodeType> parent_;
mutable bool changed_ = true; mutable bool changed_;
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
String debug_name_; String debug_name_;
......
...@@ -84,7 +84,7 @@ class PaintPropertyNodeTest : public testing::Test { ...@@ -84,7 +84,7 @@ class PaintPropertyNodeTest : public testing::Test {
template <typename NodeType> template <typename NodeType>
void ExpectInitialState(const Tree<NodeType>& tree) { void ExpectInitialState(const Tree<NodeType>& tree) {
EXPECT_TRUE(tree.root->NodeChanged()); EXPECT_FALSE(tree.root->NodeChanged());
EXPECT_TRUE(tree.ancestor->NodeChanged()); EXPECT_TRUE(tree.ancestor->NodeChanged());
EXPECT_TRUE(tree.child1->NodeChanged()); EXPECT_TRUE(tree.child1->NodeChanged());
EXPECT_TRUE(tree.child2->NodeChanged()); EXPECT_TRUE(tree.child2->NodeChanged());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment