| 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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 scoped_ptr<Window> w1(CreateTestWindowWithDelegate( | 594 scoped_ptr<Window> w1(CreateTestWindowWithDelegate( |
| 595 &delegate1, 0, gfx::Rect(0, 0, 20, 20), NULL)); | 595 &delegate1, 0, gfx::Rect(0, 0, 20, 20), NULL)); |
| 596 CaptureWindowDelegateImpl delegate2; | 596 CaptureWindowDelegateImpl delegate2; |
| 597 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( | 597 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( |
| 598 &delegate2, 0, gfx::Rect(20, 20, 20, 20), NULL)); | 598 &delegate2, 0, gfx::Rect(20, 20, 20, 20), NULL)); |
| 599 | 599 |
| 600 // Press on w1. | 600 // Press on w1. |
| 601 TouchEvent press(ui::ET_TOUCH_PRESSED, | 601 TouchEvent press(ui::ET_TOUCH_PRESSED, |
| 602 gfx::Point(10, 10), 0, getTime()); | 602 gfx::Point(10, 10), 0, getTime()); |
| 603 root_window()->DispatchTouchEvent(&press); | 603 root_window()->DispatchTouchEvent(&press); |
| 604 EXPECT_EQ(1, delegate1.gesture_event_count()); | 604 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. |
| 605 EXPECT_EQ(2, delegate1.gesture_event_count()); |
| 605 delegate1.ResetCounts(); | 606 delegate1.ResetCounts(); |
| 606 w2->SetCapture(); | 607 w2->SetCapture(); |
| 607 | 608 |
| 608 // The touch was cancelled when the other window | 609 // The touch was cancelled when the other window |
| 609 // attained a touch lock. | 610 // attained a touch lock. |
| 610 EXPECT_EQ(1, delegate1.touch_event_count()); | 611 EXPECT_EQ(1, delegate1.touch_event_count()); |
| 611 EXPECT_EQ(0, delegate2.touch_event_count()); | 612 EXPECT_EQ(0, delegate2.touch_event_count()); |
| 612 | 613 |
| 613 delegate1.ResetCounts(); | 614 delegate1.ResetCounts(); |
| 614 delegate2.ResetCounts(); | 615 delegate2.ResetCounts(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 626 root_window()->DispatchTouchEvent(&release); | 627 root_window()->DispatchTouchEvent(&release); |
| 627 EXPECT_EQ(0, delegate1.gesture_event_count()); | 628 EXPECT_EQ(0, delegate1.gesture_event_count()); |
| 628 EXPECT_EQ(0, delegate2.gesture_event_count()); | 629 EXPECT_EQ(0, delegate2.gesture_event_count()); |
| 629 | 630 |
| 630 // A new press is captured by w2. | 631 // A new press is captured by w2. |
| 631 | 632 |
| 632 TouchEvent press2(ui::ET_TOUCH_PRESSED, | 633 TouchEvent press2(ui::ET_TOUCH_PRESSED, |
| 633 gfx::Point(10, 10), 0, getTime()); | 634 gfx::Point(10, 10), 0, getTime()); |
| 634 root_window()->DispatchTouchEvent(&press2); | 635 root_window()->DispatchTouchEvent(&press2); |
| 635 EXPECT_EQ(0, delegate1.gesture_event_count()); | 636 EXPECT_EQ(0, delegate1.gesture_event_count()); |
| 636 EXPECT_EQ(1, delegate2.gesture_event_count()); | 637 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. |
| 638 EXPECT_EQ(2, delegate2.gesture_event_count()); |
| 637 } | 639 } |
| 638 | 640 |
| 639 TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { | 641 TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { |
| 640 CaptureWindowDelegateImpl delegate; | 642 CaptureWindowDelegateImpl delegate; |
| 641 scoped_ptr<Window> window(CreateTestWindowWithDelegate( | 643 scoped_ptr<Window> window(CreateTestWindowWithDelegate( |
| 642 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); | 644 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); |
| 643 | 645 |
| 644 TouchEvent press(ui::ET_TOUCH_PRESSED, | 646 TouchEvent press(ui::ET_TOUCH_PRESSED, |
| 645 gfx::Point(10, 10), 0, getTime()); | 647 gfx::Point(10, 10), 0, getTime()); |
| 646 root_window()->DispatchTouchEvent(&press); | 648 root_window()->DispatchTouchEvent(&press); |
| 647 | 649 |
| 648 EXPECT_EQ(1, delegate.gesture_event_count()); | 650 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. |
| 651 EXPECT_EQ(2, delegate.gesture_event_count()); |
| 649 delegate.ResetCounts(); | 652 delegate.ResetCounts(); |
| 650 | 653 |
| 651 window->SetCapture(); | 654 window->SetCapture(); |
| 652 EXPECT_EQ(0, delegate.gesture_event_count()); | 655 EXPECT_EQ(0, delegate.gesture_event_count()); |
| 653 delegate.ResetCounts(); | 656 delegate.ResetCounts(); |
| 654 | 657 |
| 655 // The move event should still create a gesture, as this touch was | 658 // The move event should still create a gesture, as this touch was |
| 656 // on the window which was captured. | 659 // on the window which was captured. |
| 657 TouchEvent release(ui::ET_TOUCH_RELEASED, | 660 TouchEvent release(ui::ET_TOUCH_RELEASED, |
| 658 gfx::Point(10, 10), 0, getTime() + | 661 gfx::Point(10, 10), 0, getTime() + |
| (...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 c1->SetParent(parent.get()); | 2036 c1->SetParent(parent.get()); |
| 2034 Window* c2 = new Window(NULL); | 2037 Window* c2 = new Window(NULL); |
| 2035 c2->Init(ui::LAYER_NOT_DRAWN); | 2038 c2->Init(ui::LAYER_NOT_DRAWN); |
| 2036 c2->SetParent(parent.get()); | 2039 c2->SetParent(parent.get()); |
| 2037 delegate.SetOwnedWindow(c2); | 2040 delegate.SetOwnedWindow(c2); |
| 2038 parent.reset(); | 2041 parent.reset(); |
| 2039 } | 2042 } |
| 2040 | 2043 |
| 2041 } // namespace test | 2044 } // namespace test |
| 2042 } // namespace aura | 2045 } // namespace aura |
| OLD | NEW |