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

Side by Side Diff: ui/views/touchui/touch_selection_controller_impl_unittest.cc

Issue 191723003: Nukes USE_AURA ifdefs from views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 9 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
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "grit/ui_resources.h" 7 #include "grit/ui_resources.h"
8 #include "ui/aura/test/event_generator.h"
9 #include "ui/aura/window.h"
8 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/base/touch/touch_editing_controller.h" 11 #include "ui/base/touch/touch_editing_controller.h"
10 #include "ui/base/ui_base_switches.h" 12 #include "ui/base/ui_base_switches.h"
11 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/point.h" 14 #include "ui/gfx/point.h"
13 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
14 #include "ui/gfx/render_text.h" 16 #include "ui/gfx/render_text.h"
15 #include "ui/views/controls/textfield/textfield.h" 17 #include "ui/views/controls/textfield/textfield.h"
16 #include "ui/views/test/views_test_base.h" 18 #include "ui/views/test/views_test_base.h"
17 #include "ui/views/touchui/touch_selection_controller_impl.h" 19 #include "ui/views/touchui/touch_selection_controller_impl.h"
18 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
19 21
20 #if defined(USE_AURA)
21 #include "ui/aura/test/event_generator.h"
22 #include "ui/aura/window.h"
23 #endif
24
25 using base::ASCIIToUTF16; 22 using base::ASCIIToUTF16;
26 using base::UTF16ToUTF8; 23 using base::UTF16ToUTF8;
27 using base::WideToUTF16; 24 using base::WideToUTF16;
28 25
29 namespace { 26 namespace {
30 // Should match kSelectionHandlePadding in touch_selection_controller. 27 // Should match kSelectionHandlePadding in touch_selection_controller.
31 const int kPadding = 10; 28 const int kPadding = 10;
32 29
33 gfx::Image* GetHandleImage() { 30 gfx::Image* GetHandleImage() {
34 static gfx::Image* handle_image = NULL; 31 static gfx::Image* handle_image = NULL;
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 size_t visible_handle_position = textfield_->GetSelectedRange().end(); 455 size_t visible_handle_position = textfield_->GetSelectedRange().end();
459 for (int i = 0; i < 10; ++i) { 456 for (int i = 0; i < 10; ++i) {
460 SimulateSelectionHandleDrag(gfx::Point(-10, 0), 2); 457 SimulateSelectionHandleDrag(gfx::Point(-10, 0), 2);
461 // Make sure that the visible handle is being dragged. 458 // Make sure that the visible handle is being dragged.
462 EXPECT_NE(visible_handle_position, textfield_->GetSelectedRange().end()); 459 EXPECT_NE(visible_handle_position, textfield_->GetSelectedRange().end());
463 visible_handle_position = textfield_->GetSelectedRange().end(); 460 visible_handle_position = textfield_->GetSelectedRange().end();
464 EXPECT_EQ((size_t) 10, textfield_->GetSelectedRange().start()); 461 EXPECT_EQ((size_t) 10, textfield_->GetSelectedRange().start());
465 } 462 }
466 } 463 }
467 464
468 #if defined(USE_AURA)
469 TEST_F(TouchSelectionControllerImplTest, 465 TEST_F(TouchSelectionControllerImplTest,
470 DoubleTapInTextfieldWithCursorHandleShouldSelectWord) { 466 DoubleTapInTextfieldWithCursorHandleShouldSelectWord) {
471 CreateTextfield(); 467 CreateTextfield();
472 textfield_->SetText(ASCIIToUTF16("some text")); 468 textfield_->SetText(ASCIIToUTF16("some text"));
473 aura::test::EventGenerator generator( 469 aura::test::EventGenerator generator(
474 textfield_->GetWidget()->GetNativeView()->GetRootWindow()); 470 textfield_->GetWidget()->GetNativeView()->GetRootWindow());
475 471
476 // Tap the textfield to invoke touch selection. 472 // Tap the textfield to invoke touch selection.
477 generator.GestureTapAt(gfx::Point(10, 10)); 473 generator.GestureTapAt(gfx::Point(10, 10));
478 474
479 // Cursor handle should be visible. 475 // Cursor handle should be visible.
480 EXPECT_FALSE(textfield_->HasSelection()); 476 EXPECT_FALSE(textfield_->HasSelection());
481 VERIFY_HANDLE_POSITIONS(false); 477 VERIFY_HANDLE_POSITIONS(false);
482 478
483 // Double tap on the cursor handle position. We want to check that the cursor 479 // Double tap on the cursor handle position. We want to check that the cursor
484 // handle is not eating the event and that the event is falling through to the 480 // handle is not eating the event and that the event is falling through to the
485 // textfield. 481 // textfield.
486 gfx::Point cursor_pos = GetCursorHandlePosition(); 482 gfx::Point cursor_pos = GetCursorHandlePosition();
487 cursor_pos.Offset(GetHandleImageSize().width() / 2 + kPadding, 0); 483 cursor_pos.Offset(GetHandleImageSize().width() / 2 + kPadding, 0);
488 generator.GestureTapAt(cursor_pos); 484 generator.GestureTapAt(cursor_pos);
489 generator.GestureTapAt(cursor_pos); 485 generator.GestureTapAt(cursor_pos);
490 EXPECT_TRUE(textfield_->HasSelection()); 486 EXPECT_TRUE(textfield_->HasSelection());
491 VERIFY_HANDLE_POSITIONS(false); 487 VERIFY_HANDLE_POSITIONS(false);
492 } 488 }
493 #endif
494 489
495 } // namespace views 490 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698