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

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

Issue 10479010: Gesture related changes for views: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test and add some mores Created 8 years, 6 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/views/view.cc ('k') | ui/views/widget/native_widget_aura.cc » ('j') | 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 v2->Reset(); 595 v2->Reset();
596 v3->Reset(); 596 v3->Reset();
597 597
598 // Gesture on |v3| 598 // Gesture on |v3|
599 GestureEventForTest g1(ui::ET_GESTURE_TAP, 110, 110, 0); 599 GestureEventForTest g1(ui::ET_GESTURE_TAP, 110, 110, 0);
600 root->OnGestureEvent(g1); 600 root->OnGestureEvent(g1);
601 EXPECT_EQ(ui::ET_GESTURE_TAP, v2->last_gesture_event_type_); 601 EXPECT_EQ(ui::ET_GESTURE_TAP, v2->last_gesture_event_type_);
602 EXPECT_EQ(gfx::Point(10, 10), v2->location_); 602 EXPECT_EQ(gfx::Point(10, 10), v2->location_);
603 EXPECT_EQ(ui::ET_UNKNOWN, v1->last_gesture_event_type_); 603 EXPECT_EQ(ui::ET_UNKNOWN, v1->last_gesture_event_type_);
604 604
605 // Simular an up so that RootView is no longer targetting |v3|.
606 GestureEventForTest g1_up(ui::ET_GESTURE_TAP_UP, 110, 110, 0);
607 root->OnGestureEvent(g1_up);
608
605 v1->Reset(); 609 v1->Reset();
606 v2->Reset(); 610 v2->Reset();
607 v3->Reset(); 611 v3->Reset();
608 612
609 // Gesture on |v1| 613 // Gesture on |v1|
610 GestureEventForTest g2(ui::ET_GESTURE_TAP, 80, 80, 0); 614 GestureEventForTest g2(ui::ET_GESTURE_TAP, 80, 80, 0);
611 root->OnGestureEvent(g2); 615 root->OnGestureEvent(g2);
612 EXPECT_EQ(ui::ET_GESTURE_TAP, v1->last_gesture_event_type_); 616 EXPECT_EQ(ui::ET_GESTURE_TAP, v1->last_gesture_event_type_);
613 EXPECT_EQ(gfx::Point(80, 80), v1->location_); 617 EXPECT_EQ(gfx::Point(80, 80), v1->location_);
614 EXPECT_EQ(ui::ET_UNKNOWN, v2->last_gesture_event_type_); 618 EXPECT_EQ(ui::ET_UNKNOWN, v2->last_gesture_event_type_);
615 619
620 // Send event |g1| again. Even though the coordinates target |v3| it should go
621 // to |v1| as that is the view the touch was initially down on.
622 v1->last_gesture_event_type_ = ui::ET_UNKNOWN;
623 v3->last_gesture_event_type_ = ui::ET_UNKNOWN;
624 root->OnGestureEvent(g1);
625 EXPECT_EQ(ui::ET_GESTURE_TAP, v1->last_gesture_event_type_);
626 EXPECT_EQ(ui::ET_UNKNOWN, v3->last_gesture_event_type_);
627 EXPECT_EQ("110,110", v1->location_.ToString());
628
616 widget->CloseNow(); 629 widget->CloseNow();
617 } 630 }
618 631
619 //////////////////////////////////////////////////////////////////////////////// 632 ////////////////////////////////////////////////////////////////////////////////
620 // Painting 633 // Painting
621 //////////////////////////////////////////////////////////////////////////////// 634 ////////////////////////////////////////////////////////////////////////////////
622 635
623 void TestView::Paint(gfx::Canvas* canvas) { 636 void TestView::Paint(gfx::Canvas* canvas) {
624 canvas->sk_canvas()->getClipBounds(&last_clip_); 637 canvas->sk_canvas()->getClipBounds(&last_clip_);
625 } 638 }
(...skipping 2581 matching lines...) Expand 10 before | Expand all | Expand 10 after
3207 scoped_ptr<ui::Layer> layer(c1->AcquireLayer()); 3220 scoped_ptr<ui::Layer> layer(c1->AcquireLayer());
3208 EXPECT_EQ(layer.get(), c1->layer()); 3221 EXPECT_EQ(layer.get(), c1->layer());
3209 3222
3210 layer.reset(c1->RecreateLayer()); 3223 layer.reset(c1->RecreateLayer());
3211 EXPECT_NE(c1->layer(), layer.get()); 3224 EXPECT_NE(c1->layer(), layer.get());
3212 } 3225 }
3213 3226
3214 #endif // USE_AURA 3227 #endif // USE_AURA
3215 3228
3216 } // namespace views 3229 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.cc ('k') | ui/views/widget/native_widget_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698