| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 }; | 116 }; |
| 116 | 117 |
| 117 class AccessibilityEventRouterViewsTest | 118 class AccessibilityEventRouterViewsTest |
| 118 : public testing::Test, | 119 : public testing::Test, |
| 119 public content::NotificationObserver { | 120 public content::NotificationObserver { |
| 120 public: | 121 public: |
| 121 virtual void SetUp() { | 122 virtual void SetUp() { |
| 122 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); | 123 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); |
| 123 #if defined(USE_AURA) | 124 #if defined(USE_AURA) |
| 124 root_window_.reset(new aura::RootWindow); | 125 root_window_.reset(new aura::RootWindow); |
| 126 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); |
| 125 test_stacking_client_.reset( | 127 test_stacking_client_.reset( |
| 126 new aura::test::TestStackingClient(root_window_.get())); | 128 new aura::test::TestStackingClient(root_window_.get())); |
| 127 #endif | 129 #endif |
| 128 } | 130 } |
| 129 | 131 |
| 130 virtual void TearDown() { | 132 virtual void TearDown() { |
| 131 #if defined(USE_AURA) | 133 #if defined(USE_AURA) |
| 132 test_stacking_client_.reset(); | 134 test_stacking_client_.reset(); |
| 133 root_window_.reset(); | 135 root_window_.reset(); |
| 134 #endif | 136 #endif |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 316 |
| 315 // Test that we got the event with the expected name and context. | 317 // Test that we got the event with the expected name and context. |
| 316 EXPECT_EQ(1, focus_event_count_); | 318 EXPECT_EQ(1, focus_event_count_); |
| 317 EXPECT_EQ(kButtonNameASCII, last_control_name_); | 319 EXPECT_EQ(kButtonNameASCII, last_control_name_); |
| 318 EXPECT_EQ(kAlertTextASCII, last_control_context_); | 320 EXPECT_EQ(kAlertTextASCII, last_control_context_); |
| 319 | 321 |
| 320 window->CloseNow(); | 322 window->CloseNow(); |
| 321 } | 323 } |
| 322 | 324 |
| 323 #endif // defined(TOOLKIT_VIEWS) | 325 #endif // defined(TOOLKIT_VIEWS) |
| OLD | NEW |