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

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

Issue 6132009: Delete test view delegate at end of test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/views/controls/textfield
Patch Set: Created 9 years, 11 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 | « no previous file | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/scoped_ptr.h" 6 #include "base/scoped_ptr.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/base/clipboard/clipboard.h" 9 #include "ui/base/clipboard/clipboard.h"
10 #include "ui/base/clipboard/scoped_clipboard_writer.h" 10 #include "ui/base/clipboard/scoped_clipboard_writer.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 EXPECT_EQ(7U, model.cursor_pos()); 282 EXPECT_EQ(7U, model.cursor_pos());
283 283
284 model.SetText(ASCIIToUTF16("BYE")); 284 model.SetText(ASCIIToUTF16("BYE"));
285 EXPECT_EQ(3U, model.cursor_pos()); 285 EXPECT_EQ(3U, model.cursor_pos());
286 EXPECT_EQ(string16(), model.GetSelectedText()); 286 EXPECT_EQ(string16(), model.GetSelectedText());
287 model.SetText(ASCIIToUTF16("")); 287 model.SetText(ASCIIToUTF16(""));
288 EXPECT_EQ(0U, model.cursor_pos()); 288 EXPECT_EQ(0U, model.cursor_pos());
289 } 289 }
290 290
291 TEST(TextfieldViewsModelTest, Clipboard) { 291 TEST(TextfieldViewsModelTest, Clipboard) {
292 views::ViewsDelegate::views_delegate = new TestViewsDelegate(); 292 scoped_ptr<TestViewsDelegate> test_views_delegate(new TestViewsDelegate());
293 views::ViewsDelegate* original_delegate =
294 views::ViewsDelegate::views_delegate;
295 views::ViewsDelegate::views_delegate = test_views_delegate.get();
293 ui::Clipboard* clipboard 296 ui::Clipboard* clipboard
294 = views::ViewsDelegate::views_delegate->GetClipboard(); 297 = views::ViewsDelegate::views_delegate->GetClipboard();
295 string16 initial_clipboard_text; 298 string16 initial_clipboard_text;
296 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &initial_clipboard_text); 299 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &initial_clipboard_text);
297 string16 clipboard_text; 300 string16 clipboard_text;
298 TextfieldViewsModel model; 301 TextfieldViewsModel model;
299 model.Append(ASCIIToUTF16("HELLO WORLD")); 302 model.Append(ASCIIToUTF16("HELLO WORLD"));
300 model.MoveCursorToEnd(false); 303 model.MoveCursorToEnd(false);
301 304
302 // Test for cut: Empty selection. 305 // Test for cut: Empty selection.
(...skipping 29 matching lines...) Expand all
332 335
333 // Test for paste. 336 // Test for paste.
334 model.ClearSelection(); 337 model.ClearSelection();
335 model.MoveCursorToEnd(false); 338 model.MoveCursorToEnd(false);
336 model.MoveCursorToPreviousWord(true); 339 model.MoveCursorToPreviousWord(true);
337 EXPECT_TRUE(model.Paste()); 340 EXPECT_TRUE(model.Paste());
338 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text); 341 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text);
339 EXPECT_STR_EQ("HELLO HELLO WORLD", clipboard_text); 342 EXPECT_STR_EQ("HELLO HELLO WORLD", clipboard_text);
340 EXPECT_STR_EQ("HELLO HELLO HELLO HELLO WORLD", model.text()); 343 EXPECT_STR_EQ("HELLO HELLO HELLO HELLO WORLD", model.text());
341 EXPECT_EQ(29U, model.cursor_pos()); 344 EXPECT_EQ(29U, model.cursor_pos());
345
346 // Restore original delegate.
347 views::ViewsDelegate::views_delegate = original_delegate;
342 } 348 }
343 349
344 } // namespace views 350 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698