OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/app_list/views/speech_view.h" | 5 #include "ui/app_list/views/speech_view.h" |
6 | 6 |
7 #include "ui/app_list/test/app_list_test_view_delegate.h" | 7 #include "ui/app_list/test/app_list_test_view_delegate.h" |
8 #include "ui/events/event_utils.h" | 8 #include "ui/events/event_utils.h" |
9 #include "ui/views/controls/button/image_button.h" | 9 #include "ui/views/controls/button/image_button.h" |
10 #include "ui/views/test/widget_test.h" | 10 #include "ui/views/test/widget_test.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 }; | 50 }; |
51 | 51 |
52 // Tests that clicking within the circular hit-test mask of MicButton invokes | 52 // Tests that clicking within the circular hit-test mask of MicButton invokes |
53 // SpeechView::ToggleSpeechRecognition() and clicking outside of the | 53 // SpeechView::ToggleSpeechRecognition() and clicking outside of the |
54 // hit-test mask does not. | 54 // hit-test mask does not. |
55 TEST_F(SpeechViewTest, ClickMicButton) { | 55 TEST_F(SpeechViewTest, ClickMicButton) { |
56 EXPECT_EQ(0, GetToggleSpeechRecognitionCountAndReset()); | 56 EXPECT_EQ(0, GetToggleSpeechRecognitionCountAndReset()); |
57 gfx::Rect screen_bounds(view()->mic_button()->GetBoundsInScreen()); | 57 gfx::Rect screen_bounds(view()->mic_button()->GetBoundsInScreen()); |
58 | 58 |
59 // Simulate a mouse click in the center of the MicButton. | 59 // Simulate a mouse click in the center of the MicButton. |
60 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(), | 60 ui::MouseEvent press( |
61 screen_bounds.CenterPoint(), ui::EventTimeForNow(), | 61 ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(), |
62 ui::EF_LEFT_MOUSE_BUTTON, 0); | 62 screen_bounds.CenterPoint(), ui::EventTimeForNow(), |
63 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, screen_bounds.CenterPoint(), | 63 ui::EF_LEFT_MOUSE_BUTTON, 0, |
64 screen_bounds.CenterPoint(), ui::EventTimeForNow(), | 64 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
65 ui::EF_LEFT_MOUSE_BUTTON, 0); | 65 ui::MouseEvent release( |
| 66 ui::ET_MOUSE_RELEASED, screen_bounds.CenterPoint(), |
| 67 screen_bounds.CenterPoint(), ui::EventTimeForNow(), |
| 68 ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 69 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
66 widget()->OnMouseEvent(&press); | 70 widget()->OnMouseEvent(&press); |
67 widget()->OnMouseEvent(&release); | 71 widget()->OnMouseEvent(&release); |
68 EXPECT_EQ(1, GetToggleSpeechRecognitionCountAndReset()); | 72 EXPECT_EQ(1, GetToggleSpeechRecognitionCountAndReset()); |
69 | 73 |
70 // Simulate a mouse click in the bottom right-hand corner of the | 74 // Simulate a mouse click in the bottom right-hand corner of the |
71 // MicButton's view bounds (which would fall outside of its | 75 // MicButton's view bounds (which would fall outside of its |
72 // circular hit-test mask). | 76 // circular hit-test mask). |
73 gfx::Point bottom_right(screen_bounds.right() - 1, | 77 gfx::Point bottom_right(screen_bounds.right() - 1, |
74 screen_bounds.bottom() - 2); | 78 screen_bounds.bottom() - 2); |
75 press = ui::MouseEvent(ui::ET_MOUSE_PRESSED, bottom_right, bottom_right, | 79 press = ui::MouseEvent( |
76 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); | 80 ui::ET_MOUSE_PRESSED, bottom_right, bottom_right, ui::EventTimeForNow(), |
77 release = ui::MouseEvent(ui::ET_MOUSE_RELEASED, bottom_right, bottom_right, | 81 ui::EF_LEFT_MOUSE_BUTTON, 0, |
78 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); | 82 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 83 release = ui::MouseEvent( |
| 84 ui::ET_MOUSE_RELEASED, bottom_right, bottom_right, ui::EventTimeForNow(), |
| 85 ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 86 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
79 widget()->OnMouseEvent(&press); | 87 widget()->OnMouseEvent(&press); |
80 widget()->OnMouseEvent(&release); | 88 widget()->OnMouseEvent(&release); |
81 EXPECT_EQ(0, GetToggleSpeechRecognitionCountAndReset()); | 89 EXPECT_EQ(0, GetToggleSpeechRecognitionCountAndReset()); |
82 } | 90 } |
83 | 91 |
84 } // namespace test | 92 } // namespace test |
85 } // namespace app_list | 93 } // namespace app_list |
OLD | NEW |