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

Side by Side Diff: ui/views/view_unittest.cc

Issue 11188012: gesture recognizer: Remove the touch-event queue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 8 years, 2 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 | « ui/base/gestures/gesture_sequence.cc ('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 <map> 5 #include <map>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 v2->AddChildView(v3); 520 v2->AddChildView(v3);
521 521
522 // |v3| completely obscures |v2|, but all the touch events on |v3| should 522 // |v3| completely obscures |v2|, but all the touch events on |v3| should
523 // reach |v2| because |v3| doesn't process any touch events. 523 // reach |v2| because |v3| doesn't process any touch events.
524 524
525 // Make sure if none of the views handle the touch event, the gesture manager 525 // Make sure if none of the views handle the touch event, the gesture manager
526 // does. 526 // does.
527 v1->Reset(); 527 v1->Reset();
528 v2->Reset(); 528 v2->Reset();
529 529
530 ui::TestTouchEvent unhandled(ui::ET_TOUCH_MOVED, 530 ui::TouchEvent unhandled(ui::ET_TOUCH_MOVED,
531 400, 400, 531 gfx::Point(400, 400),
532 0, /* no flags */ 532 0, /* no flags */
533 0, /* first finger touch */ 533 0, /* first finger touch */
534 1.0, 0.0, 1.0, 0.0); 534 base::TimeDelta(),
535 1.0, 0.0, 1.0, 0.0);
535 root->OnTouchEvent(unhandled); 536 root->OnTouchEvent(unhandled);
536 537
537 EXPECT_EQ(v1->last_touch_event_type_, 0); 538 EXPECT_EQ(v1->last_touch_event_type_, 0);
538 EXPECT_EQ(v2->last_touch_event_type_, 0); 539 EXPECT_EQ(v2->last_touch_event_type_, 0);
539 540
540 // Test press, drag, release touch sequence. 541 // Test press, drag, release touch sequence.
541 v1->Reset(); 542 v1->Reset();
542 v2->Reset(); 543 v2->Reset();
543 544
544 ui::TestTouchEvent pressed(ui::ET_TOUCH_PRESSED, 545 ui::TouchEvent pressed(ui::ET_TOUCH_PRESSED,
545 110, 120, 546 gfx::Point(110, 120),
546 0, /* no flags */ 547 0, /* no flags */
547 0, /* first finger touch */ 548 0, /* first finger touch */
548 1.0, 0.0, 1.0, 0.0); 549 base::TimeDelta(),
550 1.0, 0.0, 1.0, 0.0);
549 v2->last_touch_event_was_handled_ = true; 551 v2->last_touch_event_was_handled_ = true;
550 root->OnTouchEvent(pressed); 552 root->OnTouchEvent(pressed);
551 553
552 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_PRESSED); 554 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_PRESSED);
553 EXPECT_EQ(v2->location_.x(), 10); 555 EXPECT_EQ(v2->location_.x(), 10);
554 EXPECT_EQ(v2->location_.y(), 20); 556 EXPECT_EQ(v2->location_.y(), 20);
555 // Make sure v1 did not receive the event 557 // Make sure v1 did not receive the event
556 EXPECT_EQ(v1->last_touch_event_type_, 0); 558 EXPECT_EQ(v1->last_touch_event_type_, 0);
557 559
558 // Drag event out of bounds. Should still go to v2 560 // Drag event out of bounds. Should still go to v2
559 v1->Reset(); 561 v1->Reset();
560 v2->Reset(); 562 v2->Reset();
561 ui::TestTouchEvent dragged(ui::ET_TOUCH_MOVED, 563 ui::TouchEvent dragged(ui::ET_TOUCH_MOVED,
562 50, 40, 564 gfx::Point(50, 40),
563 0, /* no flags */ 565 0, /* no flags */
564 0, /* first finger touch */ 566 0, /* first finger touch */
565 1.0, 0.0, 1.0, 0.0); 567 base::TimeDelta(),
568 1.0, 0.0, 1.0, 0.0);
566 569
567 root->OnTouchEvent(dragged); 570 root->OnTouchEvent(dragged);
568 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_MOVED); 571 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_MOVED);
569 EXPECT_EQ(v2->location_.x(), -50); 572 EXPECT_EQ(v2->location_.x(), -50);
570 EXPECT_EQ(v2->location_.y(), -60); 573 EXPECT_EQ(v2->location_.y(), -60);
571 // Make sure v1 did not receive the event 574 // Make sure v1 did not receive the event
572 EXPECT_EQ(v1->last_touch_event_type_, 0); 575 EXPECT_EQ(v1->last_touch_event_type_, 0);
573 576
574 // Released event out of bounds. Should still go to v2 577 // Released event out of bounds. Should still go to v2
575 v1->Reset(); 578 v1->Reset();
576 v2->Reset(); 579 v2->Reset();
577 ui::TestTouchEvent released(ui::ET_TOUCH_RELEASED, 0, 0, 580 ui::TouchEvent released(ui::ET_TOUCH_RELEASED, gfx::Point(),
578 0, /* no flags */ 581 0, /* no flags */
579 0, /* first finger */ 582 0, /* first finger */
580 1.0, 0.0, 1.0, 0.0); 583 base::TimeDelta(),
584 1.0, 0.0, 1.0, 0.0);
581 v2->last_touch_event_was_handled_ = true; 585 v2->last_touch_event_was_handled_ = true;
582 root->OnTouchEvent(released); 586 root->OnTouchEvent(released);
583 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_RELEASED); 587 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_RELEASED);
584 EXPECT_EQ(v2->location_.x(), -100); 588 EXPECT_EQ(v2->location_.x(), -100);
585 EXPECT_EQ(v2->location_.y(), -100); 589 EXPECT_EQ(v2->location_.y(), -100);
586 // Make sure v1 did not receive the event 590 // Make sure v1 did not receive the event
587 EXPECT_EQ(v1->last_touch_event_type_, 0); 591 EXPECT_EQ(v1->last_touch_event_type_, 0);
588 592
589 widget->CloseNow(); 593 widget->CloseNow();
590 } 594 }
(...skipping 2792 matching lines...) Expand 10 before | Expand all | Expand 10 after
3383 // Set to non default value. 3387 // Set to non default value.
3384 v->layer()->set_scale_content(false); 3388 v->layer()->set_scale_content(false);
3385 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); 3389 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer());
3386 ui::Layer* new_layer = v->layer(); 3390 ui::Layer* new_layer = v->layer();
3387 EXPECT_FALSE(new_layer->scale_content()); 3391 EXPECT_FALSE(new_layer->scale_content());
3388 } 3392 }
3389 3393
3390 #endif // USE_AURA 3394 #endif // USE_AURA
3391 3395
3392 } // namespace views 3396 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/gestures/gesture_sequence.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698