| OLD | NEW |
| 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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 scoped_ptr<Window> w1(CreateTestWindowWithDelegate( | 619 scoped_ptr<Window> w1(CreateTestWindowWithDelegate( |
| 620 &delegate1, 0, gfx::Rect(0, 0, 20, 20), NULL)); | 620 &delegate1, 0, gfx::Rect(0, 0, 20, 20), NULL)); |
| 621 CaptureWindowDelegateImpl delegate2; | 621 CaptureWindowDelegateImpl delegate2; |
| 622 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( | 622 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( |
| 623 &delegate2, 0, gfx::Rect(20, 20, 20, 20), NULL)); | 623 &delegate2, 0, gfx::Rect(20, 20, 20, 20), NULL)); |
| 624 | 624 |
| 625 // Press on w1. | 625 // Press on w1. |
| 626 TouchEvent press(ui::ET_TOUCH_PRESSED, | 626 TouchEvent press(ui::ET_TOUCH_PRESSED, |
| 627 gfx::Point(10, 10), 0, getTime()); | 627 gfx::Point(10, 10), 0, getTime()); |
| 628 root_window()->DispatchTouchEvent(&press); | 628 root_window()->DispatchTouchEvent(&press); |
| 629 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. | 629 EXPECT_EQ(1, delegate1.gesture_event_count()); |
| 630 EXPECT_EQ(2, delegate1.gesture_event_count()); | |
| 631 delegate1.ResetCounts(); | 630 delegate1.ResetCounts(); |
| 632 w2->SetCapture(); | 631 w2->SetCapture(); |
| 633 | 632 |
| 634 // The touch was cancelled when the other window | 633 // The touch was cancelled when the other window |
| 635 // attained a touch lock. | 634 // attained a touch lock. |
| 636 EXPECT_EQ(1, delegate1.touch_event_count()); | 635 EXPECT_EQ(1, delegate1.touch_event_count()); |
| 637 EXPECT_EQ(0, delegate2.touch_event_count()); | 636 EXPECT_EQ(0, delegate2.touch_event_count()); |
| 638 | 637 |
| 639 delegate1.ResetCounts(); | 638 delegate1.ResetCounts(); |
| 640 delegate2.ResetCounts(); | 639 delegate2.ResetCounts(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 652 root_window()->DispatchTouchEvent(&release); | 651 root_window()->DispatchTouchEvent(&release); |
| 653 EXPECT_EQ(0, delegate1.gesture_event_count()); | 652 EXPECT_EQ(0, delegate1.gesture_event_count()); |
| 654 EXPECT_EQ(0, delegate2.gesture_event_count()); | 653 EXPECT_EQ(0, delegate2.gesture_event_count()); |
| 655 | 654 |
| 656 // A new press is captured by w2. | 655 // A new press is captured by w2. |
| 657 | 656 |
| 658 TouchEvent press2(ui::ET_TOUCH_PRESSED, | 657 TouchEvent press2(ui::ET_TOUCH_PRESSED, |
| 659 gfx::Point(10, 10), 0, getTime()); | 658 gfx::Point(10, 10), 0, getTime()); |
| 660 root_window()->DispatchTouchEvent(&press2); | 659 root_window()->DispatchTouchEvent(&press2); |
| 661 EXPECT_EQ(0, delegate1.gesture_event_count()); | 660 EXPECT_EQ(0, delegate1.gesture_event_count()); |
| 662 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. | 661 EXPECT_EQ(1, delegate2.gesture_event_count()); |
| 663 EXPECT_EQ(2, delegate2.gesture_event_count()); | |
| 664 } | 662 } |
| 665 | 663 |
| 666 TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { | 664 TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { |
| 667 CaptureWindowDelegateImpl delegate; | 665 CaptureWindowDelegateImpl delegate; |
| 668 scoped_ptr<Window> window(CreateTestWindowWithDelegate( | 666 scoped_ptr<Window> window(CreateTestWindowWithDelegate( |
| 669 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); | 667 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); |
| 670 | 668 |
| 671 TouchEvent press(ui::ET_TOUCH_PRESSED, | 669 TouchEvent press(ui::ET_TOUCH_PRESSED, |
| 672 gfx::Point(10, 10), 0, getTime()); | 670 gfx::Point(10, 10), 0, getTime()); |
| 673 root_window()->DispatchTouchEvent(&press); | 671 root_window()->DispatchTouchEvent(&press); |
| 674 | 672 |
| 675 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. | 673 EXPECT_EQ(1, delegate.gesture_event_count()); |
| 676 EXPECT_EQ(2, delegate.gesture_event_count()); | |
| 677 delegate.ResetCounts(); | 674 delegate.ResetCounts(); |
| 678 | 675 |
| 679 window->SetCapture(); | 676 window->SetCapture(); |
| 680 EXPECT_EQ(0, delegate.gesture_event_count()); | 677 EXPECT_EQ(0, delegate.gesture_event_count()); |
| 681 delegate.ResetCounts(); | 678 delegate.ResetCounts(); |
| 682 | 679 |
| 683 // The move event should still create a gesture, as this touch was | 680 // The move event should still create a gesture, as this touch was |
| 684 // on the window which was captured. | 681 // on the window which was captured. |
| 685 TouchEvent release(ui::ET_TOUCH_RELEASED, | 682 TouchEvent release(ui::ET_TOUCH_RELEASED, |
| 686 gfx::Point(10, 10), 0, getTime() + | 683 gfx::Point(10, 10), 0, getTime() + |
| (...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 base::TimeTicks start_time = | 2168 base::TimeTicks start_time = |
| 2172 window->layer()->GetAnimator()->last_step_time(); | 2169 window->layer()->GetAnimator()->last_step_time(); |
| 2173 ui::AnimationContainerElement* element = window->layer()->GetAnimator(); | 2170 ui::AnimationContainerElement* element = window->layer()->GetAnimator(); |
| 2174 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); | 2171 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
| 2175 EXPECT_TRUE(delegate.bounds_changed()); | 2172 EXPECT_TRUE(delegate.bounds_changed()); |
| 2176 EXPECT_NE("0,0 100x100", window->bounds().ToString()); | 2173 EXPECT_NE("0,0 100x100", window->bounds().ToString()); |
| 2177 } | 2174 } |
| 2178 | 2175 |
| 2179 } // namespace test | 2176 } // namespace test |
| 2180 } // namespace aura | 2177 } // namespace aura |
| OLD | NEW |