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

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

Issue 1171323003: Fix unit test style in core/{dom,editing,html}/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: whitespace fix Created 5 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 6
7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
11 #include "core/dom/Text.h" 11 #include "core/dom/Text.h"
12 #include "core/editing/FrameSelection.h" 12 #include "core/editing/FrameSelection.h"
13 #include "core/frame/FrameView.h" 13 #include "core/frame/FrameView.h"
14 #include "core/frame/Settings.h" 14 #include "core/frame/Settings.h"
15 #include "core/html/HTMLBodyElement.h" 15 #include "core/html/HTMLBodyElement.h"
16 #include "core/html/HTMLDocument.h" 16 #include "core/html/HTMLDocument.h"
17 #include "core/testing/DummyPageHolder.h" 17 #include "core/testing/DummyPageHolder.h"
18 #include "wtf/OwnPtr.h" 18 #include "wtf/OwnPtr.h"
19 #include "wtf/PassRefPtr.h" 19 #include "wtf/PassRefPtr.h"
20 #include "wtf/RefPtr.h" 20 #include "wtf/RefPtr.h"
21 #include "wtf/StdLibExtras.h" 21 #include "wtf/StdLibExtras.h"
22 #include "wtf/testing/WTFTestHelpers.h" 22 #include "wtf/testing/WTFTestHelpers.h"
23 #include <gtest/gtest.h> 23 #include <gtest/gtest.h>
24 24
25 using namespace blink; 25 namespace blink {
26
27 namespace {
28 26
29 #define EXPECT_EQ_SELECTED_TEXT(text) \ 27 #define EXPECT_EQ_SELECTED_TEXT(text) \
30 EXPECT_EQ(text, WebString(selection().selectedText()).utf8()) 28 EXPECT_EQ(text, WebString(selection().selectedText()).utf8())
31 29
32 IntPoint visiblePositionToContentsPoint(const VisiblePosition& pos) 30 IntPoint visiblePositionToContentsPoint(const VisiblePosition& pos)
33 { 31 {
34 IntPoint result = pos.absoluteCaretBounds().minXMaxYCorner(); 32 IntPoint result = pos.absoluteCaretBounds().minXMaxYCorner();
35 // Need to move the point at least by 1 - caret's minXMaxYCorner is not 33 // Need to move the point at least by 1 - caret's minXMaxYCorner is not
36 // evaluated to the same line as the text by hit testing. 34 // evaluated to the same line as the text by hit testing.
37 result.move(0, -1); 35 result.move(0, -1);
38 return result; 36 return result;
39 } 37 }
40 38
41 class GranularityStrategyTest : public ::testing::Test { 39 class GranularityStrategyTest : public ::testing::Test {
42 protected: 40 protected:
43 virtual void SetUp() override; 41 void SetUp() override;
44 42
45 DummyPageHolder& dummyPageHolder() const { return *m_dummyPageHolder; } 43 DummyPageHolder& dummyPageHolder() const { return *m_dummyPageHolder; }
46 HTMLDocument& document() const; 44 HTMLDocument& document() const;
47 void setSelection(const VisibleSelection&); 45 void setSelection(const VisibleSelection&);
48 FrameSelection& selection() const; 46 FrameSelection& selection() const;
49 PassRefPtrWillBeRawPtr<Text> appendTextNode(const String& data); 47 PassRefPtrWillBeRawPtr<Text> appendTextNode(const String& data);
50 int layoutCount() const { return m_dummyPageHolder->frameView().layoutCount( ); } 48 int layoutCount() const { return m_dummyPageHolder->frameView().layoutCount( ); }
51 void setInnerHTML(const char*); 49 void setInnerHTML(const char*);
52 // Parses the text node, appending the info to m_letterPos and m_wordMiddles . 50 // Parses the text node, appending the info to m_letterPos and m_wordMiddles .
53 void parseText(Text*); 51 void parseText(Text*);
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 651
654 parseText(text.get()); 652 parseText(text.get());
655 653
656 // "ab cd efghijkl ^mnopqr |>stuvwi inm," (^ means base and | means extent, 654 // "ab cd efghijkl ^mnopqr |>stuvwi inm," (^ means base and | means extent,
657 // > means end). 655 // > means end).
658 selection().setSelection(VisibleSelection(Position(text, 15), Position(text, 22))); 656 selection().setSelection(VisibleSelection(Position(text, 15), Position(text, 22)));
659 EXPECT_EQ_SELECTED_TEXT("mnopqr "); 657 EXPECT_EQ_SELECTED_TEXT("mnopqr ");
660 selection().moveRangeSelectionExtent(m_wordMiddles[4]); 658 selection().moveRangeSelectionExtent(m_wordMiddles[4]);
661 EXPECT_EQ_SELECTED_TEXT("mnopqr iiin"); 659 EXPECT_EQ_SELECTED_TEXT("mnopqr iiin");
662 } 660 }
663 } 661
662 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/FrameSelectionTest.cpp ('k') | Source/core/editing/InputMethodControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698