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

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

Issue 12182002: Fix RenderTextTest.PangoAttributes test leaks; remove suppressions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
« no previous file with comments | « tools/valgrind/memcheck/suppressions.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/break_list.h" 10 #include "ui/gfx/break_list.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 RenderTextLinux* rt_linux = static_cast<RenderTextLinux*>(render_text.get()); 182 RenderTextLinux* rt_linux = static_cast<RenderTextLinux*>(render_text.get());
183 rt_linux->EnsureLayout(); 183 rt_linux->EnsureLayout();
184 PangoAttrList* attributes = pango_layout_get_attributes(rt_linux->layout_); 184 PangoAttrList* attributes = pango_layout_get_attributes(rt_linux->layout_);
185 PangoAttrIterator* iter = pango_attr_list_get_iterator(attributes); 185 PangoAttrIterator* iter = pango_attr_list_get_iterator(attributes);
186 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 186 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
187 pango_attr_iterator_range(iter, &start, &end); 187 pango_attr_iterator_range(iter, &start, &end);
188 EXPECT_EQ(cases[i].start, start); 188 EXPECT_EQ(cases[i].start, start);
189 EXPECT_EQ(cases[i].end, end); 189 EXPECT_EQ(cases[i].end, end);
190 PangoFontDescription* font = pango_font_description_new(); 190 PangoFontDescription* font = pango_font_description_new();
191 pango_attr_iterator_get_font(iter, font, NULL, NULL); 191 pango_attr_iterator_get_font(iter, font, NULL, NULL);
192 const string16 desc = ASCIIToUTF16(pango_font_description_to_string(font)); 192 char* description_string = pango_font_description_to_string(font);
193 const string16 desc = ASCIIToUTF16(description_string);
193 const bool bold = desc.find(ASCIIToUTF16("Bold")) != std::string::npos; 194 const bool bold = desc.find(ASCIIToUTF16("Bold")) != std::string::npos;
194 EXPECT_EQ(cases[i].bold, bold); 195 EXPECT_EQ(cases[i].bold, bold);
195 const bool italic = desc.find(ASCIIToUTF16("Italic")) != std::string::npos; 196 const bool italic = desc.find(ASCIIToUTF16("Italic")) != std::string::npos;
196 EXPECT_EQ(cases[i].italic, italic); 197 EXPECT_EQ(cases[i].italic, italic);
197 pango_attr_iterator_next(iter); 198 pango_attr_iterator_next(iter);
198 pango_font_description_free(font); 199 pango_font_description_free(font);
200 g_free(description_string);
199 } 201 }
200 EXPECT_FALSE(pango_attr_iterator_next(iter)); 202 EXPECT_FALSE(pango_attr_iterator_next(iter));
203 pango_attr_iterator_destroy(iter);
201 } 204 }
202 #endif 205 #endif
203 206
204 // TODO(asvitkine): Cursor movements tests disabled on Mac because RenderTextMac 207 // TODO(asvitkine): Cursor movements tests disabled on Mac because RenderTextMac
205 // does not implement this yet. http://crbug.com/131618 208 // does not implement this yet. http://crbug.com/131618
206 #if !defined(OS_MACOSX) 209 #if !defined(OS_MACOSX)
207 void TestVisualCursorMotionInObscuredField(RenderText* render_text, 210 void TestVisualCursorMotionInObscuredField(RenderText* render_text,
208 const string16& text, 211 const string16& text,
209 bool select) { 212 bool select) {
210 ASSERT_TRUE(render_text->obscured()); 213 ASSERT_TRUE(render_text->obscured());
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 EXPECT_EQ(render_text->display_rect().width() - width - 1, 1221 EXPECT_EQ(render_text->display_rect().width() - width - 1,
1219 render_text->GetUpdatedCursorBounds().x()); 1222 render_text->GetUpdatedCursorBounds().x());
1220 1223
1221 // Reset the application default text direction to LTR. 1224 // Reset the application default text direction to LTR.
1222 SetRTL(was_rtl); 1225 SetRTL(was_rtl);
1223 EXPECT_EQ(was_rtl, base::i18n::IsRTL()); 1226 EXPECT_EQ(was_rtl, base::i18n::IsRTL());
1224 } 1227 }
1225 #endif // !defined(OS_MACOSX) 1228 #endif // !defined(OS_MACOSX)
1226 1229
1227 } // namespace gfx 1230 } // namespace gfx
OLDNEW
« no previous file with comments | « tools/valgrind/memcheck/suppressions.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698