| 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/root_window.h" | 28 #include "ui/aura/root_window.h" |
| 29 #include "ui/aura/test/test_screen.h" |
| 29 #include "ui/aura/test/test_stacking_client.h" | 30 #include "ui/aura/test/test_stacking_client.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 #if defined(TOOLKIT_VIEWS) | 33 #if defined(TOOLKIT_VIEWS) |
| 33 | 34 |
| 34 class AccessibilityViewsDelegate : public views::ViewsDelegate { | 35 class AccessibilityViewsDelegate : public views::ViewsDelegate { |
| 35 public: | 36 public: |
| 36 AccessibilityViewsDelegate() {} | 37 AccessibilityViewsDelegate() {} |
| 37 virtual ~AccessibilityViewsDelegate() {} | 38 virtual ~AccessibilityViewsDelegate() {} |
| 38 | 39 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 class AccessibilityEventRouterViewsTest | 121 class AccessibilityEventRouterViewsTest |
| 121 : public testing::Test, | 122 : public testing::Test, |
| 122 public content::NotificationObserver { | 123 public content::NotificationObserver { |
| 123 public: | 124 public: |
| 124 virtual void SetUp() { | 125 virtual void SetUp() { |
| 125 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); | 126 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); |
| 126 #if defined(USE_AURA) | 127 #if defined(USE_AURA) |
| 127 root_window_.reset(new aura::RootWindow); | 128 root_window_.reset(new aura::RootWindow); |
| 129 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); |
| 128 test_stacking_client_.reset( | 130 test_stacking_client_.reset( |
| 129 new aura::test::TestStackingClient(root_window_.get())); | 131 new aura::test::TestStackingClient(root_window_.get())); |
| 130 #endif | 132 #endif |
| 131 } | 133 } |
| 132 | 134 |
| 133 virtual void TearDown() { | 135 virtual void TearDown() { |
| 134 #if defined(USE_AURA) | 136 #if defined(USE_AURA) |
| 135 test_stacking_client_.reset(); | 137 test_stacking_client_.reset(); |
| 136 root_window_.reset(); | 138 root_window_.reset(); |
| 137 #endif | 139 #endif |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 319 |
| 318 // Test that we got the event with the expected name and context. | 320 // Test that we got the event with the expected name and context. |
| 319 EXPECT_EQ(1, focus_event_count_); | 321 EXPECT_EQ(1, focus_event_count_); |
| 320 EXPECT_EQ(kButtonNameASCII, last_control_name_); | 322 EXPECT_EQ(kButtonNameASCII, last_control_name_); |
| 321 EXPECT_EQ(kAlertTextASCII, last_control_context_); | 323 EXPECT_EQ(kAlertTextASCII, last_control_context_); |
| 322 | 324 |
| 323 window->CloseNow(); | 325 window->CloseNow(); |
| 324 } | 326 } |
| 325 | 327 |
| 326 #endif // defined(TOOLKIT_VIEWS) | 328 #endif // defined(TOOLKIT_VIEWS) |
| OLD | NEW |