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

Side by Side Diff: ui/gfx/render_text_unittest.cc

Issue 2556083002: Don't subtract border from max size for display rect. (Closed)
Patch Set: RenderTextTestApi Created 4 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gfx/render_text.h" 5 #include "ui/gfx/render_text.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 18 matching lines...) Expand all
29 #include "ui/gfx/canvas.h" 29 #include "ui/gfx/canvas.h"
30 #include "ui/gfx/color_utils.h" 30 #include "ui/gfx/color_utils.h"
31 #include "ui/gfx/decorated_text.h" 31 #include "ui/gfx/decorated_text.h"
32 #include "ui/gfx/font.h" 32 #include "ui/gfx/font.h"
33 #include "ui/gfx/font_names_testing.h" 33 #include "ui/gfx/font_names_testing.h"
34 #include "ui/gfx/geometry/point.h" 34 #include "ui/gfx/geometry/point.h"
35 #include "ui/gfx/geometry/point_f.h" 35 #include "ui/gfx/geometry/point_f.h"
36 #include "ui/gfx/range/range.h" 36 #include "ui/gfx/range/range.h"
37 #include "ui/gfx/range/range_f.h" 37 #include "ui/gfx/range/range_f.h"
38 #include "ui/gfx/render_text_harfbuzz.h" 38 #include "ui/gfx/render_text_harfbuzz.h"
39 #include "ui/gfx/test/render_text_test_api.h"
39 #include "ui/gfx/text_utils.h" 40 #include "ui/gfx/text_utils.h"
40 41
41 #if defined(OS_WIN) 42 #if defined(OS_WIN)
42 #include "base/win/windows_version.h" 43 #include "base/win/windows_version.h"
43 #include "ui/gfx/platform_font_win.h" 44 #include "ui/gfx/platform_font_win.h"
44 #endif 45 #endif
45 46
46 #if defined(OS_MACOSX) 47 #if defined(OS_MACOSX)
47 #include <ApplicationServices/ApplicationServices.h> 48 #include <ApplicationServices/ApplicationServices.h>
48 49
49 #include "ui/gfx/render_text_mac.h" 50 #include "ui/gfx/render_text_mac.h"
50 #endif 51 #endif
51 52
52 using base::ASCIIToUTF16; 53 using base::ASCIIToUTF16;
53 using base::UTF8ToUTF16; 54 using base::UTF8ToUTF16;
54 using base::WideToUTF16; 55 using base::WideToUTF16;
55 using base::WideToUTF8; 56 using base::WideToUTF8;
56 57
57 namespace gfx { 58 namespace gfx {
58 namespace test {
59
60 class RenderTextTestApi {
61 public:
62 RenderTextTestApi(RenderText* render_text) : render_text_(render_text) {}
63
64 static SkPaint& GetRendererPaint(internal::SkiaTextRenderer* renderer) {
65 return renderer->paint_;
66 }
67
68 // Callers should ensure that the associated RenderText object is a
69 // RenderTextHarfBuzz instance.
70 internal::TextRunList* GetHarfBuzzRunList() {
71 RenderTextHarfBuzz* render_text =
72 static_cast<RenderTextHarfBuzz*>(render_text_);
73 return render_text->GetRunList();
74 }
75
76 void DrawVisualText(internal::SkiaTextRenderer* renderer) {
77 render_text_->EnsureLayout();
78 render_text_->DrawVisualText(renderer);
79 }
80
81 const BreakList<SkColor>& colors() const { return render_text_->colors(); }
82
83 const BreakList<BaselineStyle>& baselines() const {
84 return render_text_->baselines();
85 }
86
87 const BreakList<Font::Weight>& weights() const {
88 return render_text_->weights();
89 }
90
91 const std::vector<BreakList<bool>>& styles() const {
92 return render_text_->styles();
93 }
94
95 const std::vector<internal::Line>& lines() const {
96 return render_text_->lines();
97 }
98
99 SelectionModel EdgeSelectionModel(VisualCursorDirection direction) {
100 return render_text_->EdgeSelectionModel(direction);
101 }
102
103 size_t TextIndexToDisplayIndex(size_t index) {
104 return render_text_->TextIndexToDisplayIndex(index);
105 }
106
107 size_t DisplayIndexToTextIndex(size_t index) {
108 return render_text_->DisplayIndexToTextIndex(index);
109 }
110
111 void EnsureLayout() { render_text_->EnsureLayout(); }
112
113 Vector2d GetAlignmentOffset(size_t line_number) {
114 return render_text_->GetAlignmentOffset(line_number);
115 }
116
117 private:
118 RenderText* render_text_;
119
120 DISALLOW_COPY_AND_ASSIGN(RenderTextTestApi);
121 };
122
123 } // namespace test
124
125 namespace { 59 namespace {
126 60
127 // An enum specifying the different RenderText implementations to be tested. 61 // An enum specifying the different RenderText implementations to be tested.
128 enum RenderTextBackend { 62 enum RenderTextBackend {
129 RENDER_TEXT_HARFBUZZ, 63 RENDER_TEXT_HARFBUZZ,
130 RENDER_TEXT_MAC, 64 RENDER_TEXT_MAC,
131 }; 65 };
132 66
133 // Parameterised test name generator for tests depending on RenderTextBackend. 67 // Parameterised test name generator for tests depending on RenderTextBackend.
134 struct PrintRenderTextBackend { 68 struct PrintRenderTextBackend {
(...skipping 3959 matching lines...) Expand 10 before | Expand all | Expand 10 after
4094 ::testing::Values(RENDER_TEXT_HARFBUZZ), 4028 ::testing::Values(RENDER_TEXT_HARFBUZZ),
4095 PrintRenderTextBackend()); 4029 PrintRenderTextBackend());
4096 #endif 4030 #endif
4097 4031
4098 INSTANTIATE_TEST_CASE_P(, 4032 INSTANTIATE_TEST_CASE_P(,
4099 RenderTextHarfBuzzTest, 4033 RenderTextHarfBuzzTest,
4100 ::testing::Values(RENDER_TEXT_HARFBUZZ), 4034 ::testing::Values(RENDER_TEXT_HARFBUZZ),
4101 PrintRenderTextBackend()); 4035 PrintRenderTextBackend());
4102 4036
4103 } // namespace gfx 4037 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698