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

Side by Side Diff: third_party/WebKit/Source/core/editing/GranularityStrategyTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. 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 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 "bindings/core/v8/ExceptionStatePlaceholder.h" 5 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
6 #include "core/dom/Document.h" 6 #include "core/dom/Document.h"
7 #include "core/dom/Element.h" 7 #include "core/dom/Element.h"
8 #include "core/dom/Text.h" 8 #include "core/dom/Text.h"
9 #include "core/editing/FrameSelection.h" 9 #include "core/editing/FrameSelection.h"
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
11 #include "core/frame/Settings.h" 11 #include "core/frame/Settings.h"
12 #include "core/html/HTMLBodyElement.h" 12 #include "core/html/HTMLBodyElement.h"
13 #include "core/html/HTMLDocument.h" 13 #include "core/html/HTMLDocument.h"
14 #include "core/html/HTMLSpanElement.h" 14 #include "core/html/HTMLSpanElement.h"
15 #include "core/testing/DummyPageHolder.h" 15 #include "core/testing/DummyPageHolder.h"
16 #include "platform/heap/Handle.h" 16 #include "platform/heap/Handle.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "wtf/OwnPtr.h"
19 #include "wtf/PassRefPtr.h" 18 #include "wtf/PassRefPtr.h"
20 #include "wtf/RefPtr.h" 19 #include "wtf/RefPtr.h"
21 #include "wtf/StdLibExtras.h" 20 #include "wtf/StdLibExtras.h"
21 #include <memory>
22 22
23 namespace blink { 23 namespace blink {
24 24
25 #define EXPECT_EQ_SELECTED_TEXT(text) \ 25 #define EXPECT_EQ_SELECTED_TEXT(text) \
26 EXPECT_EQ(text, WebString(selection().selectedText()).utf8()) 26 EXPECT_EQ(text, WebString(selection().selectedText()).utf8())
27 27
28 IntPoint visiblePositionToContentsPoint(const VisiblePosition& pos) 28 IntPoint visiblePositionToContentsPoint(const VisiblePosition& pos)
29 { 29 {
30 IntPoint result = absoluteCaretBoundsOf(pos).minXMaxYCorner(); 30 IntPoint result = absoluteCaretBoundsOf(pos).minXMaxYCorner();
31 // Need to move the point at least by 1 - caret's minXMaxYCorner is not 31 // Need to move the point at least by 1 - caret's minXMaxYCorner is not
(...skipping 30 matching lines...) Expand all
62 void testDirectionShrink(); 62 void testDirectionShrink();
63 void testDirectionSwitchSide(); 63 void testDirectionSwitchSide();
64 64
65 // Pixel coordinates of the positions for each letter within the text being tested. 65 // Pixel coordinates of the positions for each letter within the text being tested.
66 Vector<IntPoint> m_letterPos; 66 Vector<IntPoint> m_letterPos;
67 // Pixel coordinates of the middles of the words in the text being tested. 67 // Pixel coordinates of the middles of the words in the text being tested.
68 // (y coordinate is based on y coordinates of m_letterPos) 68 // (y coordinate is based on y coordinates of m_letterPos)
69 Vector<IntPoint> m_wordMiddles; 69 Vector<IntPoint> m_wordMiddles;
70 70
71 private: 71 private:
72 OwnPtr<DummyPageHolder> m_dummyPageHolder; 72 std::unique_ptr<DummyPageHolder> m_dummyPageHolder;
73 Persistent<HTMLDocument> m_document; 73 Persistent<HTMLDocument> m_document;
74 }; 74 };
75 75
76 void GranularityStrategyTest::SetUp() 76 void GranularityStrategyTest::SetUp()
77 { 77 {
78 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); 78 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
79 m_document = toHTMLDocument(&m_dummyPageHolder->document()); 79 m_document = toHTMLDocument(&m_dummyPageHolder->document());
80 DCHECK(m_document); 80 DCHECK(m_document);
81 dummyPageHolder().frame().settings()->setDefaultFontSize(12); 81 dummyPageHolder().frame().settings()->setDefaultFontSize(12);
82 dummyPageHolder().frame().settings()->setSelectionStrategy(SelectionStrategy ::Direction); 82 dummyPageHolder().frame().settings()->setSelectionStrategy(SelectionStrategy ::Direction);
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 653
654 // "ab cd efghijkl ^mnopqr |>stuvwi inm," (^ means base and | means extent, 654 // "ab cd efghijkl ^mnopqr |>stuvwi inm," (^ means base and | means extent,
655 // > means end). 655 // > means end).
656 selection().setSelection(VisibleSelection(Position(text, 15), Position(text, 22))); 656 selection().setSelection(VisibleSelection(Position(text, 15), Position(text, 22)));
657 EXPECT_EQ_SELECTED_TEXT("mnopqr "); 657 EXPECT_EQ_SELECTED_TEXT("mnopqr ");
658 selection().moveRangeSelectionExtent(m_wordMiddles[4]); 658 selection().moveRangeSelectionExtent(m_wordMiddles[4]);
659 EXPECT_EQ_SELECTED_TEXT("mnopqr iiin"); 659 EXPECT_EQ_SELECTED_TEXT("mnopqr iiin");
660 } 660 }
661 661
662 } // namespace blink 662 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698