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