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

Unified Diff: views/controls/textfield/native_textfield_views_unittest.cc

Issue 7265011: RenderText API Outline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix permissions, export RenderText and StyleRange via UI_API. Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: views/controls/textfield/native_textfield_views_unittest.cc
diff --git a/views/controls/textfield/native_textfield_views_unittest.cc b/views/controls/textfield/native_textfield_views_unittest.cc
index 31a5e51879425cfc1b02e1a2fc940e74b7c55a40..0c8ec2e5c9c9e959171e8e3e23db2651042bc25f 100644
--- a/views/controls/textfield/native_textfield_views_unittest.cc
+++ b/views/controls/textfield/native_textfield_views_unittest.cc
@@ -15,6 +15,7 @@
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/keycodes/keyboard_codes.h"
+#include "ui/gfx/render_text.h"
#include "views/controls/textfield/native_textfield_views.h"
#include "views/controls/textfield/textfield.h"
#include "views/controls/textfield/textfield_controller.h"
@@ -218,9 +219,8 @@ class NativeTextfieldViewsTest : public ViewsTestBase,
}
int GetCursorPositionX(int cursor_pos) {
- const string16 text = textfield_->text().substr(0, cursor_pos);
- return textfield_view_->GetInsets().left() + textfield_view_->text_offset_ +
- textfield_view_->GetFont().GetStringWidth(text);
+ gfx::RenderText* render_text = textfield_view_->GetRenderText();
+ return render_text->GetCursorBounds(cursor_pos, false).x();
}
// We need widget to populate wrapper class.
@@ -254,12 +254,12 @@ TEST_F(NativeTextfieldViewsTest, ModelChangesTest) {
last_contents_.clear();
textfield_->SetText(ASCIIToUTF16("this is"));
- EXPECT_STR_EQ("this is", model_->text());
+ EXPECT_STR_EQ("this is", model_->GetText());
EXPECT_STR_EQ("this is", textfield_->text());
EXPECT_TRUE(last_contents_.empty());
textfield_->AppendText(ASCIIToUTF16(" a test"));
- EXPECT_STR_EQ("this is a test", model_->text());
+ EXPECT_STR_EQ("this is a test", model_->GetText());
EXPECT_STR_EQ("this is a test", textfield_->text());
EXPECT_TRUE(last_contents_.empty());

Powered by Google App Engine
This is Rietveld 408576698