OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ash/shell.h" | 5 #include "ash/shell.h" |
6 #include "ash/system/tray/system_tray.h" | 6 #include "ash/system/tray/system_tray.h" |
7 #include "base/strings/pattern.h" | 7 #include "base/strings/pattern.h" |
8 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 8 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
9 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" | 9 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
11 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
12 #include "content/public/browser/notification_details.h" | 12 #include "content/public/browser/notification_details.h" |
13 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
14 #include "extensions/browser/notification_types.h" | 14 #include "extensions/browser/notification_types.h" |
15 #include "ui/events/test/event_generator.h" | 15 #include "ui/events/test/event_generator.h" |
16 #include "url/url_constants.h" | 16 #include "url/url_constants.h" |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 | 19 |
20 class SelectToSpeakTest : public InProcessBrowserTest { | 20 class SelectToSpeakTest : public InProcessBrowserTest { |
21 protected: | 21 protected: |
22 SelectToSpeakTest() {} | 22 SelectToSpeakTest() {} |
23 ~SelectToSpeakTest() override {} | 23 ~SelectToSpeakTest() override {} |
24 | 24 |
25 void SetUpOnMainThread() override { | 25 void SetUpOnMainThread() override { |
26 InProcessBrowserTest::SetUpOnMainThread(); | |
27 | |
28 ASSERT_FALSE(AccessibilityManager::Get()->IsSelectToSpeakEnabled()); | 26 ASSERT_FALSE(AccessibilityManager::Get()->IsSelectToSpeakEnabled()); |
29 | 27 |
30 content::WindowedNotificationObserver extension_load_waiter( | 28 content::WindowedNotificationObserver extension_load_waiter( |
31 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, | 29 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, |
32 content::NotificationService::AllSources()); | 30 content::NotificationService::AllSources()); |
33 AccessibilityManager::Get()->SetSelectToSpeakEnabled(true); | 31 AccessibilityManager::Get()->SetSelectToSpeakEnabled(true); |
34 extension_load_waiter.Wait(); | 32 extension_load_waiter.Wait(); |
35 | 33 |
36 aura::Window* root_window = ash::Shell::Get()->GetPrimaryRootWindow(); | 34 aura::Window* root_window = ash::Shell::Get()->GetPrimaryRootWindow(); |
37 generator_.reset(new ui::test::EventGenerator(root_window)); | 35 generator_.reset(new ui::test::EventGenerator(root_window)); |
38 | 36 |
39 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 37 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
40 } | 38 } |
41 | 39 |
42 SpeechMonitor speech_monitor_; | 40 SpeechMonitor speech_monitor_; |
43 std::unique_ptr<ui::test::EventGenerator> generator_; | 41 std::unique_ptr<ui::test::EventGenerator> generator_; |
44 | 42 |
| 43 private: |
45 DISALLOW_COPY_AND_ASSIGN(SelectToSpeakTest); | 44 DISALLOW_COPY_AND_ASSIGN(SelectToSpeakTest); |
46 }; | 45 }; |
47 | 46 |
48 IN_PROC_BROWSER_TEST_F(SelectToSpeakTest, SpeakStatusTray) { | 47 IN_PROC_BROWSER_TEST_F(SelectToSpeakTest, SpeakStatusTray) { |
49 ash::SystemTray* tray = ash::Shell::Get()->GetPrimarySystemTray(); | 48 ash::SystemTray* tray = ash::Shell::Get()->GetPrimarySystemTray(); |
50 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); | 49 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); |
51 | 50 |
52 // Hold down Search and click a few pixels into the status tray bounds. | 51 // Hold down Search and click a few pixels into the status tray bounds. |
53 generator_->PressKey(ui::VKEY_LWIN, 0 /* flags */); | 52 generator_->PressKey(ui::VKEY_LWIN, 0 /* flags */); |
54 generator_->MoveMouseTo(tray_bounds.x() + 8, tray_bounds.y() + 8); | 53 generator_->MoveMouseTo(tray_bounds.x() + 8, tray_bounds.y() + 8); |
55 generator_->PressLeftButton(); | 54 generator_->PressLeftButton(); |
56 generator_->ReleaseLeftButton(); | 55 generator_->ReleaseLeftButton(); |
57 generator_->ReleaseKey(ui::VKEY_LWIN, 0 /* flags */); | 56 generator_->ReleaseKey(ui::VKEY_LWIN, 0 /* flags */); |
58 | 57 |
59 EXPECT_TRUE( | 58 EXPECT_TRUE( |
60 base::MatchPattern(speech_monitor_.GetNextUtterance(), "Status tray*")); | 59 base::MatchPattern(speech_monitor_.GetNextUtterance(), "Status tray*")); |
61 } | 60 } |
62 | 61 |
63 } // namespace chromeos | 62 } // namespace chromeos |
OLD | NEW |