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

Side by Side Diff: third_party/WebKit/Source/core/dom/NthIndexCacheTest.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/NthIndexCache.h" 5 #include "core/dom/NthIndexCache.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/html/HTMLElement.h" 8 #include "core/html/HTMLElement.h"
9 #include "core/testing/DummyPageHolder.h" 9 #include "core/testing/DummyPageHolder.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include <memory>
12 11
13 namespace blink { 12 namespace blink {
14 13
15 class NthIndexCacheTest : public ::testing::Test { 14 class NthIndexCacheTest : public ::testing::Test {
16 protected: 15 protected:
17 void SetUp() override; 16 void SetUp() override;
18 17
19 Document& document() const { return m_dummyPageHolder->document(); } 18 Document& document() const { return m_dummyPageHolder->document(); }
20 void setHtmlInnerHTML(const char* htmlContent); 19 void setHtmlInnerHTML(const char* htmlContent);
21 20
22 private: 21 private:
23 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; 22 OwnPtr<DummyPageHolder> m_dummyPageHolder;
24 }; 23 };
25 24
26 void NthIndexCacheTest::SetUp() 25 void NthIndexCacheTest::SetUp()
27 { 26 {
28 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); 27 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
29 } 28 }
30 29
31 TEST_F(NthIndexCacheTest, NthIndex) 30 TEST_F(NthIndexCacheTest, NthIndex)
32 { 31 {
33 document().documentElement()->setInnerHTML("<body>" 32 document().documentElement()->setInnerHTML("<body>"
34 "<span id=first></span><span></span><span></span><span></span><span></sp an>" 33 "<span id=first></span><span></span><span></span><span></span><span></sp an>"
35 "<span></span><span></span><span></span><span></span><span></span>" 34 "<span></span><span></span><span></span><span></span><span></span>"
36 "Text does not count" 35 "Text does not count"
37 "<span id=nth-last-child></span>" 36 "<span id=nth-last-child></span>"
38 "<span id=nth-child></span>" 37 "<span id=nth-child></span>"
39 "<span></span><span></span><span></span><span></span><span></span>" 38 "<span></span><span></span><span></span><span></span><span></span>"
40 "<span></span><span></span><span></span><span></span><span id=last></spa n>" 39 "<span></span><span></span><span></span><span></span><span id=last></spa n>"
41 "</body>", ASSERT_NO_EXCEPTION); 40 "</body>", ASSERT_NO_EXCEPTION);
42 41
43 NthIndexCache nthIndexCache(document()); 42 NthIndexCache nthIndexCache(document());
44 43
45 EXPECT_EQ(nthIndexCache.nthChildIndex(*document().getElementById("nth-child" )), 12U); 44 EXPECT_EQ(nthIndexCache.nthChildIndex(*document().getElementById("nth-child" )), 12U);
46 EXPECT_EQ(nthIndexCache.nthLastChildIndex(*document().getElementById("nth-la st-child")), 12U); 45 EXPECT_EQ(nthIndexCache.nthLastChildIndex(*document().getElementById("nth-la st-child")), 12U);
47 } 46 }
48 47
49 } // namespace blink 48 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/NodeRareData.h ('k') | third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698