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

Side by Side Diff: ui/views/controls/textfield/textfield_views_model_unittest.cc

Issue 8687002: Cleanup: Convert ASCIIToUTF16("") to string16(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 5 #include <vector>
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string16.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/base/clipboard/clipboard.h" 13 #include "ui/base/clipboard/clipboard.h"
13 #include "ui/base/clipboard/scoped_clipboard_writer.h" 14 #include "ui/base/clipboard/scoped_clipboard_writer.h"
14 #include "ui/base/range/range.h" 15 #include "ui/base/range/range.h"
15 #include "ui/gfx/render_text.h" 16 #include "ui/gfx/render_text.h"
16 #include "ui/views/controls/textfield/textfield.h" 17 #include "ui/views/controls/textfield/textfield.h"
17 #include "ui/views/controls/textfield/textfield_views_model.h" 18 #include "ui/views/controls/textfield/textfield_views_model.h"
18 #include "ui/views/test/test_views_delegate.h" 19 #include "ui/views/test/test_views_delegate.h"
19 #include "ui/views/test/views_test_base.h" 20 #include "ui/views/test/views_test_base.h"
(...skipping 22 matching lines...) Expand all
42 : ViewsTestBase(), 43 : ViewsTestBase(),
43 composition_text_confirmed_or_cleared_(false) { 44 composition_text_confirmed_or_cleared_(false) {
44 } 45 }
45 46
46 virtual void OnCompositionTextConfirmedOrCleared() { 47 virtual void OnCompositionTextConfirmedOrCleared() {
47 composition_text_confirmed_or_cleared_ = true; 48 composition_text_confirmed_or_cleared_ = true;
48 } 49 }
49 50
50 protected: 51 protected:
51 void ResetModel(TextfieldViewsModel* model) const { 52 void ResetModel(TextfieldViewsModel* model) const {
52 model->SetText(ASCIIToUTF16("")); 53 model->SetText(string16());
53 model->ClearEditHistory(); 54 model->ClearEditHistory();
54 } 55 }
55 56
56 bool composition_text_confirmed_or_cleared_; 57 bool composition_text_confirmed_or_cleared_;
57 58
58 private: 59 private:
59 DISALLOW_COPY_AND_ASSIGN(TextfieldViewsModelTest); 60 DISALLOW_COPY_AND_ASSIGN(TextfieldViewsModelTest);
60 }; 61 };
61 62
62 #define EXPECT_STR_EQ(ascii, utf16) \ 63 #define EXPECT_STR_EQ(ascii, utf16) \
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 EXPECT_EQ(5U, model.GetCursorPosition()); 492 EXPECT_EQ(5U, model.GetCursorPosition());
492 model.SelectAll(); 493 model.SelectAll();
493 EXPECT_STR_EQ("GOODBYE", model.GetSelectedText()); 494 EXPECT_STR_EQ("GOODBYE", model.GetSelectedText());
494 model.MoveCursorRight(gfx::LINE_BREAK, false); 495 model.MoveCursorRight(gfx::LINE_BREAK, false);
495 EXPECT_EQ(7U, model.GetCursorPosition()); 496 EXPECT_EQ(7U, model.GetCursorPosition());
496 497
497 model.SetText(ASCIIToUTF16("BYE")); 498 model.SetText(ASCIIToUTF16("BYE"));
498 // Setting shorter string moves the cursor to the end of the new string. 499 // Setting shorter string moves the cursor to the end of the new string.
499 EXPECT_EQ(3U, model.GetCursorPosition()); 500 EXPECT_EQ(3U, model.GetCursorPosition());
500 EXPECT_EQ(string16(), model.GetSelectedText()); 501 EXPECT_EQ(string16(), model.GetSelectedText());
501 model.SetText(ASCIIToUTF16("")); 502 model.SetText(string16());
502 EXPECT_EQ(0U, model.GetCursorPosition()); 503 EXPECT_EQ(0U, model.GetCursorPosition());
503 } 504 }
504 505
505 #if defined(USE_AURA) && defined(OS_LINUX) 506 #if defined(USE_AURA) && defined(OS_LINUX)
506 #define MAYBE_Clipboard DISABLED_Clipboard // http://crbug.com/97845 507 #define MAYBE_Clipboard DISABLED_Clipboard // http://crbug.com/97845
507 #else 508 #else
508 #define MAYBE_Clipboard Clipboard 509 #define MAYBE_Clipboard Clipboard
509 #endif 510 #endif
510 TEST_F(TextfieldViewsModelTest, MAYBE_Clipboard) { 511 TEST_F(TextfieldViewsModelTest, MAYBE_Clipboard) {
511 ui::Clipboard* clipboard 512 ui::Clipboard* clipboard
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 EXPECT_TRUE(model.Undo()); 1527 EXPECT_TRUE(model.Undo());
1527 EXPECT_STR_EQ("ABCDE", model.GetText()); 1528 EXPECT_STR_EQ("ABCDE", model.GetText());
1528 EXPECT_TRUE(model.Redo()); 1529 EXPECT_TRUE(model.Redo());
1529 EXPECT_STR_EQ("1234", model.GetText()); 1530 EXPECT_STR_EQ("1234", model.GetText());
1530 EXPECT_FALSE(model.Redo()); 1531 EXPECT_FALSE(model.Redo());
1531 1532
1532 // TODO(oshima): We need MockInputMethod to test the behavior with IME. 1533 // TODO(oshima): We need MockInputMethod to test the behavior with IME.
1533 } 1534 }
1534 1535
1535 } // namespace views 1536 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views_unittest.cc ('k') | webkit/plugins/npapi/plugin_group_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698