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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTextFormControlElementTest.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 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 "core/html/HTMLTextFormControlElement.h" 5 #include "core/html/HTMLTextFormControlElement.h"
6 6
7 #include "core/dom/Text.h" 7 #include "core/dom/Text.h"
8 #include "core/editing/FrameSelection.h" 8 #include "core/editing/FrameSelection.h"
9 #include "core/editing/Position.h" 9 #include "core/editing/Position.h"
10 #include "core/editing/VisibleSelection.h" 10 #include "core/editing/VisibleSelection.h"
11 #include "core/editing/VisibleUnits.h" 11 #include "core/editing/VisibleUnits.h"
12 #include "core/editing/spellcheck/SpellChecker.h" 12 #include "core/editing/spellcheck/SpellChecker.h"
13 #include "core/frame/FrameView.h" 13 #include "core/frame/FrameView.h"
14 #include "core/html/HTMLBRElement.h" 14 #include "core/html/HTMLBRElement.h"
15 #include "core/html/HTMLDocument.h" 15 #include "core/html/HTMLDocument.h"
16 #include "core/html/HTMLInputElement.h" 16 #include "core/html/HTMLInputElement.h"
17 #include "core/html/HTMLTextAreaElement.h" 17 #include "core/html/HTMLTextAreaElement.h"
18 #include "core/layout/LayoutTreeAsText.h" 18 #include "core/layout/LayoutTreeAsText.h"
19 #include "core/loader/EmptyClients.h" 19 #include "core/loader/EmptyClients.h"
20 #include "core/page/SpellCheckerClient.h" 20 #include "core/page/SpellCheckerClient.h"
21 #include "core/testing/DummyPageHolder.h" 21 #include "core/testing/DummyPageHolder.h"
22 #include "platform/testing/UnitTestHelpers.h" 22 #include "platform/testing/UnitTestHelpers.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "wtf/PtrUtil.h" 24 #include "wtf/OwnPtr.h"
25 #include <memory>
26 25
27 namespace blink { 26 namespace blink {
28 27
29 class HTMLTextFormControlElementTest : public ::testing::Test { 28 class HTMLTextFormControlElementTest : public ::testing::Test {
30 protected: 29 protected:
31 void SetUp() override; 30 void SetUp() override;
32 31
33 DummyPageHolder& page() const { return *m_dummyPageHolder; } 32 DummyPageHolder& page() const { return *m_dummyPageHolder; }
34 HTMLDocument& document() const { return *m_document; } 33 HTMLDocument& document() const { return *m_document; }
35 HTMLTextFormControlElement& textControl() const { return *m_textControl; } 34 HTMLTextFormControlElement& textControl() const { return *m_textControl; }
36 HTMLInputElement& input() const { return *m_input; } 35 HTMLInputElement& input() const { return *m_input; }
37 36
38 int layoutCount() const { return page().frameView().layoutCount(); } 37 int layoutCount() const { return page().frameView().layoutCount(); }
39 void forceLayoutFlag(); 38 void forceLayoutFlag();
40 39
41 private: 40 private:
42 std::unique_ptr<SpellCheckerClient> m_spellCheckerClient; 41 OwnPtr<SpellCheckerClient> m_spellCheckerClient;
43 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; 42 OwnPtr<DummyPageHolder> m_dummyPageHolder;
44 43
45 Persistent<HTMLDocument> m_document; 44 Persistent<HTMLDocument> m_document;
46 Persistent<HTMLTextFormControlElement> m_textControl; 45 Persistent<HTMLTextFormControlElement> m_textControl;
47 Persistent<HTMLInputElement> m_input; 46 Persistent<HTMLInputElement> m_input;
48 }; 47 };
49 48
50 class DummySpellCheckerClient : public EmptySpellCheckerClient { 49 class DummySpellCheckerClient : public EmptySpellCheckerClient {
51 public: 50 public:
52 virtual ~DummySpellCheckerClient() { } 51 virtual ~DummySpellCheckerClient() { }
53 52
54 bool isContinuousSpellCheckingEnabled() override { return true; } 53 bool isContinuousSpellCheckingEnabled() override { return true; }
55 54
56 TextCheckerClient& textChecker() override { return m_emptyTextCheckerClient; } 55 TextCheckerClient& textChecker() override { return m_emptyTextCheckerClient; }
57 56
58 private: 57 private:
59 EmptyTextCheckerClient m_emptyTextCheckerClient; 58 EmptyTextCheckerClient m_emptyTextCheckerClient;
60 }; 59 };
61 60
62 void HTMLTextFormControlElementTest::SetUp() 61 void HTMLTextFormControlElementTest::SetUp()
63 { 62 {
64 Page::PageClients pageClients; 63 Page::PageClients pageClients;
65 fillWithEmptyClients(pageClients); 64 fillWithEmptyClients(pageClients);
66 m_spellCheckerClient = wrapUnique(new DummySpellCheckerClient); 65 m_spellCheckerClient = adoptPtr(new DummySpellCheckerClient);
67 pageClients.spellCheckerClient = m_spellCheckerClient.get(); 66 pageClients.spellCheckerClient = m_spellCheckerClient.get();
68 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients) ; 67 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients) ;
69 68
70 m_document = toHTMLDocument(&m_dummyPageHolder->document()); 69 m_document = toHTMLDocument(&m_dummyPageHolder->document());
71 m_document->documentElement()->setInnerHTML("<body><textarea id=textarea></t extarea><input id=input /></body>", ASSERT_NO_EXCEPTION); 70 m_document->documentElement()->setInnerHTML("<body><textarea id=textarea></t extarea><input id=input /></body>", ASSERT_NO_EXCEPTION);
72 m_document->view()->updateAllLifecyclePhases(); 71 m_document->view()->updateAllLifecyclePhases();
73 m_textControl = toHTMLTextFormControlElement(m_document->getElementById("tex tarea")); 72 m_textControl = toHTMLTextFormControlElement(m_document->getElementById("tex tarea"));
74 m_textControl->focus(); 73 m_textControl->focus();
75 m_input = toHTMLInputElement(m_document->getElementById("input")); 74 m_input = toHTMLInputElement(m_document->getElementById("input"));
76 } 75 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 ASSERT_EQ(3, input->selectionStart()); 208 ASSERT_EQ(3, input->selectionStart());
210 209
211 Persistent<SpellChecker> spellChecker(SpellChecker::create(page().frame())); 210 Persistent<SpellChecker> spellChecker(SpellChecker::create(page().frame()));
212 forceLayoutFlag(); 211 forceLayoutFlag();
213 int startCount = layoutCount(); 212 int startCount = layoutCount();
214 spellChecker->respondToChangedSelection(oldSelection, FrameSelection::CloseT yping | FrameSelection::ClearTypingStyle); 213 spellChecker->respondToChangedSelection(oldSelection, FrameSelection::CloseT yping | FrameSelection::ClearTypingStyle);
215 EXPECT_EQ(startCount, layoutCount()); 214 EXPECT_EQ(startCount, layoutCount());
216 } 215 }
217 216
218 } // namespace blink 217 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698