| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 10 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
| 11 #include "chrome/browser/ui/views/accessibility_event_router_views.h" | 11 #include "chrome/browser/ui/views/accessibility_event_router_views.h" |
| 12 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/base/accessibility/accessible_view_state.h" | 17 #include "ui/base/accessibility/accessible_view_state.h" |
| 18 #include "ui/views/controls/button/text_button.h" | 18 #include "ui/views/controls/button/text_button.h" |
| 19 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 20 #include "ui/views/layout/grid_layout.h" | 20 #include "ui/views/layout/grid_layout.h" |
| 21 #include "ui/views/views_delegate.h" | 21 #include "ui/views/views_delegate.h" |
| 22 #include "ui/views/widget/native_widget.h" | 22 #include "ui/views/widget/native_widget.h" |
| 23 #include "ui/views/widget/root_view.h" | 23 #include "ui/views/widget/root_view.h" |
| 24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 25 #include "ui/views/widget/widget_delegate.h" | 25 #include "ui/views/widget/widget_delegate.h" |
| 26 | 26 |
| 27 #if defined(USE_AURA) | 27 #if defined(USE_AURA) |
| 28 #include "ui/aura/env.h" |
| 29 #include "ui/aura/monitor_manager.h" |
| 28 #include "ui/aura/root_window.h" | 30 #include "ui/aura/root_window.h" |
| 29 #include "ui/aura/test/test_screen.h" | 31 #include "ui/aura/test/test_screen.h" |
| 30 #include "ui/aura/test/test_stacking_client.h" | 32 #include "ui/aura/test/test_stacking_client.h" |
| 31 #endif | 33 #endif |
| 32 | 34 |
| 33 #if defined(TOOLKIT_VIEWS) | 35 #if defined(TOOLKIT_VIEWS) |
| 34 | 36 |
| 35 class AccessibilityViewsDelegate : public views::ViewsDelegate { | 37 class AccessibilityViewsDelegate : public views::ViewsDelegate { |
| 36 public: | 38 public: |
| 37 AccessibilityViewsDelegate() {} | 39 AccessibilityViewsDelegate() {} |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 }; | 121 }; |
| 120 | 122 |
| 121 class AccessibilityEventRouterViewsTest | 123 class AccessibilityEventRouterViewsTest |
| 122 : public testing::Test, | 124 : public testing::Test, |
| 123 public content::NotificationObserver { | 125 public content::NotificationObserver { |
| 124 public: | 126 public: |
| 125 virtual void SetUp() { | 127 virtual void SetUp() { |
| 126 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); | 128 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); |
| 127 #if defined(USE_AURA) | 129 #if defined(USE_AURA) |
| 128 root_window_.reset(new aura::RootWindow); | 130 root_window_.reset(new aura::RootWindow); |
| 131 aura::Env::GetInstance()->SetMonitorManager( |
| 132 aura::CreateSingleMonitorManager(root_window_.get())); |
| 129 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); | 133 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); |
| 130 test_stacking_client_.reset( | 134 test_stacking_client_.reset( |
| 131 new aura::test::TestStackingClient(root_window_.get())); | 135 new aura::test::TestStackingClient(root_window_.get())); |
| 132 #endif | 136 #endif |
| 133 } | 137 } |
| 134 | 138 |
| 135 virtual void TearDown() { | 139 virtual void TearDown() { |
| 136 #if defined(USE_AURA) | 140 #if defined(USE_AURA) |
| 137 test_stacking_client_.reset(); | 141 test_stacking_client_.reset(); |
| 138 root_window_.reset(); | 142 root_window_.reset(); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 323 |
| 320 // Test that we got the event with the expected name and context. | 324 // Test that we got the event with the expected name and context. |
| 321 EXPECT_EQ(1, focus_event_count_); | 325 EXPECT_EQ(1, focus_event_count_); |
| 322 EXPECT_EQ(kButtonNameASCII, last_control_name_); | 326 EXPECT_EQ(kButtonNameASCII, last_control_name_); |
| 323 EXPECT_EQ(kAlertTextASCII, last_control_context_); | 327 EXPECT_EQ(kAlertTextASCII, last_control_context_); |
| 324 | 328 |
| 325 window->CloseNow(); | 329 window->CloseNow(); |
| 326 } | 330 } |
| 327 | 331 |
| 328 #endif // defined(TOOLKIT_VIEWS) | 332 #endif // defined(TOOLKIT_VIEWS) |
| OLD | NEW |